#?SuikaWikiConfig/2.0 Plugin: @Name: WikiStruct @Description: @@@: Structural elements @@lang:en @License: %%Perl%% @Author: @@Name: @@@@: Wakaba @@@lang:ja @@@script:Latn @@Mail[list]: w@suika.fam.cx @Date.RCS: $Date: 2004/07/25 06:54:29 $ ViewFragment: @Name: ws--page @Description: @@@: Basic page body structure @Order: 0 @Formatting: %section ( type => body, title => {%page-name;}p, heading, content => { %template (name => ws--pre-content); %apply-template (name => content); %template (name => ws--post-content); }p, ); ViewFragment: @Name: ws--pre-content @Description: @@@: Before content body -- navigation bar @@lang:en @Order: 0 @Formatting: %block ( id => tools1, class => tools, content => {%template (name => navbar);}p, ); ViewFragment: @Name: ws--post-content @Description: @@@: After content body -- navigation bar @@lang:en @Order: 900 @Formatting: %block ( id => tools2, class => tools, content => {%template (name => navbar);}p, ); ViewFragment: @Name: ws--post-content @Description: @@@: After content body -- footer @@lang:en @Order: 1000 @Formatting: %block ( id => footer, content => {%template (name => ws--footer);}p, ); PluginConst: @NS_XHTML1: http://www.w3.org/1999/xhtml @NS_XHTML2: http://www.w3.org/2002/06/xhtml2 FormattingRule: @Category[list]: view view-resource form-input @Name: section @Description: @@@: A section @@lang: en @Parameter: @@Name: add-to-toc @@Type: boolean @@Default: {1} @@Description: @@@@: Whether adding this section to the Table of Contents list @@@lang:en @Parameter: @@Name: class @@Type: classes @@Default: (none) @@Description: @@@@: Class of section @@@lang:en @Parameter: @@Name: content @@Type: text @@Default: "" @@Description: @@@@: Content of section @@@lang:en @Parameter: @@Name: heading @@Type: boolean @@Default: {0} @@Description: Output title as a heading @Parameter: @@Name: id @@Type: ID @@Default: (none) @@Description: @@@@: Unique identifier \ Note: its uniqueness is not verified by the WikiEngine. \ Note: unless explicily specified, anomymous identifier is generated automatically if necessary @@@lang:en @Parameter: @@Name: title @@Type: text @@Default: (none) @@Description: @@@@: Title (heading) text of the section @@@lang:en @Formatting: local $o->{var}->{ws__section_depth} = $o->{var}->{ws__section_depth} + 1; __ATTRNODE:%content__; if ($p->{content}->count) { __ATTRTEXT:%type__;__ATTRTEXT:%class__;__ATTRTEXT:%id__; my $section = __FUNCPACK__->append_new_div ($p->{-parent}, type => $p->{type}, wiki => $o->{wiki}, id => $p->{id}, class1 => 'wiki-section', class2 => $p->{class}); __ATTRTEXT:%heading__; if ($p->{heading}) { if ($o->{var}->{ws__section_depth} > 6) { my $h = $section->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'div'); $h->set_attribute (class => 'heading h' .$o->{var}->{ws__section_depth}); __ATTRNODE:%title->{$h}__; } else { __ATTRNODE:%title->{ $section->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'h'.$o->{var}->{ws__section_depth}) }__; } } $section->append_text ("\n"); $section->append_node ($p->{content}); } FormattingRule: @Category[list]: view view-resource form-input @Name: paragraph @Description: @@@: A paragraph @@lang: en @Parameter: @@Name: class @@Type: classes @@Default: (none) @@Description: @@@@: Class of section @@@lang:en @Parameter: @@Name: content @@Type: text @@Default: "" @@Description: @@@@: Content of section @@@lang:en @Parameter: @@Name: id @@Type: XML:ID @@Default: (none) @@Description: @@@@: Unique identifier \ Note: its uniqueness is not verified by the WikiEngine. \ Note: unless explicily specified, anomymous identifier is generated automatically if necessary @@@lang:en @Formatting: __ATTRNODE:%content__; if ($p->{content}->count) { my $block = $p->{-parent}->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'p'); $block->append_node ($p->{content}); __ATTRTEXT:%class__;__ATTRTEXT:%id__; $block->set_attribute (class => $p->{class}) if $p->{class}; __FUNCPACK__->set_id ($block, $p->{id}, $o->{wiki}); } FormattingRule: @Category[list]: view view-resource form-input @Name: block @Description: @@@: A semantically-classed block @@lang: en @Parameter: @@Name: class @@Type: classes @@Default: (none) @@Description: @@@@: Class of section @@@lang:en @Parameter: @@Name: content @@Type: text @@Default: "" @@Description: @@@@: Content of section @@@lang:en @Parameter: @@Name: id @@Type: XML:ID @@Default: (none) @@Description: @@@@: Unique identifier \ Note: its uniqueness is not verified by the WikiEngine. \ Note: unless explicily specified, anomymous identifier is generated automatically if necessary @@@lang:en @Formatting: __ATTRNODE:%content__; if ($p->{content}->count) { __ATTRTEXT:%class__;__ATTRTEXT:%id__; my $block = __FUNCPACK__->append_new_div ($p->{-parent}, id => $p->{id}, class1 => 'block', class2 => $p->{class}, wiki => $o->{wiki}); $block->append_node ($p->{content}, node_or_text => 1); __ATTRTEXT:%class__;__ATTRTEXT:%id__; } FormattingRule: @Category[list]: view view-resource form-input page-link link-to-resource @Name: line @Description: @@@: A semantically line @@lang: en @Parameter: @@Name: class @@Type: classes @@Default: (none) @@Description: @@@@: Class of section @@@lang:en @Parameter: @@Name: content @@Type: text @@Default: "" @@Description: @@@@: Content of the line @@@lang:en @Formatting: __ATTRNODE:%content__; if ($p->{content}->count) { $p->{-parent}->append_node ($p->{content}, node_or_text => 1); $p->{-parent}->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'br') ->option (use_EmptyElemTag => 1); } @ ( XHTML 2 ) : __ATTRNODE:%content__; if ($p->{content}->count) { my $block = $p->{-parent}->append_new_node (type => '#element', namespace_uri => $NS_XHTML2, local_name => 'l'); $block->append_node ($p->{content}, node_or_text => 1); __ATTRTEXT:%class__; $block->set_attribute (class => 'block ' . $p->{class}); } FormattingRule: @Category[list]: view view-resource form-input @Name: list @Pre: $p->{-ws__list} ||= []; @Attribute: if ($param_name eq '-boolean') { if (index ($opt{-name_flag}, 'p') > -1) { $param_value = $f->replace ($param_value, param => $o); } push @{$p->{-ws__list}}, [$param_value] if $param_name->count; } elsif ($param_name eq 'x') { if (index ($opt{-value_flag}, 'p') > -1) { $param_value = $f->replace ($param_value, param => $o); } push @{$p->{-ws__list}}, [$param_value] if $param_value->count; } else { if (index ($opt{-name_flag}, 'p') > -1) { $param_name = $f->replace ($param_name, param => $o); } if (index ($opt{-value_flag}, 'p') > -1) { $param_value = $f->replace ($param_value, param => $o); } push @{$p->{-ws__list}}, [$param_name => $param_value] if $param_value->count; } @Formatting: my $dl = $p->{-parent} ->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'dl'); for (@{$p->{-ws__list}}) { $dl->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'dt') ->append_node ($_->[0], node_or_text => 1); $dl->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'dd') ->append_node ($_->[1], node_or_text => 1) if length $_->[1]; } Function: @Name: append_new_div @Description: @@@: Appending a new DIV element @@lang:en @Main: my (undef, $parent, %opt) = @_; my $div = $parent->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => $opt{type}||'div'); $div->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'p') if $opt{wiki}->{var}->{client}->{downgrade}->{html_no_div}; __FUNCPACK__->set_id ($div, $opt{id}, $opt{wiki}) if $opt{id}; my @class = (split (/\s+/, $opt{class1}), split (/\s+/, $opt{class2})); $div->set_attribute (class => join ' ', @class) if @class; $parent->append_text ("\n"); return $div; Function: @Name: set_id @Description: @@@: Set id attribute if necessary. \ HTML A element with name attribute is also appended if client user agent is of old version. @@lang:en @Main: my (undef, $node, $id, $wiki) = @_; return unless $id; $node->set_attribute (id => $id); if ($wiki->{var}->{client}->{downgrade}->{html_no_id}) { my $a = $node->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'a'); $a->set_attribute (name => $id); unshift @{$node->child_nodes}, pop @{$node->child_nodes}; } Function: @Name: set_section_id @Description: @@@: Set id attribute for the section node, with id generated from section title @@lang: en @Main: my (undef, $node, $id, $wiki, %opt) = @_; $id ||= __FUNCPACK__->get_section_id (wiki => $wiki, %opt); $node->set_attribute (id => $id); if ($wiki->{var}->{client}->{downgrade}->{html_no_id}) { my $a = $node->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'a'); $a->set_attribute (name => $id); unshift @{$node->child_nodes}, pop @{$node->child_nodes}; } Function: @Name: get_section_id @Main: my (undef, %opt) = @_; unless ($opt{id}) { $opt{id} = $opt{title}; ## TODO: Use Punycode $opt{id} =~ s/([^0-9A-Za-z_-])/sprintf '.%02X', ord $1/ge; $opt{id} = uc ($opt{prefix} || 'WS--SECTION') . '--TEMP--' . $opt{id}; } if ($__FUNCPACK__::IDIndex{$opt{id}}++) { $opt{id} .= '..' . $__FUNCPACK__::IDIndex{$opt{id}}; } $opt{id};