1 |
w |
1.1 |
Name: |
2 |
|
|
WikiPage |
3 |
|
|
FullName: |
4 |
|
|
Getting WikiPage information |
5 |
|
|
URI: |
6 |
|
|
IW:SuikaWiki:WikiAdmin |
7 |
|
|
|
8 |
|
|
{ |
9 |
|
|
Name: |
10 |
|
|
wikiform_input/recent-change-list |
11 |
|
|
FullName: |
12 |
|
|
Recent-changed-pages list |
13 |
|
|
Format: |
14 |
|
|
eval q{ |
15 |
w |
1.3 |
if ($o->{to} eq 'RSS') { |
16 |
|
|
require Yuki::RSS; |
17 |
|
|
my $rss = new Yuki::RSS (version => '1.0'); |
18 |
|
|
my $myuri = $o->uri ('wiki'); |
19 |
|
|
$rss->stylesheet ( |
20 |
|
|
href => $myuri . "?mycmd=css;mypage=WikiStyle:RSS", |
21 |
|
|
type => 'text/css', |
22 |
|
|
); |
23 |
|
|
$rss->channel( |
24 |
|
|
title => $o->resource ('RSS:WikiTitle'), |
25 |
|
|
link => $myuri, |
26 |
|
|
description => $o->resource ('RSS:WikiDescription'), |
27 |
|
|
'dc:language' => $main::lang, |
28 |
|
|
); |
29 |
|
|
for my $title ($main::database->recent_changes ($p->{n} || 10)) { |
30 |
|
|
next unless $title; |
31 |
|
|
$rss->add_item ( |
32 |
|
|
title => $o->escape ($title), |
33 |
|
|
link => $myuri . '?' . $o->encode ($title), |
34 |
|
|
description => $o->escape(&main::get_subjectline($title,delimiter=>'')), |
35 |
|
|
'dc:date' => $main::database->mtime ($title), |
36 |
|
|
); |
37 |
|
|
} |
38 |
|
|
$r = $rss->as_string; |
39 |
|
|
} else { |
40 |
|
|
$r = qq(<ol class="recent-changes">\n); |
41 |
|
|
for ($main::database->recent_changes ($p->{n} || 10)) { |
42 |
|
|
next unless $_; |
43 |
|
|
my @date = gmtime $main::database->mtime ($_); |
44 |
|
|
$date[0] = sprintf '%04d-%02d-%02d %02d:%02d:%02d+00:00', $date[5]+1900,$date[4]+1,@date[3,2,1,0]; |
45 |
|
|
$r .= qq(<li><span class="date">$date[0]</span> <a href="@{[$o->uri('wiki')]}?@{[$o->encode($_)]}" class="wiki">) . $o->escape ($_) . qq(</a>); |
46 |
|
|
$r .= ' <span class="summary">'.$o->escape (&main::get_subjectline ($_)).'</span>' if $p->{summary}; |
47 |
|
|
$r .= qq(</li>\n); |
48 |
|
|
} |
49 |
|
|
$r .= '</ol>'; |
50 |
w |
1.1 |
} |
51 |
|
|
} or $r = ''; |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
{ |
55 |
|
|
Name: |
56 |
w |
1.4 |
wikiview/recent-change-dated |
57 |
|
|
FullName: |
58 |
|
|
Recent-changed-pages list, grouped by modified date |
59 |
|
|
Format: |
60 |
|
|
eval q{ |
61 |
|
|
$r = qq(<div class="recent-changes">\n); |
62 |
|
|
my $date = ''; |
63 |
|
|
for ($main::database->recent_changes ($p->{n} || 10)) { |
64 |
|
|
next unless $_; |
65 |
|
|
my @date = gmtime $main::database->mtime ($_); |
66 |
|
|
my $ndate = sprintf '%04d-%02d-%02d', $date[5]+1900,$date[4]+1,$date[3]; |
67 |
|
|
if ($ndate ne $date) { |
68 |
|
|
$r .= "</ol>\n" if $date; |
69 |
|
|
my $id = 'h'.$o->new_index ('heading'); |
70 |
|
|
my $level = $p->{level}+0||1; |
71 |
|
|
$r .= qq(<h$level id="$id">$ndate</h$level>\n<ol>\n); |
72 |
|
|
push @{$o->{toc}}, [$level-1 => $id => $ndate] if !defined $p->{add_to_toc} || $p->{add_to_toc}; |
73 |
|
|
$date = $ndate; |
74 |
|
|
} |
75 |
|
|
$date[0] = sprintf '%s %02d:%02d:%02d+00:00', $ndate, @date[2,1,0]; |
76 |
|
|
$r .= qq(<li><a href="@{[$o->uri('wiki')]}?@{[$o->encode($_)]}" class="wiki" title="@{[$o->escape (&main::get_subjectline ($_,delimiter=>''))]} [$date[0]]">) . $o->escape ($_) . qq(</a></li>\n); |
77 |
|
|
} |
78 |
|
|
$r .= '</ol></div>'; |
79 |
|
|
} or $r = $o->escape($@); |
80 |
|
|
} |
81 |
|
|
{ |
82 |
|
|
Name: |
83 |
|
|
wikiform_input/recent-change-dated |
84 |
|
|
FullName: |
85 |
|
|
Recent-changed-pages list, grouped by modified date |
86 |
|
|
Format: |
87 |
|
|
eval q{ |
88 |
|
|
$r = qq(<div class="recent-changes">\n); |
89 |
|
|
my $date = ''; |
90 |
|
|
for ($main::database->recent_changes ($p->{n} || 10)) { |
91 |
|
|
next unless $_; |
92 |
|
|
my @date = gmtime $main::database->mtime ($_); |
93 |
|
|
my $ndate = sprintf '%04d-%02d-%02d', $date[5]+1900,$date[4]+1,$date[3]; |
94 |
|
|
if ($ndate ne $date) { |
95 |
|
|
$r .= "</ol>\n" if $date; |
96 |
|
|
my $id = 'h'.$o->new_index ('heading'); |
97 |
|
|
my $level = ($p->{level}+0||1)+1; |
98 |
|
|
$r .= qq(<h$level id="$id">$ndate</h$level>\n<ol>\n); |
99 |
|
|
push @{$o->{toc}}, [$level-1 => $id => $ndate] if !defined $p->{add_to_toc} || $p->{add_to_toc}; |
100 |
|
|
$date = $ndate; |
101 |
|
|
} |
102 |
|
|
$date[0] = sprintf '%s %02d:%02d:%02d+00:00', $ndate, @date[2,1,0]; |
103 |
|
|
$r .= qq(<li><a href="@{[$o->uri('wiki')]}?@{[$o->encode($_)]}" class="wiki" title="@{[$o->escape($_)]} [$date[0]]">) . $o->escape ($_) . qq(</a></li>\n); |
104 |
|
|
} |
105 |
|
|
$r .= '</ol></div>'; |
106 |
|
|
} or $r = $o->escape($@); |
107 |
|
|
} |
108 |
|
|
|
109 |
|
|
{ |
110 |
|
|
Name: |
111 |
w |
1.1 |
wikiform_input/page-list |
112 |
|
|
FullName: |
113 |
|
|
WikiPage list |
114 |
|
|
Format: |
115 |
|
|
eval q{ |
116 |
|
|
$r = qq(<ul class="pages">\n); |
117 |
|
|
my $re = $p->{match} || '.'; |
118 |
|
|
for (grep /$re/, keys %main::database) { |
119 |
w |
1.2 |
$r .= qq(<li><a href="@{[$o->uri('wiki')]}?@{[$o->encode($_)]}" class="wiki">) . $o->escape ($_) . qq(</a>); |
120 |
w |
1.1 |
$r .= ' <span class="summary">'.$o->escape (&main::get_subjectline ($_)).'</span>' if $p->{summary}; |
121 |
|
|
$r .= qq(</li>\n); |
122 |
|
|
} |
123 |
|
|
$r .= '</ul>'; |
124 |
|
|
} or $r = ''; |
125 |
w |
1.3 |
} |
126 |
|
|
|
127 |
|
|
{ |
128 |
|
|
Name: |
129 |
|
|
wikiformat/SuikaWiki/0.9-to-RSS |
130 |
|
|
FullName: |
131 |
|
|
SuikaWiki/0.9 document format -> RSS |
132 |
|
|
URI: |
133 |
|
|
IW:SuikaWiki:SuikaWiki |
134 |
|
|
Format: |
135 |
|
|
$o->{content} =~ s($main::embed_command{form}){ |
136 |
|
|
my $i = $2; |
137 |
|
|
$i =~ s/\\(.)/$1/gs; |
138 |
|
|
if ($i =~ /(%recent-change-list(?:\((?:[^)]|\\.)*\))?;)/s) { |
139 |
|
|
$r = $o->formatter ('form_input')->replace ($1 => $o); |
140 |
|
|
return $r; |
141 |
|
|
} |
142 |
|
|
''}ge; |
143 |
|
|
$r = '<?xml version="1.0"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>'; |
144 |
w |
1.4 |
} |
145 |
|
|
|
146 |
|
|
{ |
147 |
|
|
Name: |
148 |
|
|
wikiview/search-result |
149 |
|
|
FullName: |
150 |
|
|
Search result of given page name |
151 |
|
|
Format: |
152 |
|
|
($r) = main::get_search_result ($o->{page}); |
153 |
|
|
} |
154 |
|
|
|
155 |
|
|
{ |
156 |
|
|
Name: |
157 |
|
|
wikiform_input/search-result |
158 |
|
|
FullName: |
159 |
|
|
Search result with the given string |
160 |
|
|
Format: |
161 |
|
|
my $word = $p->{case_sensible} ? $p->{key} : lc $p->{key}; |
162 |
|
|
my @r; |
163 |
|
|
my $sr = $o->cache ('search'); |
164 |
|
|
unless (defined $sr->{$word}) { |
165 |
|
|
for my $page (keys %main::database) { |
166 |
|
|
my ($magic, $content) = $o->magic_and_content ($main::database{$page}); |
167 |
|
|
$content = $p->{case_sensible} ? $content : lc $content; |
168 |
|
|
$content =~ s/^[^\x0A\x0D]+[\x0D\x0A]+//s; |
169 |
|
|
if (index (lc $page, $word) > -1) { |
170 |
|
|
my $c = $content =~ s/\Q$word\E//g; |
171 |
|
|
push @r, [$page, $c+20]; |
172 |
|
|
} elsif (index ($word, lc $page) > -1) { |
173 |
|
|
my $c = $content =~ s/\Q$word\E//g; |
174 |
|
|
push @r, [$page, $c+10]; |
175 |
|
|
} elsif (my $c = $content =~ s/\Q$word\E//g) { |
176 |
|
|
push @r, [$page, $c]; |
177 |
|
|
} |
178 |
|
|
} |
179 |
|
|
@r = sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r; |
180 |
|
|
$sr->{$word} = join "\x1E", map {$_->[0]."\x1F".$_->[1]} @r; |
181 |
|
|
} else { |
182 |
|
|
@r = map {[split /\x1F/, $_, 2]} split /\x1E/, $sr->{$word}; |
183 |
|
|
} |
184 |
|
|
my $em = $p->{em} ? sub { my $s = shift; $s =~ s#(\Q$word\E)#<em>$1</em>#gi; $s } : sub {$_[0]}; |
185 |
|
|
$r = join "\n", map {qq(<li>[$_->[1]] <a href ="@{[$o->uri('wiki').'?'.$o->encode($_->[0])]}" class="wiki">@{[&$em($o->escape($_->[0]))]}</a> <span class="headline">@{[&$em($o->escape(&main::get_subjectline($_->[0])))]}</span></li>)} @r; |
186 |
|
|
$r = qq|<ul class="search-result">$r</ul>| if $r; |
187 |
|
|
} |
188 |
|
|
|
189 |
|
|
{ |
190 |
|
|
Name: |
191 |
|
|
wikiview/link-map |
192 |
|
|
FullName: |
193 |
|
|
Hyperlink map from the WikiPage |
194 |
|
|
Format: |
195 |
|
|
sub make_list ($;%) { |
196 |
|
|
my ($page, %option) = @_; |
197 |
|
|
$option{level} ||= 3; |
198 |
|
|
my %weight; |
199 |
|
|
my $content = $main::database{$page}; |
200 |
|
|
$content =~ s{^\#\?([^\x0A\x0D]+)}{ |
201 |
|
|
if ($1 =~ /import="([^"]+)"/) { |
202 |
|
|
for (split /\s*,\s*/, $1) { |
203 |
|
|
$weight{$_} += 2; |
204 |
|
|
} |
205 |
|
|
} |
206 |
|
|
$&; |
207 |
|
|
}ges; |
208 |
|
|
## Bug: this code does not support content type. |
209 |
|
|
$content =~ s{\[\[((?!\#)[^]]+)\](?:>>\d+)?\]}{ |
210 |
|
|
$weight{$1}++; $&; |
211 |
|
|
}ge; |
212 |
|
|
delete $weight{$page}; ## Delete myself |
213 |
|
|
for my $page (keys %weight) { |
214 |
|
|
my $w = ($content =~ s/\Q$page\E/$&/g); |
215 |
|
|
$weight{$page} += $w + $weight{$page}; ## Weight of [[name]] is x2. |
216 |
w |
1.5 |
($weight{$page} *= 0.1, $option{not_exist}->{$page} = 1) unless exists $main::database {$page}; |
217 |
w |
1.4 |
} |
218 |
|
|
$option{weight_list}->{$page} = \%weight; |
219 |
|
|
if (--$option{level}) { |
220 |
|
|
for my $page (keys %weight) { |
221 |
|
|
&make_list ($page, %option) unless $option{weight_list}->{$page}; |
222 |
|
|
} |
223 |
|
|
} |
224 |
|
|
$option{weight_list}; |
225 |
|
|
} |
226 |
|
|
|
227 |
|
|
sub list_to_html ($$;%) { |
228 |
|
|
my ($Page, $wlist, %option) = @_; |
229 |
|
|
my $r = ''; |
230 |
|
|
$option{outputed}->{$Page} = 1; |
231 |
|
|
for my $page (sort {$wlist->{$Page}->{$b} <=> $wlist->{$Page}->{$a}} keys %{$wlist->{$Page}}) { |
232 |
|
|
$r .= qq(<li><span class="weight">[@{[0+$wlist->{$Page}->{$page}]}]</span> <a href="$main::url_cgi?@{[&main::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=@{[&main::encode($page)]}" class="wiki-cmd map-from-here" title="@{[&main::escape($option{map_from_here_description})]}">@{[$o->escape($option{map_from_here})]}</a> <span class="summary">@{[$o->escape(&main::get_subjectline($page))]}</span>); |
233 |
|
|
unless ($option{outputed}->{$page}) { |
234 |
|
|
$r .= &list_to_html ($page, $wlist, %option); |
235 |
|
|
} |
236 |
|
|
$r .= "</li>\n"; |
237 |
|
|
} |
238 |
|
|
$r ? qq(<ul class="map">$r</ul>) : ''; |
239 |
|
|
} |
240 |
|
|
|
241 |
|
|
my %option = (level => 0+$o->resource('Map:Depth'), weight_list => {}, |
242 |
|
|
not_exist => {}, map_from_here => $o->resource('Map:FromHere'), |
243 |
|
|
map_from_here_description => $o->resource('Map:FromHereLong')); |
244 |
|
|
&make_list ($o->{page}, %option); |
245 |
|
|
$r = &list_to_html ($o->{page}, $option{weight_list}, %option); |
246 |
|
|
} |
247 |
|
|
|
248 |
|
|
{ |
249 |
|
|
Name: |
250 |
|
|
wikiview/last-modified |
251 |
|
|
FullName: |
252 |
|
|
Last-modified date & time of the page |
253 |
|
|
Format: |
254 |
|
|
$r = &main::_rfc3339_date ($main::database->mtime ($p->{page} || $o->{page})); |
255 |
|
|
} |
256 |
|
|
{ |
257 |
|
|
Name: |
258 |
|
|
wikiview-resource/last-modified |
259 |
|
|
FullName: |
260 |
|
|
Last-modified date & time of the page |
261 |
|
|
Format: |
262 |
|
|
$r = &main::_rfc3339_date ($main::database->mtime ($p->{page} || $o->{page})); |
263 |
|
|
} |
264 |
|
|
{ |
265 |
|
|
Name: |
266 |
|
|
wikiform_input/last-modified |
267 |
|
|
FullName: |
268 |
|
|
Last-modified date & time of the page |
269 |
|
|
Format: |
270 |
|
|
$r = &main::_rfc3339_date ($main::database->mtime ($p->{page} || $o->{page})); |
271 |
|
|
} |
272 |
|
|
{ |
273 |
|
|
Name: |
274 |
|
|
wikiview/page-name |
275 |
|
|
FullName: |
276 |
|
|
Page name |
277 |
|
|
Format: |
278 |
|
|
$r = $o->escape ($o->{page}); |
279 |
|
|
} |
280 |
|
|
{ |
281 |
|
|
Name: |
282 |
|
|
wikiview-resource/page-name |
283 |
|
|
FullName: |
284 |
|
|
Page name |
285 |
|
|
Format: |
286 |
|
|
$r = $o->escape ($o->{page}); |
287 |
|
|
} |
288 |
|
|
{ |
289 |
|
|
Name: |
290 |
|
|
wikiview/wiki-link |
291 |
|
|
FullName: |
292 |
|
|
Link to the WikiPage |
293 |
|
|
Format: |
294 |
|
|
$r = &main::make_wikilink ($o->escape ($p->{page}||$o->{page}), anchor => $p->{anchor}, latest => 1); |
295 |
|
|
} |
296 |
|
|
{ |
297 |
|
|
Name: |
298 |
|
|
wikiview-resource/wiki-link |
299 |
|
|
FullName: |
300 |
|
|
Link to the WikiPage |
301 |
|
|
Format: |
302 |
|
|
$r = &main::make_wikilink ($o->escape ($p->{page}||$o->{page}), anchor => $p->{anchor}, latest => 1); |
303 |
|
|
} |
304 |
|
|
|
305 |
|
|
{ |
306 |
|
|
Name: |
307 |
|
|
wikiview/diff-between-previous |
308 |
|
|
FullName: |
309 |
|
|
Difference between previous version of this WikiPage |
310 |
|
|
Format: |
311 |
|
|
$r = qq(<pre class="diff">); |
312 |
|
|
for (split /\n/, $o->escape ($main::database->traverse_diff ($o->{page}))) { |
313 |
|
|
if (/^\+(.*)/) { |
314 |
|
|
$r .= qq(<ins class="added">$1</ins>\n); |
315 |
|
|
} elsif (/^\-(.*)/) { |
316 |
|
|
$r .= qq(<del class="deleted">$1</del>\n); |
317 |
|
|
} elsif (/^\=(.*)/) { |
318 |
|
|
$r .= qq(<span class="same">$1</span>\n); |
319 |
|
|
} else { |
320 |
|
|
$r .= qq|??? $_\n|; |
321 |
|
|
} |
322 |
|
|
} |
323 |
|
|
$r .= qq(</pre>); |
324 |
|
|
} |
325 |
|
|
|
326 |
|
|
{ |
327 |
|
|
Name: |
328 |
|
|
wikiview/link-wiki |
329 |
|
|
FullName: |
330 |
|
|
Link element to the wiki itself |
331 |
|
|
Format: |
332 |
|
|
unless ($p->{href}) { |
333 |
|
|
$p->{mode} ||= 'read'; |
334 |
|
|
$p->{page} = $o->{page} unless defined $p->{page}; |
335 |
|
|
$p->{href} = $o->uri('wiki').'?'; |
336 |
|
|
if ($p->{up_to_date} || $p->{mode} ne 'read' || $p->{add_param}) { |
337 |
|
|
$p->{href} .= qq(mypage=@{[$o->encode($p->{page})]};mycmd=@{[$o->encode($p->{mode})]}); |
338 |
|
|
$p->{href} .= ';'.$p->{add_param} if $p->{add_param}; |
339 |
|
|
$p->{href} .= ';x-d='.time if $p->{up_to_date}; |
340 |
|
|
$p->{href} .= ';x-lm='.($main::database->mtime ($p->{page})||0) if $p->{with_lm}; |
341 |
|
|
} else { |
342 |
|
|
$p->{href} .= $o->encode ($p->{page}); |
343 |
|
|
} |
344 |
|
|
} |
345 |
|
|
$r = qq(<link); |
346 |
|
|
for my $attr (qw/rel rev href class type hreflang charset/) { |
347 |
|
|
$r .= qq( $attr="@{[$o->escape($p->{$attr})]}") if $p->{$attr}; |
348 |
|
|
} |
349 |
|
|
for my $attr (qw/title/) { |
350 |
|
|
$r .= qq( $attr="@{[$o->formatter('view')->replace($p->{$attr},$o)]}") if $p->{$attr}; |
351 |
|
|
} |
352 |
|
|
$r .= '/' if $o->{media}->{type} =~ /xml/; |
353 |
|
|
$r .= '>'; |
354 |
|
|
} |
355 |
|
|
{ |
356 |
|
|
Name: |
357 |
|
|
wikiview/anchor-wiki |
358 |
|
|
FullName: |
359 |
|
|
A element to the wiki page |
360 |
|
|
Format: |
361 |
|
|
unless ($p->{href}) { |
362 |
|
|
$p->{mode} ||= 'read'; |
363 |
|
|
$p->{page} = $o->{page} unless defined $p->{page}; |
364 |
|
|
$p->{href} = $o->uri('wiki').'?'; |
365 |
|
|
if ($p->{up_to_date} || $p->{mode} ne 'read' || $p->{add_param}) { |
366 |
|
|
$p->{href} .= qq(mypage=@{[$o->encode($p->{page})]};mycmd=@{[$o->encode($p->{mode})]}); |
367 |
|
|
$p->{href} .= ';'.$p->{add_param} if $p->{add_param}; |
368 |
|
|
$p->{href} .= ';x-d='.time if $p->{up_to_date}; |
369 |
|
|
$p->{href} .= ';x-lm='.($main::database->mtime ($p->{page})||0) if $p->{with_lm}; |
370 |
|
|
} else { |
371 |
|
|
$p->{href} .= $o->encode ($p->{page}); |
372 |
|
|
} |
373 |
|
|
} |
374 |
|
|
$r = qq(<a); |
375 |
|
|
for my $attr (qw/rel rev href class type hreflang charset/) { |
376 |
|
|
$r .= qq( $attr="@{[$o->escape($p->{$attr})]}") if $p->{$attr}; |
377 |
|
|
} |
378 |
|
|
for my $attr (qw/title accesskey/) { |
379 |
|
|
$r .= qq( $attr="@{[$o->formatter('view')->replace($p->{$attr},$o)]}") if $p->{$attr}; |
380 |
|
|
} |
381 |
|
|
$r .= '>' . $o->formatter ('view')->replace ($p->{label}, $o) . '</a>'; |
382 |
|
|
} |
383 |
|
|
|
384 |
|
|
{ |
385 |
|
|
Name: |
386 |
|
|
wikiview/referer-list |
387 |
|
|
FullName: |
388 |
|
|
Referer-list of page |
389 |
|
|
Format: |
390 |
|
|
$r = wiki::referer::list_html ($o->{page}); |
391 |
|
|
} |
392 |
|
|
|
393 |
|
|
{ |
394 |
|
|
Name: |
395 |
|
|
wikiview/uri-wiki |
396 |
|
|
FullName: |
397 |
|
|
Output URI of the WikiPage (as anchor) |
398 |
|
|
Format: |
399 |
|
|
my $uri = $o->uri('wiki').'?'.$o->encode($p->{page}||$o->{page}); |
400 |
|
|
$r = qq(<<a href="$uri">$uri</a>>); |
401 |
w |
1.1 |
} |
402 |
|
|
|
403 |
|
|
POD:LICENSE: |
404 |
|
|
Copyright 2003 Wakaba <w@suika.fam.cx> |
405 |
|
|
|
406 |
|
|
%%GNUGPL2%% |