/[pub]/suikawiki/script/misc/plugins/link/iw-wikiengine.wp2
Suika

Contents of /suikawiki/script/misc/plugins/link/iw-wikiengine.wp2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Wed Mar 10 06:57:25 2004 UTC (21 years, 4 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, release-3-0-0, HEAD
Branch point for: paragraph-200404, helowiki, helowiki-2005
Changes since 1.3: +43 -2 lines
Lots of formatting rule for referer listing added

1 wakaba 1.1 #?SuikaWikiConfig/2.0
2    
3     Plugin:
4     @Name: InterWikiForWikiEngine
5     @Description:
6     @@@:
7     InterWiki - External WikiEngine URI Reference Support
8     @@lang:en
9 wakaba 1.4 @License: %%Perl%%
10 wakaba 1.1 @Author:
11     @@Name:
12     @@@@: Wakaba
13     @@@lang:ja
14     @@@script:Latn
15     @@Mail[list]: w@suika.fam.cx
16 wakaba 1.4 @Date.RCS:
17     $Date: 2004/02/14 10:52:13 $
18 wakaba 1.3 @RequiredModule[list]:
19     main
20     URI
21 wakaba 1.1 @RequiredPlugin[list]: InterWikiCore
22     @Use:
23     require URI;
24     our $INTERWIKICORE;
25    
26     PluginConst:
27     @INTERWIKICORE:
28     {($INTERWIKICORE ||= SuikaWiki::Plugin->module_package ('InterWikiCore'))}
29    
30    
31     FormattingRule:
32     @Category[list]: iwc--urireference
33     @Name: suikawiki
34     @Description:
35     @@@:
36     SuikaWiki URI Reference.
37     @@lang:en
38     @Parameter:
39     @@Name: anchor-no
40     @@Type: integer
41     @@Default: (none)
42     @@Description:
43     @@@: Fragment anchor number
44     @@lang:en
45     @Parameter:
46     @@Name: fragment
47     @@Type:
48     URI:fragment
49     @@Default: (none)
50     @@Description:
51     @@@: Fragment identifier
52     @@lang:en
53     @Parameter:
54     @@Name: mode
55     @@Type: mode
56     @@Default: (none)
57     @@Description:
58     @@@: Mode name.
59     @@lang: en
60     @Parameter:
61     @@Name: page
62     @@Type: WikiName
63     @@Default: (none)
64     @@Description:
65     @@@: WikiPage
66     @@lang: en
67     @Parameter:
68     @@Name: up-to-date
69     @@Type: boolean
70     @@Default: "0"
71     @@Description:
72     @@@: Whether dummy "up to date" parameter should be appended
73     @@lang:en
74     @Parameter:
75     @@Name: version
76     @@Type: number
77     @@Default: (auto)
78     @@Description:
79     @@@: Version number of SuikaWiki interface. "2.0" or "2.9".
80     @@lang: en
81     @Parameter:
82     @@Name: wiki-uri
83     @@Type: URIReference
84     @@Default: (current)
85     @@Description:
86     @@@: Base wiki URI
87     @@lang: en
88     @Post:
89     if (not $p->{version} or $p->{version} >= 2.9) {
90     $p->{-result} = $o->{wiki}->uri_reference
91     (version => $p->{version}+0,
92     wiki_uri => $p->{base} ? URI->new ($p->{base})
93     : undef,
94 wakaba 1.2 page => $o->{wiki}->name ($p->{page}),
95 wakaba 1.1 mode => $p->{mode},
96     up_to_date => $p->{up_to_date},
97     # with_lm => $p->{with_lm},
98     anchor_no => $p->{anchor_no},
99     fragment => $p->{fragment});
100     } else { # SuikaWiki 2
101     $p->{-result} = URI->new ($p->{base});
102     if ($INTERWIKICORE->uri_has_feature
103     (uri => $p->{-result}, method => 'query_form')) {
104     if ($p->{page} and not $p->{mode} and not $p->{up_to_date}) {
105     $p->{-result}->query ($INTERWIKICORE->uri_escape_encode ($p->{page}, qr([^0-9A-Za-z_.-])));
106     } else {
107     my %query;
108     $query{mypage} = $p->{page} if $p->{page};
109     $query{mycmd} = $p->{mode} if $p->{mode};
110     $query{up_to_date} = time if $p->{up_to_date};
111     $p->{-result}->query_form (%query);
112     }
113     }
114     if ($p->{anchor_no}) {
115     $p->{-result}->fragment ('anchor-'.(0+$p->{anchor_no}));
116     } elsif ($p->{fragment}) {
117     $p->{-result}->fragment ($p->{fragment});
118     }
119     }
120    
121     FormattingRule:
122     @Category[list]: iwc--urireference
123     @Name: yukiwiki
124     @Description:
125     @@@:
126     YukiWiki URI Reference. This rule can be used to specify URI reference
127     to YukiWiki or derived works (such as WalWiki).
128     \
129     "version" parameter controls URI reference generating procedure.
130     \
131     In YukiWiki 1, non-alphabetical WikiName (BracketName)
132     automatically enclosed by "[[" and "]]".
133     \
134     In YukiWiki 2, only WikiName is used as URI query
135     when no other parameter required (ie. <http://wiki.example/?WikiName>).
136     @Parameter:
137     @@Name: charset
138     @@Type: charset
139     @@Default: (auto)
140     @@Description:
141     @@@:
142     Charset in which query parameters should be encoded.
143     \
144     In YukiWiki 1, it is defaulted to "shift_jis",
145     while otherwise defaulted to "euc-jp".
146     @Parameter:
147     @@Name: mycmd
148     @@Type:
149     YukiWiki:mycmd
150     @@Default: (none)
151     @@Description:
152     @@@: YukiWiki command
153     @@lang: en
154     @Parameter:
155     @@Name: mymsg
156     @@Type: CDATA
157     @@Default: (none)
158     @@Description:
159     @@@: YukiWiki "mymsg" parameter (unescaped)
160     @@lang: en
161     @Parameter:
162     @@Name: mypage
163     @@Type:
164     YukiWiki:WikiName
165     @@Default: (none)
166     @@Description:
167     @@@: WikiPage name
168     @@lang: en
169     @Parameter:
170     @@Name: version
171     @@Type: number
172     @@Default: (auto)
173     @@Description:
174     @@@: YukiWiki version number
175     @@lang: en
176     @Post:
177     $p->{-result} = URI->new ($p->{base});
178     return unless $INTERWIKICORE->uri_has_feature (uri => $p->{-result},
179     method => 'query_form');
180     if (not $p->{version} or $p->{version} >= 2.0) {
181     if ($p->{mypage} and not $p->{mycmd}) {
182     $p->{mypage} = &main::code_convert (\$p->{mypage},
183     $p->{charset} || 'euc-jp');
184     $p->{-result}->query ($INTERWIKICORE->uri_escape_encode
185     ($p->{mypage}, qr([^0-9A-Za-z_.-])));
186     } else {
187     my %query;
188     for (qw/mypage mycmd mymsg/) {
189     $query{$_} = &main::code_convert (\$p->{$_},
190     $p->{charset} || 'euc-jp')
191     if length $p->{$_};
192     }
193     $p->{-result}->query_form (%query);
194     }
195     } else { # YukiWiki 1
196     $p->{mypage} = qq([[$p->{mypage}]])
197     if $p->{mypage} and $p->{mypage} !~ /^[A-Z][a-z]+(?:[A-Z][a-z]+)+$/;
198     my %query;
199     for (qw/mypage mycmd mymsg/) {
200     $query{$_} = &main::code_convert (\$p->{$_},
201     $p->{charset} || 'shift_jis')
202     if length $p->{$_};
203     }
204     $p->{-result}->query_form (%query);
205     }
206 wakaba 1.3
207     FormattingRule:
208     @Category[list]: iwc--urireference
209     @Name: iwwe--YukiWikiDBNS-base16-encode
210     @Description:
211     @@@:
212     String encoded in base 16 encoding, with YukiWikiDBNS namespacing
213     rule and suffixes.
214     @@lang: en
215     @Parameter:
216     @@Name: charset
217     @@Type: charset
218     @@Default: "euc-jp"
219     @@Description:
220     @@@@: Charset in which string to be encoded before base 16 applied
221     @@@lang: en
222     @Parameter:
223     @@Name: content
224     @@Type: CDATA
225     @@Default: #REQUIRED
226     @@Description:
227     @@@@: String to be encoded
228     @@@lang: en
229     @Parameter:
230     @@Name: filesystem-namespace-delimiter
231     @@Type: CDATA
232     @@Default: "/"
233     @@Description:
234     @@@@: String with which namespace components to be delimited in result
235     @@@lang: en
236     @Parameter:
237     @@Name: filesystem-namespace-suffix
238     @@Type: CDATA
239     @@Default: ".ns"
240     @@Description:
241     @@@@: String to be suffixed to namespace component in result
242     @@@lang: en
243     @Parameter:
244     @@Name: wiki-namespace-delimiter
245     @@Type: CDATA
246     @@Default: "//"
247     @@Description:
248     @@@@:
249     String by which namespace component in source ("content" parameter)
250     delimited
251     @@@lang: en
252     @Post:
253     my $c = &main::code_convert (\$p->{content}, $p->{charset} || 'euc-jp');
254     $c =~ s/(.)/sprintf '%02X', ord $1/ges;
255     $p->{wiki_namespace_delimiter} ||= $o->{wiki}->{config}->{name}->{space}
256     ->{separator};
257     $p->{wiki_namespace_delimiter} =~ s/(.)/sprintf '%02X', ord $1/ges;
258     $p->{filesystem_namespace_delimiter} ||= '/';
259     $p->{filesystem_namespace_suffix} ||= '.ns';
260     $c =~ s{$p->{wiki_namespace_delimiter}}
261     {$p->{filesystem_namespace_suffix}$p->{filesystem_namespace_delimiter}}g;
262     $p->{-result} .= $c . ($p->{filesystem_file_suffix} || '.txt');
263 wakaba 1.4
264     FormattingRule:
265     @Category[list]: link-to-resource
266     @Name: iwwe--wikiname
267     @Description:
268     @@@: Extracting WikiName from URI reference
269     @@lang: en
270     @Parameter:
271     @@Name: charset
272     @@Type: charset
273     @@Default: (auto)
274     @@Description:
275     @@@: Charset in which WikiName written.
276     @@lang: en
277     @Formatting:
278     if ($INTERWIKICORE->uri_has_feature
279     (uri => $o->{link}->{dest}->{uri},
280     method => 'query')) {
281     my $q = $o->{link}->{dest}->{uri}->query;
282     my $page;
283     my $charset;
284     if ($q and index ($q, '=') > -1) {
285     my %q = map {split /=/, $_, 2} split /[&;]/, $q;
286     $page = $q{mypage};
287     $charset = lc ($q{_charset_} || $q{ie} || $p->{charset})
288     || $o->{wiki}->{config}->{charset}->{uri_param};
289     } elsif (defined $q and length $q) {
290     $page = $q;
291     $charset = lc $p->{charset}
292     || $o->{wiki}->{config}->{charset}->{uri_query};
293     }
294     if (defined $page) {
295     $page =~ tr/+/ /;
296     $page =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/pack 'C', hex $1/ge;
297     $page = &main::code_convert (\$page, $charset);
298     $p->{-parent}->append_text ($page);
299     }
300     }
301    
302    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24