| 1 |
#?SuikaWikiConfig/2.0 |
| 2 |
|
| 3 |
Plugin: |
| 4 |
@Name: WikiStruct |
| 5 |
@Description: |
| 6 |
@@@: Structural elements |
| 7 |
@@lang:en |
| 8 |
@License: %%GPL%% |
| 9 |
@Author: |
| 10 |
@@Name: |
| 11 |
@@@@: Wakaba |
| 12 |
@@@lang:ja |
| 13 |
@@@script:Latn |
| 14 |
@@Mail[list]: w@suika.fam.cx |
| 15 |
@Date.RCS: $Date: 2004/02/01 12:19:34 $ |
| 16 |
|
| 17 |
ViewFragment: |
| 18 |
@Name: ws--page |
| 19 |
@Description: |
| 20 |
@@@: Basic page body structure |
| 21 |
@Order: 0 |
| 22 |
@Formatting: |
| 23 |
%section ( |
| 24 |
type => body, |
| 25 |
title => {%page-name;}p, heading, |
| 26 |
content => { |
| 27 |
%template (name => ws--pre-content); |
| 28 |
%apply-template (name => content); |
| 29 |
%template (name => ws--post-content); |
| 30 |
}p, |
| 31 |
); |
| 32 |
|
| 33 |
ViewFragment: |
| 34 |
@Name: ws--pre-content |
| 35 |
@Description: |
| 36 |
@@@: Before content body -- navigation bar |
| 37 |
@@lang:en |
| 38 |
@Order: 0 |
| 39 |
@Formatting: |
| 40 |
%block ( |
| 41 |
id => tools1, class => tools, |
| 42 |
content => {%template (name => navbar);}p, |
| 43 |
); |
| 44 |
|
| 45 |
ViewFragment: |
| 46 |
@Name: ws--post-content |
| 47 |
@Description: |
| 48 |
@@@: After content body -- navigation bar |
| 49 |
@@lang:en |
| 50 |
@Order: 900 |
| 51 |
@Formatting: |
| 52 |
%block ( |
| 53 |
id => tools2, class => tools, |
| 54 |
content => {%template (name => navbar);}p, |
| 55 |
); |
| 56 |
|
| 57 |
ViewFragment: |
| 58 |
@Name: ws--post-content |
| 59 |
@Description: |
| 60 |
@@@: After content body -- footer |
| 61 |
@@lang:en |
| 62 |
@Order: 1000 |
| 63 |
@Formatting: |
| 64 |
%block ( |
| 65 |
id => footer, |
| 66 |
content => {%template (name => ws--footer);}p, |
| 67 |
); |
| 68 |
|
| 69 |
PluginConst: |
| 70 |
@NS_XHTML1: |
| 71 |
http://www.w3.org/1999/xhtml |
| 72 |
@NS_XHTML2: |
| 73 |
http://www.w3.org/2002/06/xhtml2 |
| 74 |
|
| 75 |
FormattingRule: |
| 76 |
@Category[list]: |
| 77 |
view |
| 78 |
view-resource |
| 79 |
form-input |
| 80 |
@Name: section |
| 81 |
@Description: |
| 82 |
@@@: |
| 83 |
A section |
| 84 |
@@lang: en |
| 85 |
@Parameter: |
| 86 |
@@Name: add-to-toc |
| 87 |
@@Type: boolean |
| 88 |
@@Default: {1} |
| 89 |
@@Description: |
| 90 |
@@@@: Whether adding this section to the Table of Contents list |
| 91 |
@@@lang:en |
| 92 |
@Parameter: |
| 93 |
@@Name: class |
| 94 |
@@Type: classes |
| 95 |
@@Default: (none) |
| 96 |
@@Description: |
| 97 |
@@@@: Class of section |
| 98 |
@@@lang:en |
| 99 |
@Parameter: |
| 100 |
@@Name: content |
| 101 |
@@Type: text |
| 102 |
@@Default: "" |
| 103 |
@@Description: |
| 104 |
@@@@: Content of section |
| 105 |
@@@lang:en |
| 106 |
@Parameter: |
| 107 |
@@Name: heading |
| 108 |
@@Type: boolean |
| 109 |
@@Default: {0} |
| 110 |
@@Description: Output title as a heading |
| 111 |
@Parameter: |
| 112 |
@@Name: id |
| 113 |
@@Type: ID |
| 114 |
@@Default: (none) |
| 115 |
@@Description: |
| 116 |
@@@@: |
| 117 |
Unique identifier |
| 118 |
\ |
| 119 |
Note: its uniqueness is not verified by |
| 120 |
the WikiEngine. |
| 121 |
\ |
| 122 |
Note: unless explicily specified, anomymous identifier is generated |
| 123 |
automatically if necessary |
| 124 |
@@@lang:en |
| 125 |
@Parameter: |
| 126 |
@@Name: title |
| 127 |
@@Type: text |
| 128 |
@@Default: (none) |
| 129 |
@@Description: |
| 130 |
@@@@: Title (heading) text of the section |
| 131 |
@@@lang:en |
| 132 |
@Formatting: |
| 133 |
local $o->{var}->{ws__section_depth} = $o->{var}->{ws__section_depth} + 1; |
| 134 |
__ATTRNODE:%content__; |
| 135 |
if ($p->{content}->count) { |
| 136 |
__ATTRTEXT:%type__;__ATTRTEXT:%class__;__ATTRTEXT:%id__; |
| 137 |
my $section = __FUNCPACK__->append_new_div |
| 138 |
($p->{-parent}, |
| 139 |
type => $p->{type}, |
| 140 |
wiki => $o->{wiki}, |
| 141 |
id => $p->{id}, |
| 142 |
class1 => 'wiki-section', |
| 143 |
class2 => $p->{class}); |
| 144 |
__ATTRTEXT:%heading__; |
| 145 |
if ($p->{heading}) { |
| 146 |
if ($o->{var}->{ws__section_depth} > 6) { |
| 147 |
my $h = $section->append_new_node (type => '#element', |
| 148 |
namespace_uri => $NS_XHTML1, |
| 149 |
local_name => 'div'); |
| 150 |
$h->set_attribute (class => 'heading h' |
| 151 |
.$o->{var}->{ws__section_depth}); |
| 152 |
__ATTRNODE:%title->{$h}__; |
| 153 |
} else { |
| 154 |
__ATTRNODE:%title->{ |
| 155 |
$section->append_new_node |
| 156 |
(type => '#element', |
| 157 |
namespace_uri => $NS_XHTML1, |
| 158 |
local_name => 'h'.$o->{var}->{ws__section_depth}) |
| 159 |
}__; |
| 160 |
} |
| 161 |
} |
| 162 |
$section->append_text ("\n"); |
| 163 |
$section->append_node ($p->{content}); |
| 164 |
} |
| 165 |
|
| 166 |
FormattingRule: |
| 167 |
@Category[list]: |
| 168 |
view |
| 169 |
view-resource |
| 170 |
form-input |
| 171 |
@Name: paragraph |
| 172 |
@Description: |
| 173 |
@@@: |
| 174 |
A paragraph |
| 175 |
@@lang: en |
| 176 |
@Parameter: |
| 177 |
@@Name: class |
| 178 |
@@Type: classes |
| 179 |
@@Default: (none) |
| 180 |
@@Description: |
| 181 |
@@@@: Class of section |
| 182 |
@@@lang:en |
| 183 |
@Parameter: |
| 184 |
@@Name: content |
| 185 |
@@Type: text |
| 186 |
@@Default: "" |
| 187 |
@@Description: |
| 188 |
@@@@: Content of section |
| 189 |
@@@lang:en |
| 190 |
@Parameter: |
| 191 |
@@Name: id |
| 192 |
@@Type: |
| 193 |
XML:ID |
| 194 |
@@Default: (none) |
| 195 |
@@Description: |
| 196 |
@@@@: |
| 197 |
Unique identifier |
| 198 |
\ |
| 199 |
Note: its uniqueness is not verified by |
| 200 |
the WikiEngine. |
| 201 |
\ |
| 202 |
Note: unless explicily specified, anomymous identifier is generated |
| 203 |
automatically if necessary |
| 204 |
@@@lang:en |
| 205 |
@Formatting: |
| 206 |
__ATTRNODE:%content__; |
| 207 |
if ($p->{content}->count) { |
| 208 |
my $block = $p->{-parent}->append_new_node |
| 209 |
(type => '#element', namespace_uri => $NS_XHTML1, local_name => 'p'); |
| 210 |
$block->append_node ($p->{content}); |
| 211 |
__ATTRTEXT:%class__;__ATTRTEXT:%id__; |
| 212 |
$block->set_attribute (class => $p->{class}) if $p->{class}; |
| 213 |
__FUNCPACK__->set_id ($block, $p->{id}, $o->{wiki}); |
| 214 |
} |
| 215 |
|
| 216 |
FormattingRule: |
| 217 |
@Category[list]: |
| 218 |
view |
| 219 |
view-resource |
| 220 |
form-input |
| 221 |
@Name: block |
| 222 |
@Description: |
| 223 |
@@@: |
| 224 |
A semantically-classed block |
| 225 |
@@lang: en |
| 226 |
@Parameter: |
| 227 |
@@Name: class |
| 228 |
@@Type: classes |
| 229 |
@@Default: (none) |
| 230 |
@@Description: |
| 231 |
@@@@: Class of section |
| 232 |
@@@lang:en |
| 233 |
@Parameter: |
| 234 |
@@Name: content |
| 235 |
@@Type: text |
| 236 |
@@Default: "" |
| 237 |
@@Description: |
| 238 |
@@@@: Content of section |
| 239 |
@@@lang:en |
| 240 |
@Parameter: |
| 241 |
@@Name: id |
| 242 |
@@Type: |
| 243 |
XML:ID |
| 244 |
@@Default: (none) |
| 245 |
@@Description: |
| 246 |
@@@@: |
| 247 |
Unique identifier |
| 248 |
\ |
| 249 |
Note: its uniqueness is not verified by |
| 250 |
the WikiEngine. |
| 251 |
\ |
| 252 |
Note: unless explicily specified, anomymous identifier is generated |
| 253 |
automatically if necessary |
| 254 |
@@@lang:en |
| 255 |
@Formatting: |
| 256 |
__ATTRNODE:%content__; |
| 257 |
if ($p->{content}->count) { |
| 258 |
__ATTRTEXT:%class__;__ATTRTEXT:%id__; |
| 259 |
my $block = __FUNCPACK__->append_new_div ($p->{-parent}, |
| 260 |
id => $p->{id}, |
| 261 |
class1 => 'block', |
| 262 |
class2 => $p->{class}, |
| 263 |
wiki => $o->{wiki}); |
| 264 |
$block->append_node ($p->{content}, node_or_text => 1); |
| 265 |
__ATTRTEXT:%class__;__ATTRTEXT:%id__; |
| 266 |
} |
| 267 |
|
| 268 |
FormattingRule: |
| 269 |
@Category[list]: |
| 270 |
view |
| 271 |
view-resource |
| 272 |
form-input |
| 273 |
@Name: line |
| 274 |
@Description: |
| 275 |
@@@: |
| 276 |
A semantically line |
| 277 |
@@lang: en |
| 278 |
@Parameter: |
| 279 |
@@Name: class |
| 280 |
@@Type: classes |
| 281 |
@@Default: (none) |
| 282 |
@@Description: |
| 283 |
@@@@: Class of section |
| 284 |
@@@lang:en |
| 285 |
@Parameter: |
| 286 |
@@Name: content |
| 287 |
@@Type: text |
| 288 |
@@Default: "" |
| 289 |
@@Description: |
| 290 |
@@@@: Content of the line |
| 291 |
@@@lang:en |
| 292 |
@Formatting: |
| 293 |
__ATTRNODE:%content__; |
| 294 |
if ($p->{content}->count) { |
| 295 |
$p->{-parent}->append_node ($p->{content}, node_or_text => 1); |
| 296 |
$p->{-parent}->append_new_node |
| 297 |
(type => '#element', namespace_uri => $NS_XHTML1, local_name => 'br') |
| 298 |
->option (use_EmptyElemTag => 1); |
| 299 |
} |
| 300 |
|
| 301 |
@ ( XHTML 2 ) : |
| 302 |
|
| 303 |
__ATTRNODE:%content__; |
| 304 |
if ($p->{content}->count) { |
| 305 |
my $block = $p->{-parent}->append_new_node |
| 306 |
(type => '#element', namespace_uri => $NS_XHTML2, local_name => 'l'); |
| 307 |
$block->append_node ($p->{content}, node_or_text => 1); |
| 308 |
__ATTRTEXT:%class__; |
| 309 |
$block->set_attribute (class => 'block ' . $p->{class}); |
| 310 |
} |
| 311 |
|
| 312 |
FormattingRule: |
| 313 |
@Category[list]: |
| 314 |
view |
| 315 |
view-resource |
| 316 |
form-input |
| 317 |
@Name: list |
| 318 |
@Pre: |
| 319 |
$p->{-ws__list} ||= []; |
| 320 |
@Attribute: |
| 321 |
if ($param_name eq '-boolean') { |
| 322 |
if (index ($opt{-name_flag}, 'p') > -1) { |
| 323 |
$param_value = $f->replace ($param_value, param => $o); |
| 324 |
} |
| 325 |
push @{$p->{-ws__list}}, [$param_value] if $param_name->count; |
| 326 |
} else { |
| 327 |
if (index ($opt{-name_flag}, 'p') > -1) { |
| 328 |
$param_name = $f->replace ($param_name, param => $o); |
| 329 |
} |
| 330 |
if (index ($opt{-value_flag}, 'p') > -1) { |
| 331 |
$param_value = $f->replace ($param_value, param => $o); |
| 332 |
} |
| 333 |
push @{$p->{-ws__list}}, [$param_name => $param_value] |
| 334 |
if $param_value->count; |
| 335 |
} |
| 336 |
@Formatting: |
| 337 |
my $dl = $p->{-parent} |
| 338 |
->append_new_node (type => '#element', |
| 339 |
namespace_uri => $NS_XHTML1, |
| 340 |
local_name => 'dl'); |
| 341 |
for (@{$p->{-ws__list}}) { |
| 342 |
$dl->append_new_node (type => '#element', |
| 343 |
namespace_uri => $NS_XHTML1, |
| 344 |
local_name => 'dt') |
| 345 |
->append_node ($_->[0], node_or_text => 1); |
| 346 |
$dl->append_new_node (type => '#element', |
| 347 |
namespace_uri => $NS_XHTML1, |
| 348 |
local_name => 'dd') |
| 349 |
->append_node ($_->[1], node_or_text => 1) if length $_->[1]; |
| 350 |
} |
| 351 |
|
| 352 |
Function: |
| 353 |
@Name: append_new_div |
| 354 |
@Description: |
| 355 |
@@@: |
| 356 |
Appending a new DIV element |
| 357 |
@@lang:en |
| 358 |
@Main: |
| 359 |
my (undef, $parent, %opt) = @_; |
| 360 |
my $div = $parent->append_new_node (type => '#element', |
| 361 |
namespace_uri => $NS_XHTML1, |
| 362 |
local_name => $opt{type}||'div'); |
| 363 |
$div->append_new_node (type => '#element', |
| 364 |
namespace_uri => $NS_XHTML1, |
| 365 |
local_name => 'p') |
| 366 |
if $opt{wiki}->{var}->{client}->{downgrade}->{html_no_div}; |
| 367 |
__FUNCPACK__->set_id ($div, $opt{id}, $opt{wiki}) if $opt{id}; |
| 368 |
my @class = (split (/\s+/, $opt{class1}), split (/\s+/, $opt{class2})); |
| 369 |
$div->set_attribute (class => join ' ', @class) if @class; |
| 370 |
$parent->append_text ("\n"); |
| 371 |
return $div; |
| 372 |
|
| 373 |
Function: |
| 374 |
@Name: set_id |
| 375 |
@Description: |
| 376 |
@@@: |
| 377 |
Set id attribute if necessary. |
| 378 |
\ |
| 379 |
HTML A element with name attribute is also appended |
| 380 |
if client user agent is of old version. |
| 381 |
@@lang:en |
| 382 |
@Main: |
| 383 |
my (undef, $node, $id, $wiki) = @_; |
| 384 |
return unless $id; |
| 385 |
$node->set_attribute (id => $id); |
| 386 |
if ($wiki->{var}->{client}->{downgrade}->{html_no_id}) { |
| 387 |
my $a = $node->append_new_node (type => '#element', |
| 388 |
namespace_uri => $NS_XHTML1, |
| 389 |
local_name => 'a'); |
| 390 |
$a->set_attribute (name => $id); |
| 391 |
unshift @{$node->child_nodes}, pop @{$node->child_nodes}; |
| 392 |
} |
| 393 |
|
| 394 |
Function: |
| 395 |
@Name: set_section_id |
| 396 |
@Description: |
| 397 |
@@@: |
| 398 |
Set id attribute for the section node, with id generated from |
| 399 |
section title |
| 400 |
@@lang: en |
| 401 |
@Main: |
| 402 |
my (undef, $node, $id, $wiki, %opt) = @_; |
| 403 |
$id ||= __FUNCPACK__->get_section_id (wiki => $wiki, %opt); |
| 404 |
$node->set_attribute (id => $id); |
| 405 |
if ($wiki->{var}->{client}->{downgrade}->{html_no_id}) { |
| 406 |
my $a = $node->append_new_node (type => '#element', |
| 407 |
namespace_uri => $NS_XHTML1, |
| 408 |
local_name => 'a'); |
| 409 |
$a->set_attribute (name => $id); |
| 410 |
unshift @{$node->child_nodes}, pop @{$node->child_nodes}; |
| 411 |
} |
| 412 |
|
| 413 |
Function: |
| 414 |
@Name: get_section_id |
| 415 |
@Main: |
| 416 |
my (undef, %opt) = @_; |
| 417 |
unless ($opt{id}) { |
| 418 |
$opt{id} = $opt{title}; |
| 419 |
## TODO: Use Punycode |
| 420 |
$opt{id} =~ s/([^0-9A-Za-z_-])/sprintf '.%02X', ord $1/ge; |
| 421 |
$opt{id} = uc ($opt{prefix} || 'WS--SECTION') . '--TEMP--' . $opt{id}; |
| 422 |
} |
| 423 |
if ($__FUNCPACK__::IDIndex{$opt{id}}++) { |
| 424 |
$opt{id} .= '..' . $__FUNCPACK__::IDIndex{$opt{id}}; |
| 425 |
} |
| 426 |
$opt{id}; |
| 427 |
|