/[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.10 by wakaba, Fri Mar 19 03:42:06 2004 UTC revision 1.12 by wakaba, Thu Apr 1 04:39:58 2004 UTC
# Line 16  Plugin: Line 16  Plugin:
16    @Date.RCS:    @Date.RCS:
17       $Date$       $Date$
18    @RequiredPlugin[list]:    @RequiredPlugin[list]:
19        Search
20      WikiLinking      WikiLinking
21        WikiNamespace
22    @Use:    @Use:
23      use Message::Util::Error;      use Message::Util::Error;
24      my $WIKILINKING;      my $WIKILINKING;
# Line 63  FormattingRule: Line 65  FormattingRule:
65      $list->set_attribute (class => 'm--recent-changes');      $list->set_attribute (class => 'm--recent-changes');
66            
67      __ATTRTEXT:%ns__;__ATTRTEXT:%recursive__;      __ATTRTEXT:%ns__;__ATTRTEXT:%recursive__;
     __ATTRTEXT:%n__;  
68      $p->{recursive} = 1 unless length $p->{recursive};      $p->{recursive} = 1 unless length $p->{recursive};
69      my $ns = $o->{wiki}->name ($p->{ns});      my $ns = $o->{wiki}->name ($p->{ns});
70      #$ns->append_component ('') unless $ns->[$#$ns] eq '';  
71      my $i = 0;      my @target = map  { try { [$_, $o->{wiki}->{db}->get (lastmodified => $_)] }
72      $p->{n} ||= 10;                          catch SuikaWiki::DB::Util::Error with {
73                              my $err = shift;
74                              $err->throw if $err->{-type} eq 'ERROR_REPORTED';
75                              [$_, undef]} }
76             $o->{wiki}->{db}->keys ('lastmodified',
77                                     -ns => $ns,
78                                     -type => 'key',
79                                     -recursive => $p->{recursive});
80        try {
81          my $nsmodified = $o->{wiki}->{db}->get (lastmodified => $ns);
82          push @target, [$ns, $nsmodified] if $nsmodified;
83        } catch SuikaWiki::DB::Util::Error with {
84          my $err = shift;
85          $err->throw if $err->{-type} eq 'ERROR_REPORTED';
86        };
87        @target = sort {$b->[1] <=> $a->[1]} @target;
88    
89        __ATTRTEXT:%start__;
90        __ATTRTEXT:%n__;
91        my $start = length $p->{start} ? $p->{start} :
92                    $o->{wiki}->{input}->parameter ('m--change--range-start') || 0;
93        $p->{n} = $o->{wiki}->{input}->parameter ('m--change--range-number')
94                     unless length $p->{n};
95        my $end = $p->{n} ? $start + $p->{n} - 1 : $start + 29;
96        $start = 0 if $start > $#target or $start < 0;
97        $end = $#target if $end < $start or $end > $#target;
98        $end = $start + 255 if $end > $start + 255;
99        local $o->{var}->{search__result} = {
100          min => 0,
101          max => $#target,
102          start => $start,
103          end => $end,
104          number => $p->{n} || 30,
105          query => $p->{query},
106          param_prefix => 'm--change',
107        };
108    
109      __ATTRTEXT:%template__;      __ATTRTEXT:%template__;
110      $p->{template} ||= $WIKIRESOURCE->get      $p->{template} ||= $WIKIRESOURCE->get
111          (name => 'Link:toWikiPage:SourceLabelLong:RecentChangeItem',          (name => 'Link:toWikiPage:SourceLabelLong:RecentChangeItem',
112           wiki => $o->{wiki}, o => $o);           wiki => $o->{wiki}, o => $o);
113      __ATTRTEXT:%mode__;      __ATTRTEXT:%mode__;
114      for (sort {$b->[1] <=> $a->[1]}  
115           map  { try { [$_, $o->{wiki}->{db}->get (lastmodified => $_)] }      for my $target (@target[$start..$end]) {
                 catch SuikaWiki::DB::Util::Error with {  
                   my $err = shift;  
                   $err->throw if $err->{-type} eq 'ERROR_REPORTED';  
                   [$_, undef]} }  
          $o->{wiki}->{db}->keys ('content',  
                                  -ns => $ns,  
                                  -type => 'key',  
                                  -recursive => $p->{recursive})) {  
       next unless $_->[0];  
       last if $i++ == $p->{n};  
         
116        $WIKILINKING->to_wikipage_in_html ({        $WIKILINKING->to_wikipage_in_html ({
117          label => $p->{template},          label => $p->{template},
118        } => {        } => {
119          base => $o->{wiki}->{var}->{page},          base => $o->{wiki}->{var}->{page},
120          page_name_relative => $o->{wiki}->name ($_->[0]),          page_name_relative => $o->{wiki}->name ($target->[0]),
121          wiki_mode => $p->{mode},          wiki_mode => $p->{mode},
122          _with_lm => 1,          _with_lm => 1,
123          page_lastmodified => $_->[1],          page_lastmodified => $target->[1],
124        }, {        }, {
125          o => $o,          o => $o,
126          parent => $list->append_new_node          parent => $list->append_new_node
# Line 104  FormattingRule: Line 130  FormattingRule:
130        });        });
131      }      }
132    
133        if ($list->count) {
134          $list->set_attribute (start => $start + 1);
135          __ATTRNODE:%post_list->{$p->{-parent}}__;
136        } else {
137          $p->{-parent}->remove_child_node ($list);
138        }
139    
140    ViewDefinition:
141      @Mode: m--change
142      @Condition:
143        @@http-method[list]:
144          GET
145          HEAD
146          POST
147      @Description:
148        @@@: Show recently changed WikiPages list
149        @@lang: en
150      @template:
151        @@http-status-code: 200
152        @@media-type: text/html
153        @@use-media-type-charset: 1
154        @@expires: %%list%%
155        @@body:
156            %html-document (
157              title => {%res (name => {Map:Change:WebPageTitle});}p,
158              link-meta => {%template (name => links);}p,
159              content => {
160                %block (
161                  id => tools1, class => tools,
162                  content => {%template (name => navbar);}p,
163                );
164                %section (
165                  title => {%res (name => {Map:Change:Title});}p,
166                  heading,
167                  id => WEBPAGE--M--CHANGE,
168                  content => {%recent-change-list (
169                    n => 50,
170                    ns => {%page-name;}p,
171                    post-list => {%search--result-navigation (
172                      fragment => WEBPAGE--M--CHANGE,
173                    );}p,
174                  );}p,
175                );
176                %block (
177                  id => footer,
178                  content => {%template (name => ws--footer);}p,
179                );
180              }p,
181            );
182    
183    
184  FormattingRule:  FormattingRule:
185    @Category[list]:    @Category[list]:
186      form-input      form-input
# Line 128  FormattingRule: Line 205  FormattingRule:
205                                   local_name => 'ul');                                   local_name => 'ul');
206            
207      __ATTRTEXT:%ns__;__ATTRTEXT:%recursive__;      __ATTRTEXT:%ns__;__ATTRTEXT:%recursive__;
     __ATTRTEXT:%n__;  
208      $p->{recursive} = 1 unless length $p->{recursive};      $p->{recursive} = 1 unless length $p->{recursive};
209      my $ns = $o->{wiki}->name ($p->{ns});      my $ns = $o->{wiki}->name ($p->{ns});
210      #$ns->append_component ('') unless $ns->[$#$ns] eq '';  
211      my $i = 0;      my @target = sort {$a->[1] cmp $b->[1]}
212      $p->{n} ||= -1;             map {[$_, join "\t", @{$_}]} # make sort key
213               $o->{wiki}->{db}->keys ('content',
214                                       -ns => $ns,
215                                       -type => 'key',
216                                       -recursive => $p->{recursive});
217    
218        __ATTRTEXT:%start__;
219        __ATTRTEXT:%n__;
220        my $start = length $p->{start} ? $p->{start} :
221                    $o->{wiki}->{input}->parameter ('m--list--range-start') || 0;
222        $p->{n} = $o->{wiki}->{input}->parameter ('m--list--range-number')
223                     unless length $p->{n};
224        my $end = $p->{n} ? $start + $p->{n} - 1 : $start + 29;
225        $start = 0 if $start > $#target or $start < 0;
226        $end = $#target if $end < $start or $end > $#target;
227        $end = $start + 255 if $end > $start + 255;
228        local $o->{var}->{search__result} = {
229          min => 0,
230          max => $#target,
231          start => $start,
232          end => $end,
233          number => $p->{n} || 30,
234          query => $p->{query},
235          param_prefix => 'm--list',
236        };
237    
238      __ATTRTEXT:%template__;      __ATTRTEXT:%template__;
239      $p->{template} ||= $WIKIRESOURCE->get      $p->{template} ||= $WIKIRESOURCE->get
240          (name => 'Link:toWikiPage:SourceLabelLong:PageList',          (name => 'Link:toWikiPage:SourceLabelLong:PageList',
241           wiki => $o->{wiki}, o => $o);           wiki => $o->{wiki}, o => $o);
242      __ATTRTEXT:%match__; ## WARNING: This parameter might be dangerous!  
     my $reg = $p->{match} ? qr/$p->{match}/ : qr/./;  
243      __ATTRTEXT:%mode__;      __ATTRTEXT:%mode__;
244      try {      try {
245        for (sort {$a->[1] cmp $b->[1]}        for (@target[$start..$end]) {
            grep {$_->[1] =~ /$reg/}  
            map {[$_, join '//', @{$_}]} # make sort key  
            $o->{wiki}->{db}->keys ('content',  
                                    -ns => $ns,  
                                    -type => 'key',  
                                    -recursive => $p->{recursive})) {  
         last if $i++ == $p->{n};  
           
246          $WIKILINKING->to_wikipage_in_html ({          $WIKILINKING->to_wikipage_in_html ({
247            label => $p->{template},            label => $p->{template},
248          } => {          } => {
# Line 169  FormattingRule: Line 261  FormattingRule:
261        my $err = shift;        my $err = shift;
262        $err->throw if $err->{-type} eq 'ERROR_REPORTED';        $err->throw if $err->{-type} eq 'ERROR_REPORTED';
263      };      };
264      $p->{-parent}->remove_child_node ($list) unless $list->count;  
265        if ($list->count) {
266          $list->set_attribute (start => $start + 1);
267          __ATTRNODE:%post_list->{$p->{-parent}}__;
268        } else {
269          $p->{-parent}->remove_child_node ($list);
270        }
271    
272    
273  FormattingRule:  FormattingRule:
274    @Category[list]:    @Category[list]:
# Line 192  ViewFragment: Line 291  ViewFragment:
291                       ns       => {%page-name;}p, recursive => 0,                       ns       => {%page-name;}p, recursive => 0,
292                       type     => both,                       type     => both,
293                       template => {%resource-as-plain-text (name => {Children:Item});}p,                       template => {%resource-as-plain-text (name => {Children:Item});}p,
294                         post-list => {%search--result-navigation (
295                           fragment => children,
296                         );}p,
297                     );}p,                     );}p,
298      );      );
299    
 Resource:  
   @Children:Title:  
       %link-to-it(label=>{%ns-short-page-name;}p,  
         description=>{%page-name(absolute);}p,  
       );  
       %span(class=>headline, content=>{%page-headline;}p);  
   @Link:toWikiPage:SourceLabelLong:PageList:  
     %link-to-it(  
       label=>{%page-title(relative);}p,  
       description=>{%page-name(absolute);}p,  
     );  
     %span(class=>headline,content=>{%page-headline;}p);  
   @Link:toWikiPage:SourceLabelLong:RecentChangeItem:  
     %last-modified;  
     %link-to-it(  
       label=>{%page-title(relative);}p,  
       description=>{%page-name(absolute);}p,  
     );  
     %span(class=>headline,content=>{%page-headline;}p);  
   
 ## TODO: Make recent-changes page name customizable  
300  ViewFragment:  ViewFragment:
301    @Name: navbar    @Name: navbar
302    @Order: 21    @Order: 21
303    @Formatting:    @Formatting:
304      %link-to-wikipage (      %link-to-wikipage (
305        page => {RecentChanges},        page => {%ns--root-wikiname;}p,
306          mode => m--change,
307        label => {%link-to-it (        label => {%link-to-it (
308          label => {%res (name => GoToRecentChanges);}p,          label => {%res (name => GoToRecentChanges);}p,
309          description => {%res (name => GoToRecentChangesLong);}p,          description => {%res (name => GoToRecentChangesLong);}p,
# Line 229  ViewFragment: Line 311  ViewFragment:
311        rel => news,        rel => news,
312      );      );
313    
 ## TODO:  
314  ViewFragment:  ViewFragment:
315    @Name: links    @Name: links
316    @Formatting:    @Formatting:
317      %link-to-wikipage (      %link-to-wikipage (
318        page => {RecentChanges},        page => {%ns--root-wikiname;}p,
319        rel => news,        rel => news,
320          mode => m--change,
321        label => {%html-link (        label => {%html-link (
322                    description => {%res(name=>GoToRecentChangesLink);}p,                    description => {%res(name=>GoToRecentChangesLink);}p,
323                  );},                  );},
324      );      );
325        %link-to-wikipage (
326          page => {%ns-page-path-name;}p,
327          rel => news,
328          mode => m--change,
329          label => {%html-link (
330            description => {%res(name=> {Map:Change:Link:Parent:Description});}p,
331          );},
332        );
333        %link-to-wikipage (
334          rel => news,
335          mode => m--change,
336          label => {%html-link (
337            description => {%res(name=> {Map:Change:Link:Local:Description});}p,
338          );},
339        );
340    
341  Resource:  Resource:
342      @Children:Title:
343          %link-to-it(label=>{%ns-short-page-name;}p,
344            description=>{%page-name(absolute);}p,
345          );
346          %span(class=>headline, content=>{%page-headline;}p);
347      @Link:toWikiPage:SourceLabelLong:PageList:
348        %link-to-it(
349          label=>{%page-title(relative);}p,
350          description=>{%page-name(absolute);}p,
351        );
352        %span(class=>headline,content=>{%page-headline;}p);
353      @Link:toWikiPage:SourceLabelLong:RecentChangeItem:
354        %last-modified;
355        %link-to-it(
356          label=>{%page-title(relative);}p,
357          description=>{%page-name(absolute);}p,
358        );
359        %span(class=>headline,content=>{%page-headline;}p);
360      @Link:toWikiPage:SourceLabelLong:SearchResult:
361        {%m--link-weight;}
362        %link-to-it(
363          label=>{%page-title(relative);}p,
364          description=>{%page-name(absolute);}p,
365        );
366        %span(class=>headline,content=>{%page-headline;}p);
367    @GoToRecentChanges:    @GoToRecentChanges:
368      @@@: Recent      @@@: Recent
369      @@lang: en      @@lang: en
# Line 251  Resource: Line 373  Resource:
373    @GoToRecentChangesLong:    @GoToRecentChangesLong:
374      @@@: Review recently modified WikiPages list      @@@: Review recently modified WikiPages list
375      @@lang: en      @@lang: en
376      @Map:Change:Link:Local:Description:
377        @@@: List of recently modified WikiPages in this namespace (%page-name;)
378        @@lang: en
379      @Map:Change:Link:Parent:Description:
380        @@@:
381          List of recently modified WikiPages in parent namespace
382          (%ns-page-path-name;)
383        @@lang: en
384      @Map:Change:Title:
385        @@@: Recent Changes
386        @@lang: en
387      @Map:Change:WebPageTitle:
388        @@@: Recent Changes (%page-name;)
389        @@lang: en
390      
391    
392    

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.12

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24