/[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.12 - (hide annotations) (download)
Mon Apr 26 00:53:45 2004 UTC (22 years, 2 months ago) by wakaba
Branch: MAIN
CVS Tags: release-3-0-0
Branch point for: paragraph-200404
Changes since 1.11: +2 -2 lines
+2004-04-26  Wakaba  <wakaba@suika.fam.cx>
+
+       * WikiLinking.wp2 (Function[to_wikipage_in_html]): Don't require
+       'page_name_relative' if 'page_name' is provided.

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24