/[pub]/suikawiki/script/lib/SuikaWiki/Plugin/Map.wps
Suika

Contents of /suikawiki/script/lib/SuikaWiki/Plugin/Map.wps

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (hide annotations) (download)
Sat Oct 18 07:08:34 2003 UTC (21 years, 6 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.12: +0 -0 lines
FILE REMOVED
Imporoved SuikaWiki 3 implementation

1 wakaba 1.1 Name:
2     Map
3     FullName:
4 wakaba 1.4 Wiki linking and page relation map
5 wakaba 1.1 URI:
6     IW:SuikaWiki:WikiPage
7 wakaba 1.9 Require:
8 w 1.10 SuikaWiki::Markup::XML SuikaWiki::Plugin::WikiPage main SuikaWiki::Plugin::WikiLinking
9 wakaba 1.1 Initialize:
10     my $NS_XHTML1 = 'http://www.w3.org/1999/xhtml';
11     my $NS_RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
12     my $NS_RSS = 'http://purl.org/rss/1.0/';
13     my $NS_DC = 'http://purl.org/dc/elements/1.1/';
14     my $NS_MAP = 'http://members.jcom.home.ne.jp/jintrick/2003/02/site-concept.xml#';
15    
16     {
17     Name:
18     wikiview/link-map
19     FullName:
20     Hyperlink map from the WikiPage
21     Format:
22     my %option = (level => 0+$o->resource('Map:Depth'), weight_list => {},
23     not_exist => {}, map_from_here => $o->resource('Map:FromHere'),
24     map_from_here_description => $o->resource('Map:FromHereLong'),
25     o => $o);
26     &map_make_list ($o->{page}, %option);
27 w 1.10 if (0 && ($o->{media}->{type} =~ /xml/)) { # XML (maybe XHTML)
28 wakaba 1.1 $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_RDF, local_name => 'RDF');
29     $r->define_new_namespace ('' => $NS_MAP);
30     $r->define_new_namespace (rss => $NS_RSS);
31     $r->define_new_namespace (dc => $NS_DC);
32     $r->append_text ("\n");
33     $option{weight_list}->{''}->{$o->{page}} = 1;
34     $r->append_node (map_list_to_xml ('', $option{weight_list}, %option));
35     } else {
36     $r = map_list_to_html ($o->{page}, $option{weight_list}, %option);
37     }
38     }
39    
40     {
41     Name:
42     wikiview/map-children-pages
43     FullName:
44     Children of the WikiPage
45     Format:
46 w 1.10 #if ($o->_database) {
47 wakaba 1.1 $r = SuikaWiki::Markup::XML->new (type => '#document');
48     #$r->append_new_node (type => '#pi', local_name => 'xml')
49     # ->set_attribute (version => '1.0');
50     #$r->append_text ("\n");
51     # stylesheets
52     my $RDF = $r->append_new_node (namespace_uri => $NS_RDF, local_name => 'RDF');
53     $RDF->define_new_namespace ('' => $NS_MAP);
54     $RDF->define_new_namespace (rss => $NS_RSS);
55     $RDF->define_new_namespace (dc => $NS_DC);
56     $RDF->append_text ("\n");
57     $RDF->append_node (rdfmap_make_pageinfo ($o, $p, ($p->{page} || $o->{page})));
58     $RDF->append_text ("\n");
59 w 1.10 #}
60 wakaba 1.1 }
61    
62    
63     {
64     Name:
65 w 1.11 wikiform-input/recent-change-list
66     wikiview/recent-change-list
67 wakaba 1.1 FullName:
68     Recent-changed-pages list
69     Format:
70 wakaba 1.9 #eval q{ # Currently not all database has '->mtime' and '->recent_changes'. Abstracted WikiDatabase system is needed
71 wakaba 1.1 if ($o->{to} eq 'RSS') {
72 wakaba 1.5 $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_RDF, local_name => 'RDF');
73     $r->define_new_namespace (rdf => $NS_RDF);
74     $r->define_new_namespace ('' => $NS_RSS);
75     $r->define_new_namespace (dc => $NS_DC);
76     my $channel = $r->append_new_node (namespace_uri => $NS_RSS, local_name => 'channel');
77     $channel->set_attribute (about => $o->_uri_wiki_page (($o->{page} || $p->{page})), namespace_uri => $NS_RDF);
78     $channel->append_text ("\n");
79     $channel->append_new_node (namespace_uri => $NS_RSS, local_name => 'title')
80     ->append_text ($o->resource ('RSS:WikiTitle'));
81     $channel->append_text ("\n");
82     $channel->append_new_node (namespace_uri => $NS_RSS, local_name => 'link')
83     ->append_text ($o->uri ('wiki'));
84     $channel->append_text ("\n");
85     $channel->append_new_node (namespace_uri => $NS_RSS, local_name => 'description')
86     ->append_text ($o->resource ('RSS:WikiDescription'));
87     $channel->append_text ("\n");
88     $channel->append_new_node (namespace_uri => $NS_DC, local_name => 'date')
89     ->append_text (&main::_rfc3339_date (time));
90     $channel->append_text ("\n");
91     my $items = $channel->append_new_node (namespace_uri => $NS_RSS, local_name => 'items')
92     ->append_new_node (namespace_uri => $NS_RDF, local_name => 'Seq');
93     $p->{ns} .= '//' if $p->{ns} && $p->{ns} !~ m#//$#;
94 w 1.11 for my $page_name ($o->_database->recent_changes (($p->{n} || 10), 0,
95     {ns => $p->{ns},
96     recursive => (defined $p->{recursive} ? $p->{recursive} : 1)})) {
97 wakaba 1.5 next unless $page_name;
98     my $page_uri = $o->_uri_wiki_page ($page_name);
99     $items->append_new_node (namespace_uri => $NS_RDF, local_name => 'li')
100     ->set_attribute (resource => $page_uri, namespace_uri => $NS_RDF);
101     $items->append_text ("\n");
102     $r->append_text ("\n");
103     my $page = $r->append_new_node (namespace_uri => $NS_RSS, local_name => 'item');
104     $page->set_attribute (about => $page_uri, namespace_uri => $NS_RDF);
105     $page->append_text ("\n");
106     $page->append_new_node (namespace_uri => $NS_RSS, local_name => 'title')
107     ->append_text ($page_name);
108     $page->append_text ("\n");
109     $page->append_new_node (namespace_uri => $NS_RSS, local_name => 'link')
110     ->append_text ($page_uri);
111     $page->append_text ("\n");
112     $page->append_new_node (namespace_uri => $NS_RSS, local_name => 'description')
113 wakaba 1.9 ->append_text (SuikaWiki::Plugin::WikiPage->_get_subjectline($page_name, delimiter => ''));
114 wakaba 1.5 $page->append_text ("\n");
115     $page->append_new_node (namespace_uri => $NS_DC, local_name => 'date')
116     ->append_text (&main::_rfc3339_date ($o->_database->mtime ($page_name)));
117     $page->append_text ("\n");
118     }
119     1;
120 wakaba 1.1 } else {
121 w 1.10 $r = SuikaWiki::Markup::XML->new (type => '#element', namespace_uri => $NS_XHTML1,
122     local_name => 'ol');
123     $r->set_attribute (class => 'm--recent-changes');
124 wakaba 1.1 $p->{ns} .= '//' if $p->{ns} && $p->{ns} !~ m#//$#;
125 wakaba 1.12 my $i = 0;
126     for (
127     sort {$b->[1] <=> $a->[1]}
128     map {[$_, $o->get_data (lastmodified => $_)]}
129     $o->db->keys ('content', -Ans => [split m#//#, $p->{ns}], -Atype => 'key',
130     -Arecursive => (defined $p->{recursive} ?
131     $p->{recursive} : 1))) {
132     next unless $_->[0];
133     last if $i++ == ($p->{n} || 10);
134 w 1.10 my $li = $r->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'li');
135     $li->append_node (SuikaWiki::Plugin::WikiLinking->to_wikipage_in_html ({
136     label => ($p->{template}
137     || $o->resource ('Link:toWikiPage:SourceLabelLong:RecentChangeItem')),
138     } => {
139     base => $o->{page},
140 wakaba 1.12 page_name_relative => join ('//', @{$_->[0]}),
141 w 1.10 wiki_mode => $p->{mode},
142 wakaba 1.12 page_lastmodified => $_->[1],
143 w 1.10 }, {
144     o => $o,
145     }));
146 wakaba 1.1 }
147     }
148 wakaba 1.5 1;
149 wakaba 1.9 #} or $r = '<p xmlns="http://www.w3.org/1999/xhtml">Error: '.$o->escape ($@).'</p>';
150 wakaba 1.1 }
151    
152     {
153     Name:
154     wikiview/recent-change-dated
155     FullName:
156     Recent-changed-pages list, grouped by modified date
157     Format:
158     eval q{
159     $r = qq(<div class="recent-changes">\n);
160     my $date = '';
161     $p->{ns} .= '//' if $p->{ns} && $p->{ns} !~ m#//$#;
162     for ($main::database->recent_changes (($p->{n} || 10),0,{ns => $p->{ns}, recursive => (defined $p->{recursive} ? $p->{recursive} : 1)})) {
163     next unless $_;
164     my @date = gmtime $main::database->mtime ($_);
165     my $ndate = sprintf '%04d-%02d-%02d', $date[5]+1900,$date[4]+1,$date[3];
166     if ($ndate ne $date) {
167     $r .= "</ol>\n" if $date;
168     my $id = 'h'.$o->new_index ('heading');
169     my $level = $p->{level}+0||1;
170     $r .= qq(<h$level id="$id">$ndate</h$level>\n<ol>\n);
171     push @{$o->{toc}}, [$level-1 => $id => $ndate] if !defined $p->{add_to_toc} || $p->{add_to_toc};
172     $date = $ndate;
173     }
174     $date[0] = sprintf '%s %02d:%02d:%02d+00:00', $ndate, @date[2,1,0];
175 wakaba 1.9 $r .= qq(<li><a href="@{[$o->uri('wiki')]}?@{[$o->encode($_)]}" class="wiki" title="@{[$o->escape (SuikaWiki::Plugin::WikiPage->_get_subjectline ($_,delimiter=>''))]} [$date[0]]">) . $o->escape ($_) . qq(</a></li>\n);
176 wakaba 1.1 }
177     $r .= '</ol></div>';
178     } or $r = $o->escape($@);
179     }
180     {
181     Name:
182     wikiform_input/recent-change-dated
183     FullName:
184     Recent-changed-pages list, grouped by modified date
185     Format:
186     eval q{
187     $r = qq(<div class="recent-changes">\n);
188     my $date = '';
189     $p->{ns} .= '//' if $p->{ns} && $p->{ns} !~ m#//$#;
190     for ($main::database->recent_changes (($p->{n} || 10),0,{ns => $p->{ns}, recursive => (defined $p->{recursive} ? $p->{recursive} : 1)})) {
191     next unless $_;
192     my @date = gmtime $main::database->mtime ($_);
193     my $ndate = sprintf '%04d-%02d-%02d', $date[5]+1900,$date[4]+1,$date[3];
194     if ($ndate ne $date) {
195     $r .= "</ol>\n" if $date;
196     my $id = 'h'.$o->new_index ('heading');
197     my $level = ($p->{level}+0||1)+1;
198     $r .= qq(<h$level id="$id">$ndate</h$level>\n<ol>\n);
199     push @{$o->{toc}}, [$level-1 => $id => $ndate] if !defined $p->{add_to_toc} || $p->{add_to_toc};
200     $date = $ndate;
201     }
202     $date[0] = sprintf '%s %02d:%02d:%02d+00:00', $ndate, @date[2,1,0];
203     $r .= qq(<li><a href="@{[$o->uri('wiki')]}?@{[$o->encode($_)]}" class="wiki" title="@{[$o->escape($_)]} [$date[0]]">) . $o->escape ($_) . qq(</a></li>\n);
204     }
205     $r .= '</ol></div>';
206     } or $r = $o->escape($@);
207     }
208    
209     {
210     Name:
211 wakaba 1.8 wikiform-input/page-list
212 wakaba 1.1 wikiview/page-list
213     FullName:
214     WikiPage list
215     Format:
216 wakaba 1.8 #eval q{
217     my $re = $p->{match} || '.'; ## WARNING: This can be dangerous!
218     $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'ul');
219 wakaba 1.1 if ($o->_database) {
220 wakaba 1.8 $p->{ns} .= '//' if $p->{ns} && substr ($p->{ns}, -2) ne '//';
221     my %outputed;
222 wakaba 1.1 for (sort grep /$re/, $o->_database->list_items ({ns => $p->{ns}, type => ($p->{type}||'key'), recursive => $p->{recursive}})) {
223 wakaba 1.8 s!//$!!;
224     $outputed{$_} ? next : ($outputed{$_} = 1);
225     my $li = $r->append_new_node (namespace_uri => $NS_XHTML1, local_name => 'li');
226     $li->append_node (SuikaWiki::Plugin::WikiLinking->to_wikipage_in_html ({
227     label => ($p->{template} || $o->resource ('Link:toWikiPage:SourceLabelLong')),
228     } => {
229     base => $o->{page},
230     page_name_relative => $_,
231     #page_anchor_no => $,
232     wiki_mode => $p->{mode},
233     }, {
234     o => $o,
235     }));
236 wakaba 1.1 }
237     }
238 wakaba 1.8 if ($r->count) {
239     $r->set_attribute (class => 'pages');
240     } else {
241     $r = '';
242     }
243     #} or $r = qq(<div class="error">@{[$o->escape ($@)]}</div>);
244 wakaba 1.1 }
245    
246     {
247     Name:
248     wikiformat/SuikaWiki/0.9-to-RSS
249     FullName:
250     SuikaWiki/0.9 document format -> RSS
251     URI:
252     IW:SuikaWiki:SuikaWiki
253     Format:
254     $o->{content} =~ s($main::embed_command{form}){
255     my $i = $2;
256     $i =~ s/\\(.)/$1/gs;
257     if ($i =~ /(%recent-change-list(?:\((?:[^)]|\\.)*\))?;)/s) {
258     $r = $o->formatter ('form_input')->replace ($1 => $o);
259     return $r;
260     }
261     ''}ge;
262     $r = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>';
263     }
264    
265 wakaba 1.5 {
266     Name:
267     wikiview/map-link-alternate-version-xml-rdf-rss
268     FullName:
269     Linking alternate version -- RSS 1.0 format
270     Format:
271 w 1.10 if ($main::database{$o->{page} || $p->{page}} =~ /%recent-change-list/) {
272 wakaba 1.5 $r = SuikaWiki::Markup::XML->new (namespace_uri => $NS_XHTML1, local_name => 'link');
273     $r->set_attribute (rel => 'alternate');
274     $r->set_attribute (type => 'application/rss+xml');
275     $r->set_attribute (href => $o->_uri_wiki_page (($o->{page} || $p->{page}), mode => 'rss'));
276     $r->set_attribute (title => $o->resource ('Map:Link:Alternate:RSS:Long'));
277     }
278     }
279 wakaba 1.1
280     MODULE:
281     SuikaWiki::View->definition (rss => {
282     media => {type => 'application/rss+xml',
283 wakaba 1.2 expires => 3600, charset => 1},
284     check => sub { ref $_[0]->format_converter ($_[0]->{magic} => 'RSS') ? 1 : 0 },
285     template => '%styles-wiki-xml(page=>"'.$main::PageName{StyleList}.'XML//RDF//RSS");
286 wakaba 1.1 %read(to=>RSS);'});
287     SuikaWiki::View->definition (m_xml_rdf_sitemap => {
288     media => {type => 'application/rdf+xml',
289     expires => 3600, charset => 1},
290     template => '%styles-wiki-xml(page=>"'.$main::PageName{StyleList}.'XML//RDF//Sitemap");
291     %map-children-pages;'});
292 wakaba 1.3 SuikaWiki::View->template ('links')->add_line (<<EOH);
293     %link-wiki(rel=>sitemap,mode=>m-xml-rdf-sitemap,class=>wiki,type=>"application/rdf+xml",title=>{%res(name=>{Nav:Sitemap:Children:Title});}p);
294 wakaba 1.2 %link-wiki(mode=>map,rel=>sitemap,class=>wiki-cmd,title=>"%res(name=>ShowMapOfThisPageLink);"p);
295 w 1.11 %link-wiki(page=>{@{[$main::PageName{IndexPage}]}},rel=>index,class=>wiki,title=>"%res(name=>GoToIndexPageLink,safe);"p);
296     %link-wiki(page=>{@{[$main::PageName{RecentChanges}]}},rel=>News,class=>wiki,title=>"%res(name=>GoToRecentChangesLink);"p);
297     %link-wiki(page=>{%page-name;}p,rel=>news,class=>wiki,mode=>m--recent-changes,title=>"%res(name=>{Map:RecentChanges:LinkTo:Description});"p);
298 wakaba 1.3 %link-wiki(page=>@{[$main::PageName{RecentChanges}]},mode=>rss,rel=>News,class=>wiki,title=>"%res(name=>GoToRssPageLink);"p,type=>"application/rss+xml");
299 wakaba 1.5 %map-link-alternate-version-xml-rdf-rss();
300 wakaba 1.3 EOH
301 wakaba 1.1
302     sub rdfmap_make_pageinfo ($$$) {
303     my ($o, $p, $page) = @_;
304     my $re = $p->{match} || '.';
305     my $c = new SuikaWiki::Markup::XML (namespace_uri => $NS_MAP, local_name => 'Document');
306     $c->append_new_node (namespace_uri => $NS_DC, local_name => 'title')
307     ->append_text ($page);
308     $c->append_new_node (namespace_uri => $NS_RSS, local_name => 'description')
309 wakaba 1.9 ->append_text (SuikaWiki::Plugin::WikiPage->_get_subjectline ($page, delimiter => ''));
310 wakaba 1.1 my @date = gmtime $main::database->mtime ($page);
311     $c->append_new_node (namespace_uri => $NS_DC, local_name => 'date')
312     ->append_text (sprintf '%04d-%02d-%02d %02d:%02d:%02d+00:00', $date[5]+1900,$date[4]+1,@date[3,2,1,0]);
313     $c->set_attribute (about => $o->uri ('wiki').'?'.$o->encode($page), namespace_uri => $NS_RDF);
314     my %children;
315     map {s!\Q$SuikaWiki::Name::Space::Delimiter\E$!!; $children{$_} = 1} grep /$re/, $o->_database->list_items ({ns => $page.'//', type => ('both'), recursive => 0});
316     if (scalar (keys %children)) {
317     my $c = $c->append_new_node (namespace_uri => $NS_RSS, local_name => 'items')
318     ->append_new_node (namespace_uri => $NS_RDF, local_name => 'Bag');
319     for (sort keys %children) {
320     $c->append_new_node (namespace_uri => $NS_RDF, local_name => 'li')
321     ->append_node (rdfmap_make_pageinfo ($o, $p, $_));
322     }
323     }
324     $c;
325     }
326    
327     sub map_make_list ($;%) {
328     my ($page, %option) = @_;
329     $option{level} ||= 3;
330     my %weight;
331     my $content = $main::database{$page};
332     $content =~ s{^\#\?([^\x0A\x0D]+)}{
333     if ($1 =~ /import="([^"]+)"/) {
334     for (split /\s*,\s*/, $1) {
335     $weight{$_} += 2;
336     }
337     }
338 wakaba 1.8 '';
339     }es;
340 wakaba 1.1 ## Bug: this code does not support content type.
341 wakaba 1.8 $content =~ s{\[\[([^\#\]]+)\](?:>>\d+)?\]}{
342     $weight{$1} += 2; '';
343 wakaba 1.1 }ge;
344     delete $weight{$page}; ## Delete myself
345     for my $page (keys %weight) {
346 wakaba 1.8 $weight{$page} += ($content =~ s/\Q$page\E//g);
347 wakaba 1.1 ($weight{$page} *= 0.1, $option{not_exist}->{$page} = 1) unless exists $main::database {$page};
348     }
349     $option{weight_list}->{$page} = \%weight;
350     if (--$option{level}) {
351     for my $page (keys %weight) {
352     &map_make_list ($page, %option) unless $option{weight_list}->{$page};
353     }
354     }
355     $option{weight_list};
356     }
357    
358     sub map_list_to_html ($$;%) {
359     my ($Page, $wlist, %option) = @_;
360    
361     my $o = $option{o};
362     if ($o->feature ('SuikaWiki::Markup::XML')) {
363     my $r = SuikaWiki::Markup::XML->new (local_name => 'ul', namespace_uri => $NS_XHTML1);
364     $option{outputed}->{$Page} = 1;
365     for my $page (sort {$wlist->{$Page}->{$b} <=> $wlist->{$Page}->{$a}} keys %{$wlist->{$Page}}) {
366     for my $LI ($r->append_new_node (local_name => 'li', namespace_uri => $NS_XHTML1)) {
367     for my $weight ($LI->append_new_node (local_name => 'span', namespace_uri => $NS_XHTML1)) {
368     $weight->set_attribute (class => 'weight');
369     $weight->append_text ('{' . (0+$wlist->{$Page}->{$page}) . '}');
370     }
371     $LI->append_text (' ');
372     for my $A ($LI->append_new_node (local_name => 'a', namespace_uri => $NS_XHTML1)) {
373     $A->set_attribute (href => $o->uri('wiki').'?'.$o->encode($page));
374     $A->append_text ($page);
375     my $CLASS = $A->set_attribute (class => 'wiki');
376     if ($option{not_exist}->{$page}) {
377     $CLASS->append_text (' not-exist');
378     for my $mark ($A->append_new_node (local_name => 'span', namespace_uri => $NS_XHTML1)) {
379     $mark->set_attribute (class => 'mark');
380     $mark->append_text ($o->resource('JumpAndEditWikiPageMark'));
381     }
382     }
383     }
384     $LI->append_text (' ');
385     for my $A ($LI->append_new_node (local_name => 'a', namespace_uri => $NS_XHTML1)) {
386     $A->set_attribute (href => $o->uri('wiki').'?mycmd=map;mypage='.$o->encode($page));
387     $A->set_attribute (class => 'wiki-cmd map-from-here');
388     $A->set_attribute (title => $option{map_from_here_description});
389     $A->append_text ($option{map_from_here});
390     }
391     $LI->append_text (' ');
392     for my $hl ($LI->append_new_node (local_name => 'span', namespace_uri => $NS_XHTML1)) {
393     $hl->set_attribute (class => 'headline');
394 wakaba 1.9 $hl->append_text (SuikaWiki::Plugin::WikiPage->_get_subjectline($page));
395 wakaba 1.1 }
396     unless ($option{outputed}->{$page}) { ## child
397     my $c = &map_list_to_html ($page, $wlist, %option);
398     $LI->append_text ("\n");
399     if (ref ($c) eq ref ($LI)) {
400     $LI->append_node ($c);
401     } elsif ($c) {
402     $LI->append_new_node (type => '#xml', value => $c);
403     }
404     }
405     } # LI
406     }
407     return $r->count ? $r : '';
408     } else {
409    
410     my $r = '';
411     $option{outputed}->{$Page} = 1;
412     for my $page (sort {$wlist->{$Page}->{$b} <=> $wlist->{$Page}->{$a}} keys %{$wlist->{$Page}}) {
413 w 1.10 $r .= qq(<li><span class="weight">[@{[0+$wlist->{$Page}->{$page}]}]</span> <a href="$main::url_cgi?@{[$o->encode($page)]}" class="wiki@{[$option{not_exist}->{$page}?' not-exist':'']}">@{[$o->escape ($page).($option{not_exist}->{$page}?qq(<span class="mark">@{[$o->resource('JumpAndEditWikiPageMark',escape=>1)]}</span>):'')]}</a> <a href="$main::url_cgi?mycmd=map;mypage=@{[$o->encode($page)]}" class="wiki-cmd map-from-here" title="@{[$o->escape($option{map_from_here_description})]}">@{[$o->escape($option{map_from_here})]}</a> <span class="summary">@{[$o->escape(SuikaWiki::Plugin::WikiPage->_get_subjectline($page))]}</span>);
414 wakaba 1.1 unless ($option{outputed}->{$page}) {
415     $r .= &map_list_to_html ($page, $wlist, %option);
416     }
417     $r .= "</li>\n";
418     }
419     return $r ? qq(<ul class="map">$r</ul>) : '';
420    
421     }
422    
423     }
424    
425     sub map_list_to_xml ($$;%) {
426     my ($Page, $wlist, %option) = @_;
427     my $o = $option{o};
428    
429     my $r = SuikaWiki::Markup::XML->new (type => '#fragment');
430     $option{outputed}->{$Page} = 1;
431     for my $page (sort {$wlist->{$Page}->{$b} <=> $wlist->{$Page}->{$a}} keys %{$wlist->{$Page}}) {
432     for my $D ($r->append_new_node (local_name => 'Document', namespace_uri => $NS_MAP)) {
433     $D->set_attribute (about => $o->uri('wiki').'?'.$o->encode($page), namespace_uri => $NS_RDF);
434     #for my $weight ($D->append_new_node (local_name => 'span', namespace_uri => $NS_XHTML1)) {
435     # $weight->set_attribute (class => 'weight');
436     # $weight->append_text ('{' . (0+$wlist->{$Page}->{$page}) . '}');
437     #}
438     #$D->append_text ("\n");
439     $D->append_new_node (local_name => 'title', namespace_uri => $NS_DC)
440     ->append_text ($page);
441     #if ($option{not_exist}->{$page}) {
442     # $CLASS->append_text (' not-exist');
443     #}
444     $D->append_text ("\n");
445     $D->append_new_node (local_name => 'description', namespace_uri => $NS_RSS)
446 wakaba 1.9 ->append_text (SuikaWiki::Plugin::WikiPage->_get_subjectline($page));
447 wakaba 1.1 unless ($option{outputed}->{$page}) { ## child
448     my $c = &map_list_to_xml ($page, $wlist, %option);
449     if (ref $c) {
450     $D->append_text ("\n");
451     my $B = $D->append_new_node (local_name => 'items', namespace_uri => $NS_RSS)
452     ->append_new_node (local_name => 'Bag', namespace_uri => $NS_RDF);
453     for (@{$c->child_nodes}) {
454     $B->append_new_node (local_name => 'li', namespace_uri => $NS_RDF)
455     ->append_node ($_);
456     $B->append_text ("\n");
457     }
458     }
459     }
460     } # LI
461     }
462     return $r->count ? $r : '';
463     }
464    
465 wakaba 1.2 SuikaWiki::View->definition (map => {
466 w 1.11 media => {type => 'text/html', charset => 1, expires => 60},
467     xmedia => {type => 'application/xhtml+xml', charset => 1, expires => 60},
468 wakaba 1.2 template => <<'EOH'});
469 w 1.11 %html-document(title=>{%res(name=>{Map:WebPageTitle});}p,link-meta=>{%predefined-template(name=>links);}p,content=>{
470 wakaba 1.2 %section(level=>1,add-to-toc=>0,type=>body,title=>{%ns-short-page-name;}p,heading,content=>{
471     %section(id=>tools1,class=>tools,add-to-toc=>0,content=>{%predefined-template(name=>navbar);}p);
472 w 1.11 %section(level=>2,id=>link-map,title=>{%res(name=>{Map:Title});}p,heading,content=>{
473 wakaba 1.2 %paragraph(content=>{%res(name=>{Map:Description});}p);
474     %link-map;
475     }p);
476     %section(level=>2,id=>children,title=>{%res(name=>{Children:Title});}p,heading,
477 wakaba 1.8 content=>{%page-list(ns=>{%page-name;}p,recursive=>0,type=>both,template=>{%res(name=>{Children:Item});}p);}p);
478 wakaba 1.2 %section(level=>2,id=>see-also,title=>{%res(name=>SeeAlso);}p,heading,content=>{%search-result;}p);
479     %section(level=>2,id=>referer,title=>{%res(name=>Referer);}p,heading,content=>{%referer-list;}p);
480 w 1.11 %section(level=>2,id=>toc,title=>{%res(name=>{TOC:Title});}p,heading,add_to_toc=>0,content=>{%toc(drag);}p);
481     %section(id=>last-modified,add-to-toc=>0,content=>{%res(name=>{LastModified=});%last-modified;}p);
482     %section(class=>tools,add-to-toc=>0,content=>{%predefined-template(name=>navbar);}p);
483     %section(id=>footer,add-to-toc=>0,content=>{%predefined-template(name=>footer);}p);
484     %apply-user-preferred-style;
485     }p);
486     }p);
487     EOH
488    
489     SuikaWiki::View->definition (m__recent_changes => {
490     media => {type => 'text/html', charset => 1, expires => 120},
491     xmedia => {type => 'application/xhtml+xml', charset => 1, expires => 120},
492     template => <<'EOH'});
493     %html-document(title=>{%res(name=>{Map:RecentChanges:WebPageTitle});}p,
494     link-meta=>{%predefined-template(name=>links);}p,
495     content=>{
496     %section(level=>1,add-to-toc=>0,type=>body,title=>{%ns-short-page-name;}p,heading,content=>{
497     %section(id=>tools1,class=>tools,add-to-toc=>0,
498     content=>{%predefined-template(name=>navbar);}p);
499     %section(level=>2,id=>link-map,title=>{%res(name=>{Map:RecentChanges:Title});}p,heading,
500     content=>{
501     %paragraph(content=>{%res(name=>{Map:RecentChanges:Description});}p);
502     %recent-change-list(n=>50,ns=>{%page-name;}p,recursive);
503     }p);
504     %section(level=>2,id=>toc,title=>{%res(name=>{TOC:Title});}p,heading,add_to_toc=>0,
505     content=>{%toc(drag);}p);
506     %section(class=>tools,add-to-toc=>0,content=>{%predefined-template(name=>navbar);}p);
507 wakaba 1.2 %section(id=>footer,add-to-toc=>0,content=>{%predefined-template(name=>footer);}p);
508     %apply-user-preferred-style;
509     }p);
510     }p);
511     EOH
512 wakaba 1.4
513 wakaba 1.1
514 wakaba 1.6 POD:SEE ALSO:
515 wakaba 1.7 SuikaWiki::Plugin::Referer, SuikaWiki::Plugin::WikiPage,
516 w 1.11 SuikaWiki::Plugin::InterWikiCore, SuikaWiki::Plugin::WikiLinking
517 wakaba 1.1 POD:LICENSE:
518     Copyright 2003 Wakaba <w@suika.fam.cx>
519    
520     %%GNUGPL2%%

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24