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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by wakaba, Wed Mar 10 06:57:25 2004 UTC revision 1.5 by wakaba, Sat Mar 13 03:39:35 2004 UTC
# Line 68  FormattingRule: Line 68  FormattingRule:
68                       (type => '#element',                       (type => '#element',
69                        namespace_uri => $NS_XHTML1,                        namespace_uri => $NS_XHTML1,
70                        local_name => 'ol');                        local_name => 'ol');
71        for (sort {$b->[1] <=> $a->[1] or $a->[0] cmp $b->[0]} @list) {        my $default_label = $WIKIRESOURCE->get
         local $o->{iwc__param}->{uri_reference} = URI->new ($_->[0]);  
         my $site = $INTERWIKICORE->get_site_entry_by_uri_reference_match  
                      (o => $o,  
                       page => $o->{wiki}->{config}->{page}->{InterWikiName});  
         $WIKILINKING->to_resource_by_uri_in_html ({  
           label => $WIKIRESOURCE->get  
                       (name => 'Referer:RefererList:Label',  
                        o => $o, wiki => $o->{wiki}),  
           ref__label => (($site ?  
                            $site->get_attribute_value ('URIReference2Label'):'')  
                         || $WIKIRESOURCE->get  
72                               (name => 'Referer:URIReference2Label',                               (name => 'Referer:URIReference2Label',
73                                o => $o, wiki => $o->{wiki})),                                o => $o, wiki => $o->{wiki});
74          my $li_label = $WIKIRESOURCE->get
75                                (name => 'Referer:RefererList:Label',
76                                 o => $o, wiki => $o->{wiki});
77          my $i = 0;
78          my $j = 0;
79          for my $item (sort {$b->[1] <=> $a->[1] or $a->[0] cmp $b->[0]} @list) {
80            last if $j++ == 512;
81            local $o->{iwc__param}->{uri_reference} = URI->new ($item->[0]);
82            my $label;
83            try {
84              $label = $o->{wiki}->{db}->get (ref__item_template => [$item->[0]])
85                or do {
86                  if ($i > 50) { ## avoid browser timeout
87                    $label = $default_label;
88                  } else {
89                    $i++;
90                    my $site = $INTERWIKICORE->get_site_entry_by_uri_reference_match
91                             (o => $o,
92                              page => $o->{wiki}->{config}->{page}->{InterWikiName});
93                    $label = $site ? $site->get_attribute_value
94                                       ('URIReference2Label') || $default_label
95                                   : $default_label;
96                    $o->{wiki}->{db}->set (ref__item_template => [$item->[0]]
97                                                              => $label);
98                  }
99                };
100            } catch SuikaWiki::DB::Util::Error with {};
101            $WIKILINKING->to_resource_by_uri_in_html ({
102              label => $li_label,
103              ref__label => $label,
104          } => {          } => {
105            uri => $o->{iwc__param}->{uri_reference} = URI->new ($_->[0]),            uri => $o->{iwc__param}->{uri_reference},
106          }, {          }, {
107            o => $o,            o => $o,
108            parent => $list->append_new_node            parent => $list->append_new_node
109                       (type => '#element',                       (type => '#element',
110                        namespace_uri => $NS_XHTML1,                        namespace_uri => $NS_XHTML1,
111                        local_name => 'li'),                        local_name => 'li'),
112            ref__weight => $_->[1],            ref__weight => $item->[1],
113          });          });
114        }        }
115      }      }
# Line 100  Function: Line 119  Function:
119    @Main:    @Main:
120      my (undef, %opt) = @_;      my (undef, %opt) = @_;
121      return unless $opt{wiki}->{db};      return unless $opt{wiki}->{db};
122        return unless $opt{uri};
123      $opt{page} ||= $opt{wiki}->{var}->{page};      $opt{page} ||= $opt{wiki}->{var}->{page};
124      my $o = $opt{o} || {wiki => $opt{wiki}};      my $o = $opt{o} || {wiki => $opt{wiki}};
125            
# Line 160  FormattingRule: Line 180  FormattingRule:
180  FormattingRule:  FormattingRule:
181    @Category[list]: link-to-resource    @Category[list]: link-to-resource
182    @Name: ref--referer-item-label    @Name: ref--referer-item-label
183      @Description:
184        @@@:
185          Label for referer list item, that is taken from InterWikiName database.
186        @@lang: en
187      @Formatting:
188        try {
189          $f->replace ($o->{link}->{src}->{ref__label},
190                       param => $o,
191                       -parent => $p->{-parent});
192        } catch Message::Util::Formatter::error with {
193          my $err = shift;
194          if ($err->{-object}->{-category_name} eq $f->{-category_name}) {
195            my $wiki = $err->{option}->{param}->{wiki};
196            SuikaWiki::Plugin->module_package ('Error')
197                             ->reporting_formatting_template_error
198                                 ($err, $wiki,
199                                  template => $o->{link}->{src}->{ref__label});
200            undef;
201          } else {
202            $err->throw;
203          }
204        };
205    
206    ViewFragment:
207      @Name: ws--post-content
208      @Description:
209        @@@: After content body -- referer lista
210        @@lang:en
211      @Order: 150
212    @Formatting:    @Formatting:
213      $f->replace ($o->{link}->{src}->{ref__label},          %section (
214                   param => $o,            id => referer,
215                   -parent => $p->{-parent});            title => {%res(name=>Referer);}p, heading,
216              content => {%referer-list;}p,
217            );
218    
219  Resource:  Resource:
220    @Referer:RefererList:Label:    @Referer:RefererList:Label:

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24