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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (hide annotations) (download)
Tue Sep 21 03:18:22 2004 UTC (20 years, 9 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, HEAD
Branch point for: helowiki, helowiki-2005
Changes since 1.14: +72 -1 lines
%m--wikipage-obsolete rule added

1 wakaba 1.1 #?SuikaWikiConfig/2.0
2    
3     Plugin:
4     @Name: Map
5     @Description:
6     @@@:
7     Visualization of page to page relatinships
8     @@lang:en
9 wakaba 1.3 @License: %%Perl%%
10 wakaba 1.1 @Author:
11     @@Name:
12     @@@@: Wakaba
13     @@@lang:ja
14     @@@script:Latn
15     @@Mail[list]: w@suika.fam.cx
16 wakaba 1.2 @Date.RCS:
17 wakaba 1.15 $Date: 2004/08/06 03:38:11 $
18 wakaba 1.1 @RequiredPlugin[list]:
19 wakaba 1.12 Search
20 wakaba 1.1 WikiLinking
21 wakaba 1.12 WikiNamespace
22 wakaba 1.1 @Use:
23     use Message::Util::Error;
24     my $WIKILINKING;
25     my $WIKIRESOURCE;
26 wakaba 1.13 @Namespace:
27     @@relrev:
28     http://suika.fam.cx/~wakaba/archive/2004/7/25/html-relrev#
29 wakaba 1.15 @@sw:
30     http://suika.fam.cx/~wakaba/archive/2004/7/20/sw#
31 wakaba 1.1
32     PluginConst:
33     @NS_XHTML1:
34     http://www.w3.org/1999/xhtml
35     @NS_RDF:
36     http://www.w3.org/1999/02/22-rdf-syntax-ns#
37     @NS_RSS:
38     http://purl.org/rss/1.0/
39     @NS_DC:
40     http://purl.org/dc/elements/1.1/
41     @NS_MAP:
42     http://members.jcom.home.ne.jp/jintrick/2003/02/site-concept.xml#
43     @WIKILINKING:
44     {($WIKILINKING ||= SuikaWiki::Plugin->module_package ('WikiLinking'))}
45     @WIKIRESOURCE:
46     {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))}
47 wakaba 1.15
48     FormattingRule:
49     @Category[list]: view
50     @Name: m--wikipage-obsolete
51     @Description:
52     @@@:
53     The navigation notify that this WikiPage is obsolete and
54     should refer the other WikiPages.
55     @@lang: en
56     @Parameter:
57     @@Name: desc-after
58     @@Type: template
59     @@Default: (none)
60     @@Description:
61     @@@lang:en
62     @@@@: The description should be located after WikiPage names if any.
63     @Parameter:
64     @@Name: desc-before
65     @@Type: template
66     @@Default: (none)
67     @@Description:
68     @@@lang:en
69     @@@@: The description should be located before WikiPage names if any.
70     @Parameter:
71     @@Name: page
72     @@Type: WikiName
73     @@Default: (current)
74     @@Description:
75     @@@lang: en
76     @@@@: The WikiPage that might be obsoleted.
77     @Formatting:
78     my $page = $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page});
79     my $content_prop;
80     try {
81     $content_prop = $o->{wiki}->{db}->get (content_prop => $page);
82     } catch SuikaWiki::DB::Util::Error with {
83     my $err = shift;
84     $err->throw if $err->{-type} eq 'ERROR_REPORTED';
85     } catch SuikaWiki::Format::Definition::error with {
86     #
87     };
88    
89     if ($content_prop) {
90     my $obs = $content_prop->get_attribute_value
91     (<Q:sw:obsolete>, as_array => 1,
92     default => []);
93     if (@$obs) {
94     my $pp = $p->{-parent}->append_new_node
95     (type => '#element',
96     namespace_uri => $NS_XHTML1,
97     local_name => 'p');
98     $pp->set_attribute (class => 'm--wikipage-obsolete');
99     __ATTRNODE:%desc_before->{$pp}__;
100     my $i = 0;
101     for (@$obs) {
102     $pp->append_text (', ') if $i++;
103     __FUNCPACK{WikiLinking}__->to_wikipage_in_html (
104     {
105     } => {
106     base => $page,
107     page_name_relative => $o->{wiki}->name ($_),
108     }, {
109     o => $o,
110     parent => $pp,
111     });
112     }
113     __ATTRNODE:%desc_after->{$pp}__;
114     }
115     }
116 wakaba 1.1
117     FormattingRule:
118 wakaba 1.13 @Category[list]: view
119     @Name: m--html-link-navigation
120     @Description:
121     @@@: Navigation links (HTML link elements) made from content properties
122     @@lang: en
123     @Parameter:
124     @@Name: page
125     @@Type: WikiName
126     @@Default: (current)
127     @@Description:
128     @@@lang: en
129     @@@@: Target WikiPage
130     @Formatting:
131     my $page = $o->{wiki}->name ($p->{page} || $o->{wiki}->{var}->{page});
132     my $content_prop;
133     try {
134     $content_prop = $o->{wiki}->{db}->get (content_prop => $page);
135     } catch SuikaWiki::DB::Util::Error with {
136     my $err = shift;
137     $err->throw if $err->{-type} eq 'ERROR_REPORTED';
138     } catch SuikaWiki::Format::Definition::error with {
139     #
140     };
141    
142     if ($content_prop) {
143 wakaba 1.14 for my $rel (
144 wakaba 1.13 {uri => <Q:relrev:prev>, html => 'prev'},
145     {uri => <Q:relrev:next>, html => 'next'},
146     {uri => <Q:relrev:contents>, html => 'contents'},
147     {uri => <Q:relrev:index>, html => 'index'},
148     {uri => <Q:relrev:up>, html => 'up'},
149     ) {
150 wakaba 1.14 if (my $val = $content_prop->get_attribute ($rel->{uri})) {
151     $val = $val->value;
152     for (ref $val eq 'ARRAY' ? @$val : $val) {
153     __FUNCPACK{WikiLinking}__->to_wikipage_in_html (
154     {
155     label => qq(%html-link (
156     description => {%res (name => {Map:LinkNav:$rel->{html}:Description});: %page-name;: %page-headline;}p,
157     );\n),
158     } => {
159     base => $page,
160     page_name_relative => $o->{wiki}->name ($_),
161     }, {
162     o => $o,
163     parent => $p->{-parent},
164     -rel => $rel->{html},
165     });
166     }
167 wakaba 1.13 }
168     }
169     }
170    
171     FormattingRule:
172 wakaba 1.1 @Category[list]:
173     form-input
174     view
175     view-resource
176     @Name: recent-change-list
177     @Description:
178     @@@: Recently changed WikiPage list
179     @@lang: en
180     @Parameter:
181     @@Name: ns
182     @@Type: WikiName
183     @@Default: (auto)
184     @@Description:
185     @@@@:
186     WikiNamespace name to which listed WikiPages belong
187     @@@lang: en
188     @Formatting:
189     my $list = $p->{-parent}->append_new_node
190     (type => '#element',
191     namespace_uri => $NS_XHTML1,
192     local_name => 'ol');
193     $list->set_attribute (class => 'm--recent-changes');
194    
195     __ATTRTEXT:%ns__;__ATTRTEXT:%recursive__;
196     $p->{recursive} = 1 unless length $p->{recursive};
197 wakaba 1.2 my $ns = $o->{wiki}->name ($p->{ns});
198 wakaba 1.12
199     my @target = map { try { [$_, $o->{wiki}->{db}->get (lastmodified => $_)] }
200     catch SuikaWiki::DB::Util::Error with {
201     my $err = shift;
202     $err->throw if $err->{-type} eq 'ERROR_REPORTED';
203     [$_, undef]} }
204     $o->{wiki}->{db}->keys ('lastmodified',
205     -ns => $ns,
206     -type => 'key',
207     -recursive => $p->{recursive});
208     try {
209     my $nsmodified = $o->{wiki}->{db}->get (lastmodified => $ns);
210     push @target, [$ns, $nsmodified] if $nsmodified;
211     } catch SuikaWiki::DB::Util::Error with {
212     my $err = shift;
213     $err->throw if $err->{-type} eq 'ERROR_REPORTED';
214     };
215     @target = sort {$b->[1] <=> $a->[1]} @target;
216    
217     __ATTRTEXT:%start__;
218     __ATTRTEXT:%n__;
219     my $start = length $p->{start} ? $p->{start} :
220     $o->{wiki}->{input}->parameter ('m--change--range-start') || 0;
221     $p->{n} = $o->{wiki}->{input}->parameter ('m--change--range-number')
222     unless length $p->{n};
223     my $end = $p->{n} ? $start + $p->{n} - 1 : $start + 29;
224     $start = 0 if $start > $#target or $start < 0;
225     $end = $#target if $end < $start or $end > $#target;
226     $end = $start + 255 if $end > $start + 255;
227     local $o->{var}->{search__result} = {
228     min => 0,
229     max => $#target,
230     start => $start,
231     end => $end,
232     number => $p->{n} || 30,
233     query => $p->{query},
234     param_prefix => 'm--change',
235     };
236    
237 wakaba 1.1 __ATTRTEXT:%template__;
238     $p->{template} ||= $WIKIRESOURCE->get
239     (name => 'Link:toWikiPage:SourceLabelLong:RecentChangeItem',
240     wiki => $o->{wiki}, o => $o);
241     __ATTRTEXT:%mode__;
242 wakaba 1.12
243     for my $target (@target[$start..$end]) {
244 wakaba 1.1 $WIKILINKING->to_wikipage_in_html ({
245     label => $p->{template},
246     } => {
247 wakaba 1.2 base => $o->{wiki}->{var}->{page},
248 wakaba 1.12 page_name_relative => $o->{wiki}->name ($target->[0]),
249 wakaba 1.1 wiki_mode => $p->{mode},
250     _with_lm => 1,
251 wakaba 1.12 page_lastmodified => $target->[1],
252 wakaba 1.1 }, {
253     o => $o,
254 wakaba 1.5 parent => $list->append_new_node
255     (type => '#element',
256     namespace_uri => $NS_XHTML1,
257     local_name => 'li'),
258 wakaba 1.1 });
259     }
260    
261 wakaba 1.12 if ($list->count) {
262     $list->set_attribute (start => $start + 1);
263     __ATTRNODE:%post_list->{$p->{-parent}}__;
264     } else {
265     $p->{-parent}->remove_child_node ($list);
266     }
267    
268     ViewDefinition:
269     @Mode: m--change
270     @Condition:
271     @@http-method[list]:
272     GET
273     HEAD
274     POST
275     @Description:
276     @@@: Show recently changed WikiPages list
277     @@lang: en
278     @template:
279     @@http-status-code: 200
280     @@media-type: text/html
281     @@use-media-type-charset: 1
282     @@expires: %%list%%
283     @@body:
284     %html-document (
285     title => {%res (name => {Map:Change:WebPageTitle});}p,
286     link-meta => {%template (name => links);}p,
287     content => {
288     %block (
289     id => tools1, class => tools,
290     content => {%template (name => navbar);}p,
291     );
292     %section (
293     title => {%res (name => {Map:Change:Title});}p,
294     heading,
295     id => WEBPAGE--M--CHANGE,
296     content => {%recent-change-list (
297     n => 50,
298     ns => {%page-name;}p,
299     post-list => {%search--result-navigation (
300     fragment => WEBPAGE--M--CHANGE,
301     );}p,
302     );}p,
303     );
304     %block (
305     id => footer,
306     content => {%template (name => ws--footer);}p,
307     );
308     }p,
309     );
310    
311    
312 wakaba 1.1 FormattingRule:
313     @Category[list]:
314     form-input
315     view
316     view-resource
317     @Name: page-list
318     @Description:
319     @@@: WikiPage list
320     @@lang: en
321     @Parameter:
322     @@Name: ns
323     @@Type: WikiName
324     @@Default: (auto)
325     @@Description:
326     @@@@:
327     WikiNamespace name to which listed WikiPages belong
328     @@@lang: en
329     @Formatting:
330     my $list = $p->{-parent}->append_new_node
331     (type => '#element',
332     namespace_uri => $NS_XHTML1,
333     local_name => 'ul');
334    
335     __ATTRTEXT:%ns__;__ATTRTEXT:%recursive__;
336     $p->{recursive} = 1 unless length $p->{recursive};
337 wakaba 1.2 my $ns = $o->{wiki}->name ($p->{ns});
338 wakaba 1.12
339     my @target = sort {$a->[1] cmp $b->[1]}
340     map {[$_, join "\t", @{$_}]} # make sort key
341     $o->{wiki}->{db}->keys ('content',
342     -ns => $ns,
343     -type => 'key',
344     -recursive => $p->{recursive});
345    
346     __ATTRTEXT:%start__;
347     __ATTRTEXT:%n__;
348     my $start = length $p->{start} ? $p->{start} :
349     $o->{wiki}->{input}->parameter ('m--list--range-start') || 0;
350     $p->{n} = $o->{wiki}->{input}->parameter ('m--list--range-number')
351     unless length $p->{n};
352     my $end = $p->{n} ? $start + $p->{n} - 1 : $start + 29;
353     $start = 0 if $start > $#target or $start < 0;
354     $end = $#target if $end < $start or $end > $#target;
355     $end = $start + 255 if $end > $start + 255;
356     local $o->{var}->{search__result} = {
357     min => 0,
358     max => $#target,
359     start => $start,
360     end => $end,
361     number => $p->{n} || 30,
362     query => $p->{query},
363     param_prefix => 'm--list',
364     };
365    
366 wakaba 1.1 __ATTRTEXT:%template__;
367     $p->{template} ||= $WIKIRESOURCE->get
368     (name => 'Link:toWikiPage:SourceLabelLong:PageList',
369     wiki => $o->{wiki}, o => $o);
370 wakaba 1.12
371 wakaba 1.1 __ATTRTEXT:%mode__;
372     try {
373 wakaba 1.12 for (@target[$start..$end]) {
374 wakaba 1.1 $WIKILINKING->to_wikipage_in_html ({
375     label => $p->{template},
376     } => {
377 wakaba 1.2 base => $o->{wiki}->{var}->{page},
378     page_name_relative => $o->{wiki}->name ($_->[0]),
379 wakaba 1.1 wiki_mode => $p->{mode},
380     }, {
381     o => $o,
382 wakaba 1.5 parent => $list->append_new_node
383     (type => '#element',
384     namespace_uri => $NS_XHTML1,
385     local_name => 'li'),
386 wakaba 1.1 });
387     }
388     } catch SuikaWiki::DB::Util::Error with {
389 wakaba 1.4 my $err = shift;
390     $err->throw if $err->{-type} eq 'ERROR_REPORTED';
391 wakaba 1.1 };
392 wakaba 1.12
393     if ($list->count) {
394     $list->set_attribute (start => $start + 1);
395     __ATTRNODE:%post_list->{$p->{-parent}}__;
396     } else {
397     $p->{-parent}->remove_child_node ($list);
398     }
399    
400 wakaba 1.1
401     FormattingRule:
402     @Category[list]:
403     page-link
404     @Name: m--link-weight
405     @Formatting:
406     $p->{-parent}->append_text ($o->{link}->{option}->{-m__weight}+0);
407    
408     ViewFragment:
409     @Name: ws--post-content
410     @Description:
411 wakaba 1.6 @@@: After content body -- children and backward links
412 wakaba 1.1 @@lang:en
413     @Order: 100
414     @Formatting:
415     %section (
416     id => children,
417     title => {%res(name=>{Children:Title});}p, heading,
418     content => {%page-list (
419     ns => {%page-name;}p, recursive => 0,
420     type => both,
421     template => {%resource-as-plain-text (name => {Children:Item});}p,
422 wakaba 1.12 post-list => {%search--result-navigation (
423     fragment => children,
424     );}p,
425 wakaba 1.1 );}p,
426     );
427    
428     ViewFragment:
429     @Name: navbar
430     @Order: 21
431     @Formatting:
432     %link-to-wikipage (
433 wakaba 1.12 page => {%ns--root-wikiname;}p,
434     mode => m--change,
435 wakaba 1.1 label => {%link-to-it (
436 wakaba 1.7 label => {%res (name => GoToRecentChanges);}p,
437     description => {%res (name => GoToRecentChangesLong);}p,
438 wakaba 1.1 );},
439     rel => news,
440     );
441    
442     ViewFragment:
443     @Name: links
444     @Formatting:
445 wakaba 1.13 %m--html-link-navigation;
446    
447 wakaba 1.1 %link-to-wikipage (
448 wakaba 1.12 page => {%ns--root-wikiname;}p,
449 wakaba 1.1 rel => news,
450 wakaba 1.12 mode => m--change,
451 wakaba 1.1 label => {%html-link (
452     description => {%res(name=>GoToRecentChangesLink);}p,
453     );},
454 wakaba 1.7 );
455 wakaba 1.12 %link-to-wikipage (
456     page => {%ns-page-path-name;}p,
457     rel => news,
458     mode => m--change,
459     label => {%html-link (
460     description => {%res(name=> {Map:Change:Link:Parent:Description});}p,
461     );},
462     );
463     %link-to-wikipage (
464     rel => news,
465     mode => m--change,
466     label => {%html-link (
467     description => {%res(name=> {Map:Change:Link:Local:Description});}p,
468     );},
469     );
470 wakaba 1.7
471     Resource:
472 wakaba 1.11 @Children:Title:
473     %link-to-it(label=>{%ns-short-page-name;}p,
474     description=>{%page-name(absolute);}p,
475     );
476     %span(class=>headline, content=>{%page-headline;}p);
477     @Link:toWikiPage:SourceLabelLong:PageList:
478     %link-to-it(
479     label=>{%page-title(relative);}p,
480     description=>{%page-name(absolute);}p,
481     );
482     %span(class=>headline,content=>{%page-headline;}p);
483     @Link:toWikiPage:SourceLabelLong:RecentChangeItem:
484     %last-modified;
485     %link-to-it(
486     label=>{%page-title(relative);}p,
487     description=>{%page-name(absolute);}p,
488     );
489     %span(class=>headline,content=>{%page-headline;}p);
490     @Link:toWikiPage:SourceLabelLong:SearchResult:
491     {%m--link-weight;}
492     %link-to-it(
493     label=>{%page-title(relative);}p,
494     description=>{%page-name(absolute);}p,
495     );
496     %span(class=>headline,content=>{%page-headline;}p);
497 wakaba 1.7 @GoToRecentChanges:
498     @@@: Recent
499     @@lang: en
500     @GoToRecentChangesLink:
501     @@@: Recently modified WikiPages list
502     @@lang: en
503     @GoToRecentChangesLong:
504     @@@: Review recently modified WikiPages list
505     @@lang: en
506 wakaba 1.12 @Map:Change:Link:Local:Description:
507     @@@: List of recently modified WikiPages in this namespace (%page-name;)
508     @@lang: en
509     @Map:Change:Link:Parent:Description:
510     @@@:
511     List of recently modified WikiPages in parent namespace
512     (%ns-page-path-name;)
513     @@lang: en
514     @Map:Change:Title:
515     @@@: Recent Changes
516     @@lang: en
517     @Map:Change:WebPageTitle:
518     @@@: Recent Changes (%page-name;)
519     @@lang: en
520 wakaba 1.13 @Map:LinkNav:prev:Description:
521     @@lang: en
522     @@@: Previous WikiPage
523     @Map:LinkNav:next:Description:
524     @@lang: en
525     @@@: Next WikiPage
526     @Map:LinkNav:contents:Description:
527     @@lang: en
528     @@@: Table of Contents
529     @Map:LinkNav:index:Description:
530     @@lang: en
531     @@@: Index
532     @Map:LinkNav:up:Description:
533     @@lang: en
534     @@@: Up
535    
536    
537 wakaba 1.12
538    
539    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24