/[pub]/suikawiki/script/misc/plugins/link/map.wp2
Suika

Diff of /suikawiki/script/misc/plugins/link/map.wp2

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

revision 1.1 by wakaba, Sun Feb 1 12:09:44 2004 UTC revision 1.8 by wakaba, Sat Mar 13 11:39:31 2004 UTC
# Line 6  Plugin: Line 6  Plugin:
6      @@@:      @@@:
7        Visualization of page to page relatinships        Visualization of page to page relatinships
8      @@lang:en      @@lang:en
9    @License: %%GPL%%    @License: %%Perl%%
10    @Author:    @Author:
11      @@Name:      @@Name:
12        @@@@: Wakaba        @@@@: Wakaba
13        @@@lang:ja        @@@lang:ja
14        @@@script:Latn        @@@script:Latn
15      @@Mail[list]: w@suika.fam.cx      @@Mail[list]: w@suika.fam.cx
16    @Date.RCS: $Date$    @Date.RCS:
17         $Date$
18    @RequiredPlugin[list]:    @RequiredPlugin[list]:
19      WikiLinking      WikiLinking
20    @Use:    @Use:
# Line 64  FormattingRule: Line 65  FormattingRule:
65      __ATTRTEXT:%ns__;__ATTRTEXT:%recursive__;      __ATTRTEXT:%ns__;__ATTRTEXT:%recursive__;
66      __ATTRTEXT:%n__;      __ATTRTEXT:%n__;
67      $p->{recursive} = 1 unless length $p->{recursive};      $p->{recursive} = 1 unless length $p->{recursive};
68      $p->{ns} .= '//' if $p->{ns} and not substr ($p->{ns}, -2) eq '//';      my $ns = $o->{wiki}->name ($p->{ns});
69        #$ns->append_component ('') unless $ns->[$#$ns] eq '';
70      my $i = 0;      my $i = 0;
71      $p->{n} ||= 10;      $p->{n} ||= 10;
72      __ATTRTEXT:%template__;      __ATTRTEXT:%template__;
# Line 74  FormattingRule: Line 76  FormattingRule:
76      __ATTRTEXT:%mode__;      __ATTRTEXT:%mode__;
77      for (sort {$b->[1] <=> $a->[1]}      for (sort {$b->[1] <=> $a->[1]}
78           map  { try { [$_, $o->{wiki}->{db}->get (lastmodified => $_)] }           map  { try { [$_, $o->{wiki}->{db}->get (lastmodified => $_)] }
79                  catch SuikaWiki::DB::Util::Error with {[$_, undef]} }                  catch SuikaWiki::DB::Util::Error with {
80                      my $err = shift;
81                      $err->throw if $err->{-type} eq 'ERROR_REPORTED';
82                      [$_, undef]} }
83           $o->{wiki}->{db}->keys ('content',           $o->{wiki}->{db}->keys ('content',
84                                   -ns => [split m#//#, $p->{ns}],                                   -ns => $ns,
85                                   -type => 'key',                                   -type => 'key',
86                                   -recursive => $p->{recursive})) {                                   -recursive => $p->{recursive})) {
87        next unless $_->[0];        next unless $_->[0];
88        last if $i++ == $p->{n};        last if $i++ == $p->{n};
89                
       my $li = $list->append_new_node  
                         (type => '#element',  
                          namespace_uri => $NS_XHTML1,  
                          local_name => 'li');  
90        $WIKILINKING->to_wikipage_in_html ({        $WIKILINKING->to_wikipage_in_html ({
91          label => $p->{template},          label => $p->{template},
92        } => {        } => {
93  #        base => $o->{page},          base => $o->{wiki}->{var}->{page},
94          page_name_relative => $_->[0],          page_name_relative => $o->{wiki}->name ($_->[0]),
95          wiki_mode => $p->{mode},          wiki_mode => $p->{mode},
96          _with_lm => 1,          _with_lm => 1,
97          page_lastmodified => $_->[1],          page_lastmodified => $_->[1],
98        }, {        }, {
99          o => $o,          o => $o,
100          parent => $li,          parent => $list->append_new_node
101                            (type => '#element',
102                             namespace_uri => $NS_XHTML1,
103                             local_name => 'li'),
104        });        });
105      }      }
106    
# Line 126  FormattingRule: Line 130  FormattingRule:
130      __ATTRTEXT:%ns__;__ATTRTEXT:%recursive__;      __ATTRTEXT:%ns__;__ATTRTEXT:%recursive__;
131      __ATTRTEXT:%n__;      __ATTRTEXT:%n__;
132      $p->{recursive} = 1 unless length $p->{recursive};      $p->{recursive} = 1 unless length $p->{recursive};
133      $p->{ns} .= '//' if $p->{ns} and not substr ($p->{ns}, -2) eq '//';      my $ns = $o->{wiki}->name ($p->{ns});
134        #$ns->append_component ('') unless $ns->[$#$ns] eq '';
135      my $i = 0;      my $i = 0;
136      $p->{n} ||= -1;      $p->{n} ||= -1;
137      __ATTRTEXT:%template__;      __ATTRTEXT:%template__;
138      $p->{template} ||= $WIKIRESOURCE->get      $p->{template} ||= $WIKIRESOURCE->get
139          (name => 'Link:toWikiPage:SourceLabelLong:PageList',          (name => 'Link:toWikiPage:SourceLabelLong:PageList',
140           wiki => $o->{wiki}, o => $o);           wiki => $o->{wiki}, o => $o);
141        __ATTRTEXT:%match__; ## WARNING: This parameter might be dangerous!
142        my $reg = $p->{match} ? qr/$p->{match}/ : qr/./;
143      __ATTRTEXT:%mode__;      __ATTRTEXT:%mode__;
144      try {      try {
145        for (sort {$a->[1] cmp $b->[1]}        for (sort {$a->[1] cmp $b->[1]}
146             map {[$_, join '//', @{$_}]}             grep {$_->[1] =~ /$reg/}
147               map {[$_, join '//', @{$_}]} # make sort key
148             $o->{wiki}->{db}->keys ('content',             $o->{wiki}->{db}->keys ('content',
149                                     -ns => [split m#//#, $p->{ns}],                                     -ns => $ns,
150                                     -type => 'key',                                     -type => 'key',
151                                     -recursive => $p->{recursive})) {                                     -recursive => $p->{recursive})) {
152          last if $i++ == $p->{n};          last if $i++ == $p->{n};
153                    
         my $li = $list->append_new_node  
                           (type => '#element',  
                            namespace_uri => $NS_XHTML1,  
                            local_name => 'li');  
154          $WIKILINKING->to_wikipage_in_html ({          $WIKILINKING->to_wikipage_in_html ({
155            label => $p->{template},            label => $p->{template},
156          } => {          } => {
157  #          base => $o->{page},            base => $o->{wiki}->{var}->{page},
158            page_name_relative => $_->[0],            page_name_relative => $o->{wiki}->name ($_->[0]),
159            wiki_mode => $p->{mode},            wiki_mode => $p->{mode},
160          }, {          }, {
161            o => $o,            o => $o,
162            parent => $li,            parent => $list->append_new_node
163                              (type => '#element',
164                               namespace_uri => $NS_XHTML1,
165                               local_name => 'li'),
166          });          });
167        }        }
168      } catch SuikaWiki::DB::Util::Error with {      } catch SuikaWiki::DB::Util::Error with {
169        #        my $err = shift;
170          $err->throw if $err->{-type} eq 'ERROR_REPORTED';
171      };      };
172      $p->{-parent}->remove_child_node ($list) unless $list->count;      $p->{-parent}->remove_child_node ($list) unless $list->count;
173    
# Line 171  FormattingRule: Line 179  FormattingRule:
179    @Name: search-result    @Name: search-result
180    @Formatting:    @Formatting:
181      __ATTRTEXT:%key__;      __ATTRTEXT:%key__;
182      $p->{key} ||= join '//', @{$o->{wiki}->{var}->{page}};      $p->{key} ||= $o->{wiki}->{var}->{page}->stringify (wiki => $o->{wiki});
183      __ATTRTEXT:%case_sensible__;      __ATTRTEXT:%case_sensible__;
184      my $word = $p->{case_sensible} ? $p->{key} : lc $p->{key};      my $word = $p->{case_sensible} ? $p->{key} : lc $p->{key};
185      my @r;      my @r;
186      my $sr = $o->{wiki}->{db}->get (m__search_result => [$word]);      my $sr = $o->{wiki}->{db}->get (m__search_result => [$word]);
187      unless ($sr) {      unless ($sr) {
188          my $i = 0;
189        for my $page ($o->{wiki}->{db}->keys ('content')) {        for my $page ($o->{wiki}->{db}->keys ('content')) {
190            last if ++$i == 512;
191          my $content;          my $content;
192          try {          try {
193            $content = $o->{wiki}->{db}->get (content => $page);            $content = $o->{wiki}->{db}->get (content => $page);
194          } catch SuikaWiki::DB::Util::Error with {          } catch SuikaWiki::DB::Util::Error with {
195              my $err = shift;
196              $err->throw if $err->{-type} eq 'ERROR_REPORTED';
197            $content = undef;            $content = undef;
198          };          };
199          $content = $p->{case_sensible} ? $content : lc $content;          $content = $p->{case_sensitive} ? $content : lc $content;
200          $content =~ s/^[^\x0A\x0D]+[\x0D\x0A]+//s;          $content =~ s/^[^\x0A\x0D]+[\x0D\x0A]+//s;
201          my $n_page = $p->{case_sensible} ? join '//', @$page          $page = $o->{wiki}->name ($page);
202                                           : lc join '//', @$page;          my $n_page = $page->stringify (wiki => $o->{wiki});
203            $n_page = lc $n_page unless $p->{case_sensible};
204          if (index ($n_page, $word) > -1) {          if (index ($n_page, $word) > -1) {
205                 my $c = $content =~ s/\Q$word\E//g;                 my $c = $content =~ s/\Q$word\E//g;
206                  push @r, [$page, $c+20];                  push @r, [$page, $c+20];
# Line 199  FormattingRule: Line 212  FormattingRule:
212                }                }
213        }        }
214        @r = sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r;        @r = sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r;
215        $sr = join "\x1E", map {join ("\x1D", @{$_->[0]})."\x1F".$_->[1]} @r;        $sr = join "\x1E",
216                map {$_->[0]->stringify (wiki => $o->{wiki}, delimiter => "\x1D")
217                     ."\x1F".$_->[1]} @r;
218        $o->{wiki}->{db}->set (m__search_result => [$word] => $sr);        $o->{wiki}->{db}->set (m__search_result => [$word] => $sr);
219  ## TODO: Cache & case-sensibility  ## TODO: Cache & case-sensitivility
220      } else {      } else {
221        @r = map {[[split /\x1D/, $_->[0]], $_->[1]]}        @r = map {[$o->{wiki}->name ($_->[0], delimiter_reg => qr/\x1D/), $_->[1]]}
222             map {[split /\x1F/, $_, 2]} split /\x1E/, $sr;             map {[split /\x1F/, $_, 2]} split /\x1E/, $sr;
223      }      }
       #my $em = $p->{em} ? sub { my $s = shift; $s =~ s#(\Q$word\E)#<em>$1</em>#gi; $s } : sub {$_[0]};  
         
224        return unless @r;        return unless @r;
225        my $list = $p->{-parent}->append_new_node        my $list = $p->{-parent}->append_new_node
226                                  (type => '#element',                                  (type => '#element',
# Line 218  FormattingRule: Line 231  FormattingRule:
231            (name => 'Link:toWikiPage:SourceLabelLong:SearchResult',            (name => 'Link:toWikiPage:SourceLabelLong:SearchResult',
232             wiki => $o->{wiki}, o => $o);             wiki => $o->{wiki}, o => $o);
233        for (@r) {        for (@r) {
         my $li = $list->append_new_node  
                           (type => '#element',  
                            namespace_uri => $NS_XHTML1,  
                            local_name => 'li');  
234          $WIKILINKING->to_wikipage_in_html ({          $WIKILINKING->to_wikipage_in_html ({
235            label => $p->{template},            label => $p->{template},
236          } => {          } => {
237  #          base => $o->{page},            base => $o->{wiki}->{var}->{page},
238            page_name_relative => $_->[0],            page_name_relative => $_->[0],
239            wiki_mode => $p->{mode},            wiki_mode => $p->{mode},
240          }, {          }, {
241            o => $o,            o => $o,
242            parent => $li,            parent => $list->append_new_node
243                              (type => '#element',
244                               namespace_uri => $NS_XHTML1,
245                               local_name => 'li'),
246            -m__weight => $_->[1],            -m__weight => $_->[1],
247          });          });
248        }        }
# Line 245  FormattingRule: Line 257  FormattingRule:
257  ViewFragment:  ViewFragment:
258    @Name: ws--post-content    @Name: ws--post-content
259    @Description:    @Description:
260      @@@: After content body -- navigation bar      @@@: After content body -- children and backward links
261      @@lang:en      @@lang:en
262    @Order: 100    @Order: 100
263    @Formatting:    @Formatting:
# Line 263  ViewFragment: Line 275  ViewFragment:
275            title => {%res(name=>SeeAlso);}p, heading,            title => {%res(name=>SeeAlso);}p, heading,
276            content => {%search-result;}p,            content => {%search-result;}p,
277          );          );
         %section (  
           id => referer,  
           title => {%res(name=>Referer);}p, heading,  
           content => {%referer-list;}p,  
         );  
278    
279  Resource:  Resource:
280    @Children:Title:    @Children:Title:
# Line 296  Resource: Line 303  Resource:
303      );      );
304      %span(class=>headline,content=>{%page-headline;}p);      %span(class=>headline,content=>{%page-headline;}p);
305    
306  ## TODO:  ## TODO: Make recent-changes page name customizable
307  ViewFragment:  ViewFragment:
308    @Name: navbar    @Name: navbar
309    @Order: 21    @Order: 21
# Line 304  ViewFragment: Line 311  ViewFragment:
311      %link-to-wikipage (      %link-to-wikipage (
312        page => {RecentChanges},        page => {RecentChanges},
313        label => {%link-to-it (        label => {%link-to-it (
314                   label=>"%res(name=>GoToRecentChanges);"p,          label => {%res (name => GoToRecentChanges);}p,
315                   description=>"%res(name=>GoToRecentChangesLong);"p,          description => {%res (name => GoToRecentChangesLong);}p,
316        );},        );},
317        rel => news,        rel => news,
318      );      );
# Line 320  ViewFragment: Line 327  ViewFragment:
327        label => {%html-link (        label => {%html-link (
328                    description => {%res(name=>GoToRecentChangesLink);}p,                    description => {%res(name=>GoToRecentChangesLink);}p,
329                  );},                  );},
     );  
330        );
331    
332    Resource:
333      @GoToRecentChanges:
334        @@@: Recent
335        @@lang: en
336      @GoToRecentChangesLink:
337        @@@: Recently modified WikiPages list
338        @@lang: en
339      @GoToRecentChangesLong:
340        @@@: Review recently modified WikiPages list
341        @@lang: en
342    
343    
344    

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24