/[pub]/suikawiki/script/lib/SuikaWiki/Plugin/WikiLinking.wp2
Suika

Contents of /suikawiki/script/lib/SuikaWiki/Plugin/WikiLinking.wp2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (hide annotations) (download)
Fri Aug 6 03:37:04 2004 UTC (21 years ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, HEAD
Branch point for: helowiki, helowiki-2005
Changes since 1.12: +40 -10 lines
InterWiki custom source-anchor label implemented

1 wakaba 1.1 #?SuikaWikiConfig/2.0
2    
3     Plugin:
4     @Name: WikiLinking
5     @Description:
6     @@@: Wiki hyperlinking support
7     @@lang:en
8 wakaba 1.7 @License: %%Perl%%
9 wakaba 1.1 @Author:
10     @@Name:
11     @@@@: Wakaba
12     @@@lang:ja
13     @@@script:Latn
14     @@Mail[list]: w@suika.fam.cx
15 wakaba 1.7 @Date.RCS:
16 wakaba 1.13 $Date: 2004/04/26 00:53:45 $
17 wakaba 1.2 @Use:
18     use Message::Util::Error;
19     our $NestLevel = 0;
20 wakaba 1.7 my $WIKIRESOURCE;
21     my $ERROR;
22 wakaba 1.11 my $LINK_TO_RESOURCE;
23 wakaba 1.13 @Namespace:
24     @@iw:
25     http://suika.fam.cx/~wakaba/archive/2004/8/6/sw-iw#
26 wakaba 1.1
27     PluginConst:
28     @NS_XHTML1:
29     http://www.w3.org/1999/xhtml
30     @NS_XHTML2:
31     http://www.w3.org/2002/06/xhtml2
32     @NS_XLINK:
33     http://www.w3.org/1999/xlink
34     @NS_HLINK:
35     http://www.w3.org/2002/06/hlink
36 wakaba 1.7 @ERROR:
37     {($ERROR ||= SuikaWiki::Plugin->module_package ('Error'))}
38 wakaba 1.11 @LINK_TO_RESOURCE:
39     {($LINK_TO_RESOURCE||=SuikaWiki::Plugin->formatter ('link_to_resource'))}
40 wakaba 1.7 @WIKIRESOURCE:
41     {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))}
42 wakaba 1.1
43     FormattingRule:
44     @Category[list]:
45     view
46     view-resource
47     form-input
48 wakaba 1.13 page-link
49     link-to-resource
50 wakaba 1.1 @Name: link-to-wikipage
51     @Description:
52     @@@:
53     Creating "from" anchor field of a link whose "to" is a WikiPage
54     @@lang: en
55     @Parameter:
56     @@Name: base-page
57     @@Type: WikiName
58     @@Default: (current)
59     @@Description:
60     @@@@:Base WikiName (Relative WikiName is resolved with)
61     @@@lang:en
62     @Parameter:
63     @@Name: hreflang
64     @@Type:
65     HTML4:LanguageCode
66     @@Default:(none)
67     @@Description:
68     @@@@:(Human) language the linked WikiPage written in
69     @@@lang:en
70     @Parameter:
71     @@Name: hreftype
72     @@Type:
73     HTML4:ContentType
74     @@Default:(none)
75     @@Description:
76     @@@@:Media type the linked WikiPage provided with
77     @@@lang:en
78     @Parameter:
79     @@Name:label
80     @@Type:CDATA
81     @@Default:(auto)
82     @@Description:
83     @@@@:Source anchor label
84     @@@lang:en
85     @Parameter:
86     @@Name: mode
87     @@Type: WikiMode
88     @@Default:(default)
89     @@Description:
90     @@@@:Mode of the Wiki linked to
91     @@@lang:en
92     @Parameter:
93     @@Name: page
94     @@Type: WikiName
95     @@Default: (current)
96     @@Description:
97     @@@@:WikiPage linked to
98     @@@lang:en
99     @Parameter:
100     @@Name: page-anchor-name
101     @@Type:
102     XML:ID
103     @@Default: (none)
104     @@Description:
105     @@@@:Identifier in the WikiPage linked to
106     @@@lang:en
107     @Parameter:
108     @@Name: page-anchor-no
109     @@Type:
110     SGML:NUMBER
111     @@Default: (none)
112     @@Description:
113     @@@@:Numeral anchor index in the WikiPage linked to
114     @@@lang:en
115     @Parameter:
116     @@Name: page-title
117     @@Type:CDATA
118     @@Default:(auto)
119     @@Description:
120     @@@@:Title of the WikiPage linked to
121     @@@lang:en
122     @Parameter:
123     @@Name: rel
124     @@Type:
125     HTML4:LinkTypes
126     @@Default:(none)
127     @@Description:
128     @@@@:Link relationships
129     @@@lang:en
130     @Parameter:
131     @@Name: rev
132     @@Type:
133     HTML4:LinkTypes
134     @@Default:(none)
135     @@Description:
136     @@@@:Link relationship (reverse)
137     @@@lang:en
138     @Parameter:
139     @@Name: up-to-date
140     @@Type: boolean
141     @@Default: "0"
142     @@Description:
143     @@@@:Appends random "up-to-date" parameter to the URI reference
144     @@@lang:en
145     @Parameter:
146     @@Name: with-lm
147     @@Type: boolean
148     @@Default:"0"
149     @@Description:
150     @@@@:Appends "last-modified" parameter to the URI reference
151     @@@lang:en
152     @Formatting:
153     __ATTRNODE:%page_title__;
154     __ATTRTEXT:%class__;
155 wakaba 1.2 __ATTRTEXT:%label__;
156 wakaba 1.1 __ATTRTEXT:%page__;__ATTRTEXT:%base_page__;__ATTRTEXT:%page_anchor_no__;
157     __ATTRTEXT:%with_lm__;__ATTRTEXT:%up_to_date__;
158     __ATTRTEXT:%page_anchor_name__;
159     __ATTRTEXT:%hreflang__;__ATTRTEXT:%hreftype__;
160     __ATTRTEXT:%mode__;
161     __ATTRTEXT:%rel__;__ATTRTEXT:%rev__;
162     __FUNCPACK__->to_wikipage_in_html ({
163 wakaba 1.6 label => $p->{label},
164 wakaba 1.1 } => {
165 wakaba 1.6 base => $o->{wiki}->name ($p->{base_page} ||
166     $o->{wiki}->{var}->{page}),
167     page_name_relative => $o->{wiki}->name ($p->{page} ||
168     $o->{wiki}->{var}->{page}),
169     page_anchor_no => $p->{page_anchor_no},
170 wakaba 1.1 page_anchor_name => $p->{page_anchor_name},
171 wakaba 1.6 page_title => $p->{page_title},
172     wiki_mode => $p->{mode},
173     _with_lm => $p->{with_lm},
174     _up_to_date => $p->{up_to_date},
175     -hreflang => $p->{hreflang},
176     -hreftype => $p->{type},
177 wakaba 1.1 }, {
178 wakaba 1.6 o => $o,
179     parent => $p->{-parent},
180     -rel => $p->{rel},
181     -rev => $p->{rev},
182 wakaba 1.1 });
183    
184     FormattingRule:
185 wakaba 1.3 @Category[list]:
186     view
187     view-resource
188     form-input
189 wakaba 1.13 page-link
190     link-to-resource
191 wakaba 1.3 @Name: link-to-resource
192     @Description:
193     @@@:
194     Creating source anchor field of a link whose destination is a resource
195     @@lang: en
196     @Parameter
197     @@Name: hreflang
198     @@Type:
199     HTML4:LanguageCode
200     @@Default:(none)
201     @@Description:
202     @@@@:(Human) language the linked WikiPage written in (advisory)
203     @@@lang:en
204     @Parameter:
205     @@Name: hreftype
206     @@Type:
207     HTML4:ContentType
208     @@Default:(none)
209     @@Description:
210     @@@@:Media type the linked WikiPage provided with (advisory)
211     @@@lang:en
212     @Parameter:
213     @@Name:label
214     @@Type:CDATA
215     @@Default:(auto)
216     @@Description:
217     @@@@:Source anchor label
218     @@@lang:en
219     @Parameter:
220     @@Name: rel
221     @@Type:
222     HTML4:LinkTypes
223     @@Default:(none)
224     @@Description:
225     @@@@:Link relationships
226     @@@lang:en
227     @Parameter:
228     @@Name: rev
229     @@Type:
230     HTML4:LinkTypes
231     @@Default:(none)
232     @@Description:
233     @@@@:Link relationship (reverse)
234     @@@lang:en
235     @Parameter:
236     @@Name: uri
237     @@Type:
238     HTML4:URI
239     @@Default:(required)
240     @@Description:
241     @@@@:URI reference of the resoruce referred to
242     @@@lang:en
243     @Formatting:
244     __ATTRTEXT:%class__;
245     __ATTRTEXT:%label__;
246     __ATTRTEXT:%hreflang__;__ATTRTEXT:%hreftype__;
247     __ATTRTEXT:%rel__;__ATTRTEXT:%rev__;
248     __ATTRTEXT:%uri__;
249 wakaba 1.7 my $src = {
250 wakaba 1.6 label => $p->{label},
251 wakaba 1.7 };
252     my $dest = {
253 wakaba 1.3 -hreflang => $p->{hreflang},
254     -hreftype => $p->{type},
255 wakaba 1.7 };
256     my $opt = {
257 wakaba 1.3 o => $o,
258     parent => $p->{-parent},
259     -rel => $p->{rel},
260     -rev => $p->{rev},
261 wakaba 1.7 };
262     if (length $p->{uri}) {
263     $dest->{uri} = $p->{uri};
264     } else {
265     __ATTRTEXT:%iw_name__;
266     if ($p->{iw_name}) {
267     __ATTRTEXT:%iw_parameter__;
268     $dest->{resource_scheme} = 'IW';
269     $dest->{resource_parameter} = undef;
270     $dest->{-iw__name} = $p->{iw_name};
271     $dest->{-iw__parameter} = $p->{iw_parameter};
272     __FUNCPACK__->to_resource_in_html ($src => $dest, $opt);
273     return;
274     } else {
275     $dest->{uri} = q<>;
276     }
277     }
278     __FUNCPACK__->to_resource_by_uri_in_html ($src => $dest, $opt);
279 wakaba 1.3
280     FormattingRule:
281     @Category[list]:
282     page-link
283     link-to-resource
284 wakaba 1.1 @Name: link-to-it
285     @Description:
286     @@@:
287     Source anchor
288     @@lang: en
289     @Parameter:
290     @@Name: class
291     @@Type:
292     HTML4:class
293     @@Default: (none)
294     @@Description:
295     @@@@: Class names
296     @@@lang:en
297     @Parameter:
298     @@Name: description
299     @@Type: CDATA
300     @@Default: (none)
301     @@Description:
302     @@@@: Description of the anchor or link
303     @@@lang:en
304     @Parameter:
305     @@Name: label
306     @@Type: CDATA
307     @@Default: ""
308     @@Description:
309     @@@@: Source anchor label (content)
310     @@@lang:en
311     @Formatting:
312     __ATTRTEXT:%class__;
313     my $A = $p->{-parent}->append_new_node (type => '#element',
314     namespace_uri => $NS_XHTML1,
315     local_name => 'a');
316     $A->set_attribute (href => $o->{link}->{dest}->{uri});
317    
318 wakaba 1.2 __ATTRNODE:%label->{$A}__;
319 wakaba 1.7 if (length $p->{description}) {
320     __ATTRTEXT:%description__;
321     } else {
322     if ($f->{-category_name} eq 'page_link') {
323     $p->{description} = $WIKIRESOURCE->get
324     (name => 'WikiLinking:LinkToIt:ToWikiPage:Description',
325     o => $o, wiki => $o->{wiki},
326     formatter_context => $f->{-category_name},
327     formatter_option => {param => $o})->inner_text;
328     } else {
329     $p->{description} = $WIKIRESOURCE->get
330     (name => 'WikiLinking:LinkToIt:ToResource:Description',
331     o => $o, wiki => $o->{wiki},
332     formatter_context => $f->{-category_name},
333     formatter_option => {param => $o})->inner_text;
334     }
335     }
336 wakaba 1.1 $A->set_attribute (title => $p->{description}) if $p->{description};
337     my @class = split /\s+/, $p->{class};
338 wakaba 1.3 if ($o->{wiki}->uri_is_part_of_wiki ($o->{link}->{dest}->{absolute_uri} or
339     $o->{link}->{dest}->{uri})) {
340 wakaba 1.1 push @class, 'wiki'; ## Link to the page within the Wiki
341     }
342     $A->set_attribute (class => join ' ', @class) if @class;
343    
344     $A->set_attribute (rel => $o->{link}->{option}->{-rel})
345     if $o->{link}->{option}->{-rel};
346     $A->set_attribute (rev => $o->{link}->{option}->{-rev})
347     if $o->{link}->{option}->{-rev};
348    
349     $A->set_attribute (hreflang => $o->{link}->{dest}->{-lang})
350     if $o->{link}->{dest}->{-lang};
351     $A->set_attribute (type => $o->{link}->{dest}->{-type})
352     if $o->{link}->{dest}->{-type};
353    
354     FormattingRule:
355 wakaba 1.3 @Category[list]:
356     page-link
357     link-to-resource
358     @Name: uri-reference
359     @Description:
360     @@@: URI Reference of destination anchor
361     @@lang:en
362     @Formatting:
363     $p->{-parent}->append_text ($o->{link}->{dest}->{absolute_uri} or
364     $o->{link}->{dest}->{uri});
365    
366     FormattingRule:
367     @Category[list]: link-to-resource
368     @Name: link-resource-scheme
369     @Description:
370     @@@: Linking scheme (defined as ReferenceScheme in SuikaWiki/0.9 syntax)
371     @@lang:en
372     @Formatting:
373     $p->{-parent}->append_text ($o->{link}->{dest}->{resource_scheme});
374    
375     FormattingRule:
376     @Category[list]: link-to-resource
377     @Name: link-resource-parameters
378     @Description:
379     @@@: Linking parameters (defined as ReferenceParameter in SuikaWiki/0.9 syntax)
380     @@lang:en
381     @Formatting:
382     $p->{-parent}->append_text ($o->{link}->{dest}->{resource_parameter});
383    
384     FormattingRule:
385 wakaba 1.1 @Category[list]: page-link
386     @Name: link-base-page-name
387     @Description:
388     @@@: Base WikiPage name
389     @@lang: en
390     @Formatting:
391 wakaba 1.6 $p->{-parent}->append_text
392     ($o->{link}->{dest}->{base}->stringify (wiki => $o->{wiki}));
393 wakaba 1.1
394     FormattingRule:
395     @Category[list]: page-link
396     @Name: link-dest-anchor-no
397     @Description:
398     @@@: Anchor number in the WikiPage linked to, if specified
399     @@lang: en
400     @Formatting:
401     $p->{-parent}->append_text ($o->{link}->{dest}->{page_anchor_no});
402    
403     FormattingRule:
404 wakaba 1.3 @Category[list]: link-to-resource
405     @Name: if-link-resource-scheme
406     @Description:
407     @@@: If or if not resource pointing scheme matches to
408     @@lang:en
409     @Parameter:
410     @@Name: name
411     @@Type:
412     SW09:name
413     @@Default:(required)
414     @@Description:
415     @@@@: Scheme name
416     @@@lang:en
417     @Formatting:
418     __ATTRTEXT:%name__;
419     my $rule;
420     if ($o->{link}->{dest}->{resource_scheme} eq $p->{name}) {
421     $rule = __ATTRTEXT:%true__;
422     } else {
423     $rule = __ATTRTEXT:%false__;
424     }
425     SuikaWiki::Plugin->formatter ($f->{-category_name})
426     ->replace ($rule, param => $o, -parent => $p->{-parent});
427    
428     FormattingRule:
429     @Category[list]: link-to-resource
430     @Name: select-link-resource-scheme
431     @Description:
432     @@@: Selecting template by resource pointing scheme matches to
433     @@lang:en
434     @Parameter:
435     @@Name: SCHEMENAME
436     @@Type:
437     template
438     @@Default:(none)
439     @@Description:
440     @@@@: Template used when scheme name is SCHEMENAME
441     @@@lang:en
442     @Parameter:
443     @@Name: otherwise
444     @@Type:
445     template
446     @@Default:(none)
447     @@Description:
448     @@@@: Template used when no SCHEMENAME parameter matches
449     @@@lang:en
450     @Formatting:
451     my $rule;
452     if (defined $p->{$o->{link}->{dest}->{resource_scheme}}) {
453     $rule = __ATTRTEXT:%{$o->{link}->{dest}->{resource_scheme}}__;
454     } else {
455     $rule = __ATTRTEXT:%otherwise__;
456     }
457 wakaba 1.13 try {
458     $f->replace ($rule, param => $o, -parent => $p->{-parent});
459     } catch Message::Util::Formatter::error with {
460     my $err = shift;
461     if ($err->{-object}->{-category_name} eq $f->{-category_name}) {
462     my $wiki = $err->{option}->{param}->{wiki};
463     __FUNCPACK{Error}__->reporting_formatting_template_error
464     ($err, $wiki,
465     template => $rule);
466     } else {
467     $err->throw;
468     }
469     };
470 wakaba 1.3
471     FormattingRule:
472 wakaba 1.1 @Category[list]: page-link
473     @Name: if-linked-wikipage-exist
474     @Description:
475     @@@: If or if not linked WikiPage exists, then
476     @@lang: en
477     @Formatting:
478 wakaba 1.2 my $page = $o->{link}->{dest}->{page_name};
479 wakaba 1.1 my $rule;
480 wakaba 1.8 my $exists = 0;
481     if ($o->{wiki}->{db}) {
482     try {
483     $exists = $o->{wiki}->{db}->exist (content => $page);
484     } catch SuikaWiki::DB::Util::Error with {
485     my $err = shift;
486     $err->throw if $err->{-type} eq 'ERROR_REPORTED';
487     };
488     }else {CORE::die Carp::longmess}
489 wakaba 1.5 if ($exists) {
490 wakaba 1.1 $rule = __ATTRTEXT:%true__;
491     } else {
492     $rule = __ATTRTEXT:%false__;
493     }
494 wakaba 1.5 SuikaWiki::Plugin->formatter ('page_link')
495 wakaba 1.1 ->replace ($rule, param => $o, -parent => $p->{-parent});
496    
497     FormattingRule:
498     @Category[list]: page-link
499     @Name: if-link-has-dest-anchor-no
500     @Description:
501     @@@: If or if the link has destination numeral anchor
502     @@lang: en
503     @Formatting:
504     my $rule;
505     if ($o->{link}->{dest}->{page_anchor_no}) {
506     $rule = __ATTRTEXT:%true__;
507     } else {
508     $rule = __ATTRTEXT:%false__;
509     }
510     SuikaWiki::Plugin->formatter ('page-link')
511     ->replace ($rule, param => $o, -parent => $p->{-parent});
512    
513     FormattingRule:
514 wakaba 1.3 @Category[list]:
515     page-link
516     link-to-resource
517 wakaba 1.1 @Name:-bare-text
518     @Formatting:
519     $p->{-parent}->append_text ($p->{-bare_text});
520    
521     Function:
522 wakaba 1.3 @Name: to_resource_in_html
523     @Description:
524     @@@Make a link to the resource (outputted in HTML)
525     @@lang:en
526     @Main:
527     my (undef, $src => $dest, $opt) = @_;
528 wakaba 1.13 local $opt->{o}->{iwc__param}; ## For InterWikiCore module
529 wakaba 1.3 if ($dest->{resource_scheme} eq 'URI' or
530     $dest->{resource_scheme} eq 'URL') {
531 wakaba 1.7 $dest->{uri} = URI->new ($dest->{resource_parameter});
532 wakaba 1.3 } elsif ($dest->{resource_scheme} eq 'IW') {
533 wakaba 1.13 $dest->{uri} = __FUNCPACK{InterWikiCore}__
534 wakaba 1.3 ->interwikireference_to_urireference
535 wakaba 1.5 (packed => $dest->{resource_parameter},
536 wakaba 1.7 name => $dest->{-iw__name},
537     param => $dest->{-iw__parameter},
538 wakaba 1.5 o => $opt->{o},
539 wakaba 1.7 wiki => $opt->{o}->{wiki})
540     || URI->new (q<#err--error>);
541 wakaba 1.13 $src->{<Q:iw:label>} = __FUNCPACK{InterWikiCore}__
542     ->interwikireference_to_sourcelabel
543     (packed => $dest->{resource_parameter},
544     name => $dest->{-iw__name},
545     param => $dest->{-iw__parameter},
546     o => $opt->{o},
547     wiki => $opt->{o}->{wiki});
548 wakaba 1.3 } elsif ($dest->{resource_scheme} eq 'MAIL') {
549     $dest->{uri} = 'mailto:'.$dest->{resource_parameter};
550     } else {
551 wakaba 1.7 $ERROR->report_error_simple
552     ($opt->{o}->{wiki},
553     $WIKIRESOURCE->get_op ('Error:Condition', $opt->{o})
554     => $WIKIRESOURCE->get_op
555     ('WikiLinking:ResourceScheme:Unknown:Description',
556     $opt->{o}),
557     $WIKIRESOURCE->get_op ('WikiLinking:ResourceScheme', $opt->{o})
558     => $dest->{resource_scheme},
559     $WIKIRESOURCE->get_op ('WikiLinking:ResourceParameter',
560     $opt->{o})
561     => $dest->{resource_parameter},
562     );
563     $dest->{uri} = URI->new (q<#err--error>);
564 wakaba 1.3 }
565     __FUNCPACK__->to_resource_by_uri_in_html ($src => $dest, $opt);
566    
567     Function:
568     @Name: to_resource_by_uri_in_html
569     @Description:
570     @@@:Make a link to the resource by URI reference (outputted in HTML)
571     @@lang:en
572     @Main:
573     my (undef, $src => $dest, $opt) = @_;
574     local $NestLevel = $NestLevel + 1;
575     if (100 < $NestLevel) {
576     $opt->{parent}->append_new_node (type => '#comment',
577     value => $src->{label});
578 wakaba 1.7 $ERROR->report_error_simple
579     ($opt->{o}->{wiki},
580     $WIKIRESOURCE->get_op ('Error:Condition', $opt->{o})
581     => $WIKIRESOURCE->get_op
582     ('WikiLinking:Error:TooDeep', $opt->{o}),
583     $WIKIRESOURCE->get_op ('Error:Formatter:Template', $opt->{o})
584     => $src->{label},
585     -trace => 1,
586     );
587 wakaba 1.3 return;
588     }
589 wakaba 1.11
590 wakaba 1.3 local $opt->{o}->{link} = {
591     src => $src,
592     dest => $dest,
593     option => $opt,
594     };
595 wakaba 1.7 $dest->{uri} = ref $dest->{uri} ? $dest->{uri}->canonical
596     : URI->new ($dest->{uri})->canonical;
597 wakaba 1.9 $src->{label} ||= $WIKIRESOURCE->get_text
598     (name => 'Link:toResource:SourceLabel',
599 wakaba 1.4 param => $opt->{o},
600     wiki => $opt->{o}->{wiki});
601 wakaba 1.3 try {
602 wakaba 1.11 $LINK_TO_RESOURCE
603 wakaba 1.3 ->replace ($src->{label}, param => $opt->{o}, -parent => $opt->{parent});
604     } catch Message::Util::Formatter::error with {
605     my $err = shift;
606 wakaba 1.5 if ($err->{-object}->{-category_name} eq 'link_to_resource') {
607     my $wiki = $err->{option}->{param}->{wiki};
608 wakaba 1.13 __FUNCPACK{Error}__->reporting_formatting_template_error
609 wakaba 1.5 ($err, $wiki,
610     template => $src->{label});
611 wakaba 1.3 undef;
612     } else {
613     $err->throw;
614     }
615     };
616    
617     Function:
618 wakaba 1.1 @Name: to_wikipage_in_html
619     @Description:
620 wakaba 1.3 @@@:Make a link to the WikiPage (outputed in HTML)
621 wakaba 1.1 @@lang:en
622     @Main:
623     my (undef, $src => $dest, $opt) = @_;
624 wakaba 1.2 local $NestLevel = $NestLevel + 1;
625     if (100 < $NestLevel) {
626     $opt->{parent}->append_new_node (type => '#comment',
627     value => $src->{label});
628 wakaba 1.13 __FUNCPACK{Error}__->report_error_simple
629 wakaba 1.7 ($opt->{o}->{wiki},
630 wakaba 1.13 __FUNCPACK{WikiResource}__
631     ->get_op ('Error:Condition', $opt->{o})
632     => __FUNCPACK{WikiResource}__->get_op
633 wakaba 1.7 ('WikiLinking:Error:TooDeep', $opt->{o}),
634 wakaba 1.13 __FUNCPACK{WikiResource}__
635     ->get_op ('Error:Formatter:Template', $opt->{o})
636 wakaba 1.7 => $src->{label},
637     -trace => 1,
638     );
639 wakaba 1.2 return;
640     }
641 wakaba 1.12 $dest->{page_name} ||= $dest->{page_name_relative}->absolute
642 wakaba 1.6 (base => $dest->{base}, wiki => $opt->{o}->{wiki});
643 wakaba 1.3 ($dest->{uri}, $dest->{absolute_uri})
644     = $opt->{o}->{wiki}->uri_reference
645 wakaba 1.6 (page => $dest->{page_name},
646 wakaba 1.3 mode => $dest->{wiki_mode},
647     anchor_no => $dest->{page_anchor_no},
648     up_to_date => $dest->{_up_to_date},
649     with_lm => $dest->{_with_lm},
650 wakaba 1.11 param => $dest->{param} || {},
651 wakaba 1.3 fragment => $dest->{page_anchor_name},
652 wakaba 1.6 base => $dest->{-use_absolute_uri} ? undef:
653     ($src->{base_uri} || 1));
654    
655 wakaba 1.1 local $opt->{o}->{link} = {
656     src => $src,
657     dest => $dest,
658     option => $opt,
659     };
660 wakaba 1.4 $src->{label} ||= SuikaWiki::Plugin->module_package ('WikiResource')
661     ->get_text (name => 'Link:toWikiPage:SourceLabel',
662     param => $opt->{o},
663     wiki => $opt->{o}->{wiki});
664 wakaba 1.2 try {
665     SuikaWiki::Plugin->formatter ('page_link')
666     ->replace ($src->{label}, param => $opt->{o}, -parent => $opt->{parent});
667     } catch Message::Util::Formatter::error with {
668     my $err = shift;
669 wakaba 1.5 if ($err->{-object}->{-category_name} eq 'page_link') {
670     my $wiki = $err->{option}->{param}->{wiki};
671 wakaba 1.7 SuikaWiki::Plugin->module_package ('Error')
672 wakaba 1.5 ->reporting_formatting_template_error
673     ($err, $wiki,
674     template => $src->{label});
675 wakaba 1.2 undef;
676     } else {
677     $err->throw;
678     }
679     };
680 wakaba 1.1
681 wakaba 1.3 PluginCategory:
682     @Name: page-link
683     @Description:
684     @@@: Source anchor label of link whose destination is a WikiPage
685     @@lang:en
686    
687     PluginCategory:
688     @Name: link-to-resource
689     @Description:
690     @@@: Source anchor label of link whose destination is a resource
691     @@lang:en
692    
693 wakaba 1.2 Resource:
694 wakaba 1.3 @Link:toResource:SourceLabel:
695     @@@:
696     %select-link-resource-scheme (
697     URI => {<%link-to-it(
698     label => {%uri-reference;}p,
699     );>},
700 wakaba 1.13 IW => {%iw--source-label (default => {<%link-to-it (
701     label => {%link-resource-scheme;:%link-resource-parameters;}p,
702     );});},
703 wakaba 1.3 MAIL => {<%link-to-it(
704     label => {%link-resource-parameters;}p,
705     description
706     => {%res (name=>{Link:MailAddress=});<%link-resource-parameters;>}p,
707     );>},
708     otherwise => {<%link-to-it(
709     label => {%link-resource-scheme;:%link-resource-parameters;}p,
710     );>},
711     );
712 wakaba 1.10 @Link:toWikiPage:NotExist:Mark:
713     @@@: ?
714 wakaba 1.2 @Link:toWikiPage:SourceLabel:
715     @@@:
716     %link-to-it(
717     label=>{%page-title (relative);%if-linked-wikipage-exist(
718     true=>{%if-link-has-dest-anchor-no(true=>{>>%link-dest-anchor-no;});},
719     false=>{%res(name=>{Link:toWikiPage:NotExist:Mark});}
720     );}p,
721     class=>{%if-linked-wikipage-exist(false=>{not-exist});}p,
722     );
723 wakaba 1.3 @Link:MailAddress=:
724     @@@:
725     Internet Mail Address:
726     @@lang:en
727     @Link:URIReference=:
728     @@@:
729     URI Reference:
730     @@lang:en
731 wakaba 1.7 @WikiLinking:Error:TooDeep:
732     @@@:
733     Link nesting too deep.
734     @@lang: en
735     @WikiLinking:LinkToIt:ToResource:Description:
736     %res (name=>{Link:URIReference=});<%uri-reference;>
737     @WikiLinking:LinkToIt:ToWikiPage:Description:
738     %page-name(absolute);; %if-linked-wikipage-exist(
739     true=>{%page-headline;},
740     false=>{(%res(name=>{Link:toWikiPage:NotExist:Description});)},
741     );
742     @WikiLinking:ResourceParameter:
743     @@@: Resource identification parameter
744     @@lang: en
745     @WikiLinking:ResourceScheme:
746     @@@: Resource identification scheme
747     @@lang: en
748     @WikiLinking:ResourceScheme:Unknown:Description:
749     @@@:
750     Unknown resource identification scheme specified.
751     @@lang: en
752    
753    
754    
755    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24  
Google Analytics is used in this page; Cookies are used. 忍者AdMax is used in this page; Cookies are used. Privacy policy.