/[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.12 - (show annotations) (download)
Thu Apr 1 04:39:58 2004 UTC (21 years, 3 months ago) by wakaba
Branch: MAIN
CVS Tags: release-3-0-0
Branch point for: paragraph-200404
Changes since 1.11: +174 -40 lines
New m--change mode implemented

1 #?SuikaWikiConfig/2.0
2
3 Plugin:
4 @Name: Map
5 @Description:
6 @@@:
7 Visualization of page to page relatinships
8 @@lang:en
9 @License: %%Perl%%
10 @Author:
11 @@Name:
12 @@@@: Wakaba
13 @@@lang:ja
14 @@@script:Latn
15 @@Mail[list]: w@suika.fam.cx
16 @Date.RCS:
17 $Date: 2004/03/20 04:08:11 $
18 @RequiredPlugin[list]:
19 Search
20 WikiLinking
21 WikiNamespace
22 @Use:
23 use Message::Util::Error;
24 my $WIKILINKING;
25 my $WIKIRESOURCE;
26
27 PluginConst:
28 @NS_XHTML1:
29 http://www.w3.org/1999/xhtml
30 @NS_RDF:
31 http://www.w3.org/1999/02/22-rdf-syntax-ns#
32 @NS_RSS:
33 http://purl.org/rss/1.0/
34 @NS_DC:
35 http://purl.org/dc/elements/1.1/
36 @NS_MAP:
37 http://members.jcom.home.ne.jp/jintrick/2003/02/site-concept.xml#
38 @WIKILINKING:
39 {($WIKILINKING ||= SuikaWiki::Plugin->module_package ('WikiLinking'))}
40 @WIKIRESOURCE:
41 {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))}
42
43 FormattingRule:
44 @Category[list]:
45 form-input
46 view
47 view-resource
48 @Name: recent-change-list
49 @Description:
50 @@@: Recently changed WikiPage list
51 @@lang: en
52 @Parameter:
53 @@Name: ns
54 @@Type: WikiName
55 @@Default: (auto)
56 @@Description:
57 @@@@:
58 WikiNamespace name to which listed WikiPages belong
59 @@@lang: en
60 @Formatting:
61 my $list = $p->{-parent}->append_new_node
62 (type => '#element',
63 namespace_uri => $NS_XHTML1,
64 local_name => 'ol');
65 $list->set_attribute (class => 'm--recent-changes');
66
67 __ATTRTEXT:%ns__;__ATTRTEXT:%recursive__;
68 $p->{recursive} = 1 unless length $p->{recursive};
69 my $ns = $o->{wiki}->name ($p->{ns});
70
71 my @target = map { try { [$_, $o->{wiki}->{db}->get (lastmodified => $_)] }
72 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__;
110 $p->{template} ||= $WIKIRESOURCE->get
111 (name => 'Link:toWikiPage:SourceLabelLong:RecentChangeItem',
112 wiki => $o->{wiki}, o => $o);
113 __ATTRTEXT:%mode__;
114
115 for my $target (@target[$start..$end]) {
116 $WIKILINKING->to_wikipage_in_html ({
117 label => $p->{template},
118 } => {
119 base => $o->{wiki}->{var}->{page},
120 page_name_relative => $o->{wiki}->name ($target->[0]),
121 wiki_mode => $p->{mode},
122 _with_lm => 1,
123 page_lastmodified => $target->[1],
124 }, {
125 o => $o,
126 parent => $list->append_new_node
127 (type => '#element',
128 namespace_uri => $NS_XHTML1,
129 local_name => 'li'),
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:
185 @Category[list]:
186 form-input
187 view
188 view-resource
189 @Name: page-list
190 @Description:
191 @@@: WikiPage list
192 @@lang: en
193 @Parameter:
194 @@Name: ns
195 @@Type: WikiName
196 @@Default: (auto)
197 @@Description:
198 @@@@:
199 WikiNamespace name to which listed WikiPages belong
200 @@@lang: en
201 @Formatting:
202 my $list = $p->{-parent}->append_new_node
203 (type => '#element',
204 namespace_uri => $NS_XHTML1,
205 local_name => 'ul');
206
207 __ATTRTEXT:%ns__;__ATTRTEXT:%recursive__;
208 $p->{recursive} = 1 unless length $p->{recursive};
209 my $ns = $o->{wiki}->name ($p->{ns});
210
211 my @target = sort {$a->[1] cmp $b->[1]}
212 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__;
239 $p->{template} ||= $WIKIRESOURCE->get
240 (name => 'Link:toWikiPage:SourceLabelLong:PageList',
241 wiki => $o->{wiki}, o => $o);
242
243 __ATTRTEXT:%mode__;
244 try {
245 for (@target[$start..$end]) {
246 $WIKILINKING->to_wikipage_in_html ({
247 label => $p->{template},
248 } => {
249 base => $o->{wiki}->{var}->{page},
250 page_name_relative => $o->{wiki}->name ($_->[0]),
251 wiki_mode => $p->{mode},
252 }, {
253 o => $o,
254 parent => $list->append_new_node
255 (type => '#element',
256 namespace_uri => $NS_XHTML1,
257 local_name => 'li'),
258 });
259 }
260 } catch SuikaWiki::DB::Util::Error with {
261 my $err = shift;
262 $err->throw if $err->{-type} eq 'ERROR_REPORTED';
263 };
264
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:
274 @Category[list]:
275 page-link
276 @Name: m--link-weight
277 @Formatting:
278 $p->{-parent}->append_text ($o->{link}->{option}->{-m__weight}+0);
279
280 ViewFragment:
281 @Name: ws--post-content
282 @Description:
283 @@@: After content body -- children and backward links
284 @@lang:en
285 @Order: 100
286 @Formatting:
287 %section (
288 id => children,
289 title => {%res(name=>{Children:Title});}p, heading,
290 content => {%page-list (
291 ns => {%page-name;}p, recursive => 0,
292 type => both,
293 template => {%resource-as-plain-text (name => {Children:Item});}p,
294 post-list => {%search--result-navigation (
295 fragment => children,
296 );}p,
297 );}p,
298 );
299
300 ViewFragment:
301 @Name: navbar
302 @Order: 21
303 @Formatting:
304 %link-to-wikipage (
305 page => {%ns--root-wikiname;}p,
306 mode => m--change,
307 label => {%link-to-it (
308 label => {%res (name => GoToRecentChanges);}p,
309 description => {%res (name => GoToRecentChangesLong);}p,
310 );},
311 rel => news,
312 );
313
314 ViewFragment:
315 @Name: links
316 @Formatting:
317 %link-to-wikipage (
318 page => {%ns--root-wikiname;}p,
319 rel => news,
320 mode => m--change,
321 label => {%html-link (
322 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:
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:
368 @@@: Recent
369 @@lang: en
370 @GoToRecentChangesLink:
371 @@@: Recently modified WikiPages list
372 @@lang: en
373 @GoToRecentChangesLong:
374 @@@: Review recently modified WikiPages list
375 @@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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24