/[pub]/suikawiki/script/misc/plugins/referer.wp2
Suika

Contents of /suikawiki/script/misc/plugins/referer.wp2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Sat Mar 13 12:29:21 2004 UTC (22 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.5: +2 -2 lines
(FormattingRule[form-line]): New

1 wakaba 1.1 #?SuikaWikiConfig/2.0
2    
3     Plugin:
4     @Name: Referer
5     @Description:
6     @@@: Backward hyperlinking
7     @@lang:en
8     @License: %%Perl%%
9     @Author:
10     @@Name:
11     @@@@: Wakaba
12     @@@lang:ja
13     @@@script:Latn
14     @@Mail[list]: [email protected]
15     @Date.RCS:
16 wakaba 1.6 $Date: 2004/03/13 03:39:35 $
17 wakaba 1.1 @RequiredPlugin[list]:
18     InterWikiCore
19     WikiStructure
20     WikiLinking
21     @RequiredModule[list]:
22     URI
23     @Use:
24     use Message::Util::Error;
25     require URI;
26     my $INTERWIKICORE;
27     my $WIKIRESOURCE;
28     my $WIKILINKING;
29    
30     PluginConst:
31     @NS_XHTML1:
32     http://www.w3.org/1999/xhtml
33     @INTERWIKICORE:
34     {($INTERWIKICORE ||= SuikaWiki::Plugin->module_package ('InterWikiCore'))}
35     @WIKIRESOURCE:
36     {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))}
37     @WIKILINKING:
38     {($WIKILINKING ||= SuikaWiki::Plugin->module_package ('WikiLinking'))}
39    
40     FormattingRule:
41     @Category[list]:
42     view
43     view-resource
44     form-input
45     @Name: referer-list
46     @Parameter:
47     @@Name: page
48     @@Type: WikiName
49     @@Default: (auto)
50     @@Description:
51     @@@: WikiPage name
52     @@lang: en
53     @Formatting:
54     __ATTRTEXT:%page__;
55     my @list;
56     try {
57     @list = map {[split /\x09/, $_, 2]}
58     split /\x0A/,
59     $o->{wiki}->{db}->get ('referer',
60     $o->{wiki}->name ($p->{page} ||
61     $o->{wiki}->{var}->{page}));
62     } catch SuikaWiki::DB::Util::Error with {
63     #
64     };
65 wakaba 1.6
66 wakaba 1.1 if (@list) {
67     my $list = $p->{-parent}->append_new_node
68     (type => '#element',
69     namespace_uri => $NS_XHTML1,
70     local_name => 'ol');
71 wakaba 1.2 my $default_label = $WIKIRESOURCE->get
72     (name => 'Referer:URIReference2Label',
73     o => $o, wiki => $o->{wiki});
74     my $li_label = $WIKIRESOURCE->get
75     (name => 'Referer:RefererList:Label',
76     o => $o, wiki => $o->{wiki});
77 wakaba 1.4 my $i = 0;
78     my $j = 0;
79 wakaba 1.2 for my $item (sort {$b->[1] <=> $a->[1] or $a->[0] cmp $b->[0]} @list) {
80 wakaba 1.4 last if $j++ == 512;
81 wakaba 1.2 local $o->{iwc__param}->{uri_reference} = URI->new ($item->[0]);
82     my $label;
83     try {
84 wakaba 1.4 $label = $o->{wiki}->{db}->get (ref__item_template => [$item->[0]])
85     or do {
86 wakaba 1.5 if ($i > 50) { ## avoid browser timeout
87 wakaba 1.4 $label = $default_label;
88