#?SuikaWikiConfig/2.0 Plugin: @Name: HTML @Description: @@@: Hypertext Markup Language support @@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 $ @RequiredModule[list]: WikiLinking @Namespace: @@sw: http://suika.fam.cx/~wakaba/archive/2004/7/20/sw# @Use: use Message::Util::Error; PluginConst: @NS_XHTML1: http://www.w3.org/1999/xhtml @NS_XHTML2: http://www.w3.org/2002/06/xhtml2 FormattingRule: @Category[list]: view @Name: html-document @Description: @@@: A HTML document @@lang: en @Parameter: @@Name: content @@Type: text @@Default: "" @@Description: @@@@: Content of the documente (in the BODY element) @@@lang:en @Parameter: @@Name: link-meta @@Type: node @@Default: (none) @@Description: @@@@: Metainformation that should be included as part of HEAD element @@@lang:en @Parameter: @@Name: pre-element @@Type: CDATA @@Default: %template (name => ht--pre-element-content); @@Description: @@@@: Pre-root element content (such as PIs) @@@lang: en @Parameter: @@Name: profile @@Type: html:uris @@Default: "http://suika.fam.cx/~wakaba/-temp/wiki/wiki?WikiHTMLMetaProfile" @@Description: @@@@: Profile URIs of metainformation (xhtml1:head/@profile or xhtml2:html/@profile) @@@lang: en @Parameter: @@Name: stylesheets @@Type: CDATA @@Default: %template (name => ht--stylesheets-html); @@Description: @@@@: Stylesheet references @@@lang: en @Parameter: @@Name: title @@Type: text @@Default: (none) @@Description: @@@@: Title (heading) text of the document @@@lang:en @Formatting: my $HTML = $p->{-parent}->append_new_node (type => '#document'); $p->{pre_element} ||= ($p->{-parse_flag}->{pre_element} = 1, '%template (name => ht--pre-element-content);'); __ATTRNODE:%pre_element->{$HTML}__; my $H = $HTML->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'html'); $H->append_text ("\n"); my $h = $H->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'head'); __ATTRTEXT:%profile__; ## Note: HTML 4 requires author being interested in employing ## link types not referred by it and/or META name ## to specify profile URI. $h->set_attribute (profile => ($p->{profile} or q)); $h->append_text ("\n "); ## Note: CGI/1.1 draft 3 (section 9.2) recommends CGI script ## either not to use relative URI reference or to use ## BASE element, to clarify what the resource referred, ## since CGI script has no reliable way to know the ## Request-URI. $h->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'base') ->set_attribute (href => $o->{wiki}->{input}->request_uri); $h->append_text ("\n "); __ATTRNODE:%title->{$h->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'title')}__; $h->append_text ("\n "); __ATTRNODE:%link_meta->{$h}__; $p->{stylesheets} ||= ($p->{-parse_flag}->{stylesheets} = 1, '%template (name => ht--stylesheets-html);'); __ATTRNODE:%stylesheets->{$h}__; __ATTRNODE:%content->{$H}__; FormattingRule: @Category[list]: view @Name: html-meta @Description: @@@: name/val pair of metainformation (META element) @@lang: en @Parameter: @@Name: content @@Type: text @@Default: "" @@Description: @@@@: Value (meta/@content) @@@lang:en @Parameter: @@Name: name @@Type: text @@Default: "" @@Description: @@@@: Name (meta/@name) @@@lang:en @Formatting: my $meta = $p->{-parent}->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'meta'); $meta->option (use_EmptyElemTag => 1); __ATTRTEXT:%name__;__ATTRTEXT:%content__; for my $attr (qw/name content/) { $meta->set_attribute ($attr => $p->{$attr}) if defined $p->{$attr}; } FormattingRule: @Category[list]: view view-resource @Name: link-wiki @Description: @@@: Link from the document to the WikiPage (HTML's LINK element). \ Note that this rule is a shortcut for WikiLinking rules. @@lang:en @Parameter: @@Name: base-page @@Type: WikiName @@Default: (current) @@Description: @@@@:Base WikiName (Relative WikiName is resolved with) @@@lang:en @Parameter: @@Name: class @@Type: HTML4:class @@Default: (none) @@Description: @@@@:Classes of the link or anchor @@@lang:en @Parameter: @@Name: description @@Type: CDATA @@Default: (none) @@Description: @@@@:Description of the link or anchor (HTML's LINK/@title) @@@lang:en @Parameter: @@Name: hreflang @@Type: HTML4:LanguageCode @@Default:(none) @@Description: @@@@:(Human) language the linked WikiPage written in @@@lang:en @Parameter: @@Name: label @@Type: CDATA @@Default: (none) @@Description: @@@@:Source anchor label @@@lang:en @Parameter: @@Name: mode @@Type: WikiMode @@Default:(default) @@Description: @@@@:Mode of the Wiki linked to @@@lang:en @Parameter: @@Name: page @@Type: WikiName @@Default: (current) @@Description: @@@@:WikiPage linked to @@@lang:en @Parameter: @@Name: page-anchor-name @@Type: XML:ID @@Default: (none) @@Description: @@@@:Identifier in WikiPage linked to @@@lang:en @Parameter: @@Name: page-anchor-no @@Type: SGML:NUMBER @@Default: (none) @@Description: @@@@:Numeral anchor index in the WikiPage linked to @@@lang:en @Parameter: @@Name: rel @@Type: HTML4:LinkTypes @@Default:(none) @@Description: @@@@:Link relationships @@@lang:en @Parameter: @@Name: rev @@Type: HTML4:LinkTypes @@Default:(none) @@Description: @@@@:Link relationship (reverse) @@@lang:en # @Parameter: title : obsolete @Parameter: @@Name: type @@Type: HTML4:ContentType @@Default:(none) @@Description: @@@@:Media type the linked WikiPage provided with @@@lang:en @Parameter: @@Name: up-to-date @@Type: boolean @@Default: "0" @@Description: @@@@:Appends random "up-to-date" parameter to the URI reference @@@lang:en @Parameter: @@Name: with-lm @@Type: boolean @@Default:"0" @@Description: @@@@:Appends "last-modified" parameter to the URI reference @@@lang:en @Formatting: __ATTRTEXT:%class__; __ATTRNODE:%label__;__ATTRNODE:%description__;__ATTRNODE:%title__; __ATTRTEXT:%page__;__ATTRTEXT:%base_page__;__ATTRTEXT:%page_anchor_no__; __ATTRTEXT:%with_lm__;__ATTRTEXT:%up_to_date__; __ATTRTEXT:%hreflang__;__ATTRTEXT:%type__; __ATTRTEXT:%mode__; __ATTRTEXT:%rel__;__ATTRTEXT:%rev__; SuikaWiki::Plugin->module_package ('WikiLinking') ->to_wikipage_in_html ( { label => qq(%html-link;\n), -class => $p->{class}, -label => $p->{label}, # obsolete -description => $p->{description} || $p->{title}, } => { base => $o->{wiki}->name ($p->{base_page} || $o->{page}), page_name_relative => $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page}), page_anchor_no => $p->{page_anchor_no}, page_anchor_name=> $p->{page_anchor_name}, wiki_mode => $p->{mode}, _with_lm => $p->{with_lm}, _up_to_date => $p->{up_to_date}, -lang => $p->{hreflang}, -type => $p->{type}, }, { o => $o, parent => $p->{-parent}, -rel => $p->{rel}, -rev => $p->{rev}, }); FormattingRule: @Category[list]: page-link link-to-resource @Name:html-link @Description: @@@:HTML LINK element @@lang:en @Parameter: @@Name: description @@Type: text @@Default: (auto) @@Description: @@@@: Human readable description. @@@lang: en @Formatting: my $LINK = $p->{-parent}->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'link'); $LINK->set_attribute (href => $o->{link}->{dest}->{uri}); $p->{description} ||= ($p->{-parse_flag}->{description} = 1, $o->{link}->{src}->{-ht__alt_description}); __ATTRTEXT:%description__; if (length $p->{description}) { $LINK->set_attribute (title => $p->{description}); } elsif (defined $o->{link}->{src}->{-description}) { $LINK->set_attribute (title => $o->{link}->{src}->{-description}->inner_text); } elsif (defined $o->{link}->{src}->{-label}) { $LINK->set_attribute (title => $o->{link}->{src}->{-label}->inner_text); } my @class = (split (/\s+/, $p->{class}), split (/\s+/, $o->{link}->{src}->{-class})); if ($o->{wiki}->uri_is_part_of_wiki ($o->{link}->{dest}->{absolute_uri} or $o->{link}->{dest}->{uri})) { push @class, 'wiki'; ## Link to the page within the Wiki } $LINK->set_attribute (class => join ' ', @class) if @class; $LINK->set_attribute (rel => $o->{link}->{option}->{-rel}) if $o->{link}->{option}->{-rel}; $LINK->set_attribute (rev => $o->{link}->{option}->{-rev}) if $o->{link}->{option}->{-rev}; $LINK->set_attribute (hreflang => $o->{link}->{dest}->{-lang}) if $o->{link}->{dest}->{-lang}; $LINK->set_attribute (type => $o->{link}->{dest}->{-type}) if $o->{link}->{dest}->{-type}; $LINK->option (use_EmptyElemTag => 1); FormattingRule: @Category[list]: form-input view view-resource page-link @Name: span @Formatting: my $span = $p->{-parent}->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'span'); __ATTRTEXT:%class__; $span->set_attribute (class => $p->{class}); __ATTRNODE:%content->{$span}__; FormattingRule: @Category[list]: view @Name: html--meta-keywords @Description: @@lang: en @@@: An HTML meta element with name of "keywords" @Parameter: @@Name: page @@Type: WikiName @@Default: (current) @@Description: @@@lang: en @@@@: WikiPage of which keywords are shown. @Formatting: my $page = $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page}); my $content_prop; try { $content_prop = $o->{wiki}->{db}->get (content_prop => $page); } catch SuikaWiki::DB::Util::Error with { my $err = shift; $err->throw if $err->{-type} eq 'ERROR_REPORTED'; } catch SuikaWiki::Format::Definition::error with { # }; if ($content_prop) { my $kwd = $content_prop->get_attribute_value (); if (ref $kwd and @$kwd) { for my $META ($p->{-parent}->append_new_node (type => '#element', namespace_uri => $NS_XHTML1, local_name => 'meta')) { $META->set_attribute (name => 'keywords'); $META->set_attribute (content => join ', ', @$kwd); ## NOTE: Keyword that contains COMMAs will be broken. $META->option (use_EmptyElemTag => 1); } } }