#?SuikaWikiConfig/2.0 Plugin: @Name: InterWikiForWikiEngine @Description: @@@: InterWiki - External WikiEngine URI Reference Support @@lang:en @License: %%Perl%% @Author: @@Name: @@@@: Wakaba @@@lang:ja @@@script:Latn @@Mail[list]: w@suika.fam.cx @Date.RCS: $Date: 2004/03/10 06:57:25 $ @RequiredModule[list]: main URI @RequiredPlugin[list]: InterWikiCore @Use: require URI; our $INTERWIKICORE; PluginConst: @INTERWIKICORE: {($INTERWIKICORE ||= SuikaWiki::Plugin->module_package ('InterWikiCore'))} FormattingRule: @Category[list]: iwc--urireference @Name: suikawiki @Description: @@@: SuikaWiki URI Reference. @@lang:en @Parameter: @@Name: anchor-no @@Type: integer @@Default: (none) @@Description: @@@: Fragment anchor number @@lang:en @Parameter: @@Name: fragment @@Type: URI:fragment @@Default: (none) @@Description: @@@: Fragment identifier @@lang:en @Parameter: @@Name: mode @@Type: mode @@Default: (none) @@Description: @@@: Mode name. @@lang: en @Parameter: @@Name: page @@Type: WikiName @@Default: (none) @@Description: @@@: WikiPage @@lang: en @Parameter: @@Name: up-to-date @@Type: boolean @@Default: "0" @@Description: @@@: Whether dummy "up to date" parameter should be appended @@lang:en @Parameter: @@Name: version @@Type: number @@Default: (auto) @@Description: @@@: Version number of SuikaWiki interface. "2.0" or "2.9". @@lang: en @Parameter: @@Name: wiki-uri @@Type: URIReference @@Default: (current) @@Description: @@@: Base wiki URI @@lang: en @Post: if (not $p->{version} or $p->{version} >= 2.9) { $p->{-result} = $o->{wiki}->uri_reference (version => $p->{version}+0, wiki_uri => $p->{base} ? URI->new ($p->{base}) : undef, page => $o->{wiki}->name ($p->{page}), mode => $p->{mode}, up_to_date => $p->{up_to_date}, # with_lm => $p->{with_lm}, anchor_no => $p->{anchor_no}, fragment => $p->{fragment}); } else { # SuikaWiki 2 $p->{-result} = URI->new ($p->{base}); if ($INTERWIKICORE->uri_has_feature (uri => $p->{-result}, method => 'query_form')) { if ($p->{page} and not $p->{mode} and not $p->{up_to_date}) { $p->{-result}->query ($INTERWIKICORE->uri_escape_encode ($p->{page}, qr([^0-9A-Za-z_.-]))); } else { my %query; $query{mypage} = $p->{page} if $p->{page}; $query{mycmd} = $p->{mode} if $p->{mode}; $query{up_to_date} = time if $p->{up_to_date}; $p->{-result}->query_form (%query); } } if ($p->{anchor_no}) { $p->{-result}->fragment ('anchor-'.(0+$p->{anchor_no})); } elsif ($p->{fragment}) { $p->{-result}->fragment ($p->{fragment}); } } FormattingRule: @Category[list]: iwc--urireference @Name: yukiwiki @Description: @@@: YukiWiki URI Reference. This rule can be used to specify URI reference to YukiWiki or derived works (such as WalWiki). \ "version" parameter controls URI reference generating procedure. \ In YukiWiki 1, non-alphabetical WikiName (BracketName) automatically enclosed by "[[" and "]]". \ In YukiWiki 2, only WikiName is used as URI query when no other parameter required (ie. ). @Parameter: @@Name: charset @@Type: charset @@Default: (auto) @@Description: @@@: Charset in which query parameters should be encoded. \ In YukiWiki 1, it is defaulted to "shift_jis", while otherwise defaulted to "euc-jp". @Parameter: @@Name: mycmd @@Type: YukiWiki:mycmd @@Default: (none) @@Description: @@@: YukiWiki command @@lang: en @Parameter: @@Name: mymsg @@Type: CDATA @@Default: (none) @@Description: @@@: YukiWiki "mymsg" parameter (unescaped) @@lang: en @Parameter: @@Name: mypage @@Type: YukiWiki:WikiName @@Default: (none) @@Description: @@@: WikiPage name @@lang: en @Parameter: @@Name: version @@Type: number @@Default: (auto) @@Description: @@@: YukiWiki version number @@lang: en @Post: $p->{-result} = URI->new ($p->{base}); return unless $INTERWIKICORE->uri_has_feature (uri => $p->{-result}, method => 'query_form'); if (not $p->{version} or $p->{version} >= 2.0) { if ($p->{mypage} and not $p->{mycmd}) { $p->{mypage} = &main::code_convert (\$p->{mypage}, $p->{charset} || 'euc-jp'); $p->{-result}->query ($INTERWIKICORE->uri_escape_encode ($p->{mypage}, qr([^0-9A-Za-z_.-]))); } else { my %query; for (qw/mypage mycmd mymsg/) { $query{$_} = &main::code_convert (\$p->{$_}, $p->{charset} || 'euc-jp') if length $p->{$_}; } $p->{-result}->query_form (%query); } } else { # YukiWiki 1 $p->{mypage} = qq([[$p->{mypage}]]) if $p->{mypage} and $p->{mypage} !~ /^[A-Z][a-z]+(?:[A-Z][a-z]+)+$/; my %query; for (qw/mypage mycmd mymsg/) { $query{$_} = &main::code_convert (\$p->{$_}, $p->{charset} || 'shift_jis') if length $p->{$_}; } $p->{-result}->query_form (%query); } FormattingRule: @Category[list]: iwc--urireference @Name: iwwe--YukiWikiDBNS-base16-encode @Description: @@@: String encoded in base 16 encoding, with YukiWikiDBNS namespacing rule and suffixes. @@lang: en @Parameter: @@Name: charset @@Type: charset @@Default: "euc-jp" @@Description: @@@@: Charset in which string to be encoded before base 16 applied @@@lang: en @Parameter: @@Name: content @@Type: CDATA @@Default: #REQUIRED @@Description: @@@@: String to be encoded @@@lang: en @Parameter: @@Name: filesystem-namespace-delimiter @@Type: CDATA @@Default: "/" @@Description: @@@@: String with which namespace components to be delimited in result @@@lang: en @Parameter: @@Name: filesystem-namespace-suffix @@Type: CDATA @@Default: ".ns" @@Description: @@@@: String to be suffixed to namespace component in result @@@lang: en @Parameter: @@Name: wiki-namespace-delimiter @@Type: CDATA @@Default: "//" @@Description: @@@@: String by which namespace component in source ("content" parameter) delimited @@@lang: en @Post: my $c = &main::code_convert (\$p->{content}, $p->{charset} || 'euc-jp'); $c =~ s/(.)/sprintf '%02X', ord $1/ges; $p->{wiki_namespace_delimiter} ||= $o->{wiki}->{config}->{name}->{space} ->{separator}; $p->{wiki_namespace_delimiter} =~ s/(.)/sprintf '%02X', ord $1/ges; $p->{filesystem_namespace_delimiter} ||= '/'; $p->{filesystem_namespace_suffix} ||= '.ns'; $c =~ s{$p->{wiki_namespace_delimiter}} {$p->{filesystem_namespace_suffix}$p->{filesystem_namespace_delimiter}}g; $p->{-result} .= $c . ($p->{filesystem_file_suffix} || '.txt'); FormattingRule: @Category[list]: link-to-resource @Name: iwwe--wikiname @Description: @@@: Extracting WikiName from URI reference @@lang: en @Parameter: @@Name: charset @@Type: charset @@Default: (auto) @@Description: @@@: Charset in which WikiName written. @@lang: en @Formatting: if ($INTERWIKICORE->uri_has_feature (uri => $o->{link}->{dest}->{uri}, method => 'query')) { my $q = $o->{link}->{dest}->{uri}->query; my $page; my $charset; if ($q and index ($q, '=') > -1) { my %q = map {split /=/, $_, 2} split /[&;]/, $q; $page = $q{mypage}; $charset = lc ($q{_charset_} || $q{ie} || $p->{charset}) || $o->{wiki}->{config}->{charset}->{uri_param}; } elsif (defined $q and length $q) { $page = $q; $charset = lc $p->{charset} || $o->{wiki}->{config}->{charset}->{uri_query}; } if (defined $page) { $page =~ tr/+/ /; $page =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/pack 'C', hex $1/ge; $page = &main::code_convert (\$page, $charset); $p->{-parent}->append_text ($page); } }