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