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: %%GPL%% |
10 |
@Author: |
11 |
@@Name: |
12 |
@@@@: Wakaba |
13 |
@@@lang:ja |
14 |
@@@script:Latn |
15 |
@@Mail[list]: w@suika.fam.cx |
16 |
@Date.RCS: $Date: 2004/01/16 07:49:41 $ |
17 |
@RequiredPlugin[list]: |
18 |
WikiLinking |
19 |
@Use: |
20 |
use Message::Util::Error; |
21 |
my $WIKILINKING; |
22 |
my $WIKIRESOURCE; |
23 |
|
24 |
PluginConst: |
25 |
@NS_XHTML1: |
26 |
http://www.w3.org/1999/xhtml |
27 |
@NS_RDF: |
28 |
http://www.w3.org/1999/02/22-rdf-syntax-ns# |
29 |
@NS_RSS: |
30 |
http://purl.org/rss/1.0/ |
31 |
@NS_DC: |
32 |
http://purl.org/dc/elements/1.1/ |
33 |
@NS_MAP: |
34 |
http://members.jcom.home.ne.jp/jintrick/2003/02/site-concept.xml# |
35 |
@WIKILINKING: |
36 |
{($WIKILINKING ||= SuikaWiki::Plugin->module_package ('WikiLinking'))} |
37 |
@WIKIRESOURCE: |
38 |
{($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))} |
39 |
|
40 |
FormattingRule: |
41 |
@Category[list]: |
42 |
form-input |
43 |
view |
44 |
view-resource |
45 |
@Name: recent-change-list |
46 |
@Description: |
47 |
@@@: Recently changed WikiPage list |
48 |
@@lang: en |
49 |
@Parameter: |
50 |
@@Name: ns |
51 |
@@Type: WikiName |
52 |
@@Default: (auto) |
53 |
@@Description: |
54 |
@@@@: |
55 |
WikiNamespace name to which listed WikiPages belong |
56 |
@@@lang: en |
57 |
@Formatting: |
58 |
my $list = $p->{-parent}->append_new_node |
59 |
(type => '#element', |
60 |
namespace_uri => $NS_XHTML1, |
61 |
local_name => 'ol'); |
62 |
$list->set_attribute (class => 'm--recent-changes'); |
63 |
|
64 |
__ATTRTEXT:%ns__;__ATTRTEXT:%recursive__; |
65 |
__ATTRTEXT:%n__; |
66 |
$p->{recursive} = 1 unless length $p->{recursive}; |
67 |
$p->{ns} .= '//' if $p->{ns} and not substr ($p->{ns}, -2) eq '//'; |
68 |
my $i = 0; |
69 |
$p->{n} ||= 10; |
70 |
__ATTRTEXT:%template__; |
71 |
$p->{template} ||= $WIKIRESOURCE->get |
72 |
(name => 'Link:toWikiPage:SourceLabelLong:RecentChangeItem', |
73 |
wiki => $o->{wiki}, o => $o); |
74 |
__ATTRTEXT:%mode__; |
75 |
for (sort {$b->[1] <=> $a->[1]} |
76 |
map { try { [$_, $o->{wiki}->{db}->get (lastmodified => $_)] } |
77 |
catch SuikaWiki::DB::Util::Error with {[$_, undef]} } |
78 |
$o->{wiki}->{db}->keys ('content', |
79 |
-ns => [split m#//#, $p->{ns}], |
80 |
-type => 'key', |
81 |
-recursive => $p->{recursive})) { |
82 |
next unless $_->[0]; |
83 |
last if $i++ == $p->{n}; |
84 |
|
85 |
my $li = $list->append_new_node |
86 |
(type => '#element', |
87 |
namespace_uri => $NS_XHTML1, |
88 |
local_name => 'li'); |
89 |
$WIKILINKING->to_wikipage_in_html ({ |
90 |
label => $p->{template}, |
91 |
} => { |
92 |
# base => $o->{page}, |
93 |
page_name_relative => $_->[0], |
94 |
wiki_mode => $p->{mode}, |
95 |
_with_lm => 1, |
96 |
page_lastmodified => $_->[1], |
97 |
}, { |
98 |
o => $o, |
99 |
parent => $li, |
100 |
}); |
101 |
} |
102 |
|
103 |
FormattingRule: |
104 |
@Category[list]: |
105 |
form-input |
106 |
view |
107 |
view-resource |
108 |
@Name: page-list |
109 |
@Description: |
110 |
@@@: WikiPage list |
111 |
@@lang: en |
112 |
@Parameter: |
113 |
@@Name: ns |
114 |
@@Type: WikiName |
115 |
@@Default: (auto) |
116 |
@@Description: |
117 |
@@@@: |
118 |
WikiNamespace name to which listed WikiPages belong |
119 |
@@@lang: en |
120 |
@Formatting: |
121 |
my $list = $p->{-parent}->append_new_node |
122 |
(type => '#element', |
123 |
namespace_uri => $NS_XHTML1, |
124 |
local_name => 'ul'); |
125 |
|
126 |
__ATTRTEXT:%ns__;__ATTRTEXT:%recursive__; |
127 |
__ATTRTEXT:%n__; |
128 |
$p->{recursive} = 1 unless length $p->{recursive}; |
129 |
$p->{ns} .= '//' if $p->{ns} and not substr ($p->{ns}, -2) eq '//'; |
130 |
my $i = 0; |
131 |
$p->{n} ||= -1; |
132 |
__ATTRTEXT:%template__; |
133 |
$p->{template} ||= $WIKIRESOURCE->get |
134 |
(name => 'Link:toWikiPage:SourceLabelLong:PageList', |
135 |
wiki => $o->{wiki}, o => $o); |
136 |
__ATTRTEXT:%mode__; |
137 |
try { |
138 |
for (sort {$a->[1] cmp $b->[1]} |
139 |
map {[$_, join '//', @{$_}]} |
140 |
$o->{wiki}->{db}->keys ('content', |
141 |
-ns => [split m#//#, $p->{ns}], |
142 |
-type => 'key', |
143 |
-recursive => $p->{recursive})) { |
144 |
last if $i++ == $p->{n}; |
145 |
|
146 |
my $li = $list->append_new_node |
147 |
(type => '#element', |
148 |
namespace_uri => $NS_XHTML1, |
149 |
local_name => 'li'); |
150 |
$WIKILINKING->to_wikipage_in_html ({ |
151 |
label => $p->{template}, |
152 |
} => { |
153 |
# base => $o->{page}, |
154 |
page_name_relative => $_->[0], |
155 |
wiki_mode => $p->{mode}, |
156 |
}, { |
157 |
o => $o, |
158 |
parent => $li, |
159 |
}); |
160 |
} |
161 |
} catch SuikaWiki::DB::Util::Error with { |
162 |
# |
163 |
}; |
164 |
$p->{-parent}->remove_child_node ($list) unless $list->count; |
165 |
|
166 |
FormattingRule: |
167 |
@Category[list]: |
168 |
form-input |
169 |
view |
170 |
view-resource |
171 |
@Name: search-result |
172 |
@Formatting: |
173 |
__ATTRTEXT:%key__; |
174 |
$p->{key} ||= join '//', @{$o->{wiki}->{var}->{page}}; |
175 |
__ATTRTEXT:%case_sensible__; |
176 |
my $word = $p->{case_sensible} ? $p->{key} : lc $p->{key}; |
177 |
my @r; |
178 |
my $sr = $o->{wiki}->{db}->get (m__search_result => [$word]); |
179 |
unless ($sr) { |
180 |
for my $page ($o->{wiki}->{db}->keys ('content')) { |
181 |
my $content; |
182 |
try { |
183 |
$content = $o->{wiki}->{db}->get (content => $page); |
184 |
} catch SuikaWiki::DB::Util::Error with { |
185 |
$content = undef; |
186 |
}; |
187 |
$content = $p->{case_sensible} ? $content : lc $content; |
188 |
$content =~ s/^[^\x0A\x0D]+[\x0D\x0A]+//s; |
189 |
my $n_page = $p->{case_sensible} ? join '//', @$page |
190 |
: lc join '//', @$page; |
191 |
if (index ($n_page, $word) > -1) { |
192 |
my $c = $content =~ s/\Q$word\E//g; |
193 |
push @r, [$page, $c+20]; |
194 |
} elsif (index ($word, $n_page) > -1) { |
195 |
my $c = $content =~ s/\Q$word\E//g; |
196 |
push @r, [$page, $c+10]; |
197 |
} elsif (my $c = $content =~ s/\Q$word\E//g) { |
198 |
push @r, [$page, $c]; |
199 |
} |
200 |
} |
201 |
@r = sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r; |
202 |
$sr = join "\x1E", map {join ("\x1D", @{$_->[0]})."\x1F".$_->[1]} @r; |
203 |
$o->{wiki}->{db}->set (m__search_result => [$word] => $sr); |
204 |
## TODO: Cache & case-sensibility |
205 |
} else { |
206 |
@r = map {[[split /\x1D/, $_->[0]], $_->[1]]} |
207 |
map {[split /\x1F/, $_, 2]} split /\x1E/, $sr; |
208 |
} |
209 |
#my $em = $p->{em} ? sub { my $s = shift; $s =~ s#(\Q$word\E)#<em>$1</em>#gi; $s } : sub {$_[0]}; |
210 |
|
211 |
return unless @r; |
212 |
my $list = $p->{-parent}->append_new_node |
213 |
(type => '#element', |
214 |
namespace_uri => $NS_XHTML1, |
215 |
local_name => 'ol'); |
216 |
__ATTRTEXT:%template__; |
217 |
$p->{template} ||= $WIKIRESOURCE->get |
218 |
(name => 'Link:toWikiPage:SourceLabelLong:SearchResult', |
219 |
wiki => $o->{wiki}, o => $o); |
220 |
for (@r) { |
221 |
my $li = $list->append_new_node |
222 |
(type => '#element', |
223 |
namespace_uri => $NS_XHTML1, |
224 |
local_name => 'li'); |
225 |
$WIKILINKING->to_wikipage_in_html ({ |
226 |
label => $p->{template}, |
227 |
} => { |
228 |
# base => $o->{page}, |
229 |
page_name_relative => $_->[0], |
230 |
wiki_mode => $p->{mode}, |
231 |
}, { |
232 |
o => $o, |
233 |
parent => $li, |
234 |
-m__weight => $_->[1], |
235 |
}); |
236 |
} |
237 |
|
238 |
FormattingRule: |
239 |
@Category[list]: |
240 |
page-link |
241 |
@Name: m--link-weight |
242 |
@Formatting: |
243 |
$p->{-parent}->append_text ($o->{link}->{option}->{-m__weight}+0); |
244 |
|
245 |
ViewFragment: |
246 |
@Name: ws--post-content |
247 |
@Description: |
248 |
@@@: After content body -- navigation bar |
249 |
@@lang:en |
250 |
@Order: 100 |
251 |
@Formatting: |
252 |
%section ( |
253 |
id => children, |
254 |
title => {%res(name=>{Children:Title});}p, heading, |
255 |
content => {%page-list ( |
256 |
ns => {%page-name;}p, recursive => 0, |
257 |
type => both, |
258 |
template => {%resource-as-plain-text (name => {Children:Item});}p, |
259 |
);}p, |
260 |
); |
261 |
%section ( |
262 |
id => see-also, |
263 |
title => {%res(name=>SeeAlso);}p, heading, |
264 |
content => {%search-result;}p, |
265 |
); |
266 |
%section ( |
267 |
id => referer, |
268 |
title => {%res(name=>Referer);}p, heading, |
269 |
content => {%referer-list;}p, |
270 |
); |
271 |
|
272 |
Resource: |
273 |
@Children:Title: |
274 |
%link-to-it(label=>{%ns-short-page-name;}p, |
275 |
description=>{%page-name(absolute);}p, |
276 |
); |
277 |
%span(class=>headline, content=>{%page-headline;}p); |
278 |
@Link:toWikiPage:SourceLabelLong:PageList: |
279 |
%link-to-it( |
280 |
label=>{%page-title(relative);}p, |
281 |
description=>{%page-name(absolute);}p, |
282 |
); |
283 |
%span(class=>headline,content=>{%page-headline;}p); |
284 |
@Link:toWikiPage:SourceLabelLong:RecentChangeItem: |
285 |
%last-modified; |
286 |
%link-to-it( |
287 |
label=>{%page-title(relative);}p, |
288 |
description=>{%page-name(absolute);}p, |
289 |
); |
290 |
%span(class=>headline,content=>{%page-headline;}p); |
291 |
@Link:toWikiPage:SourceLabelLong:SearchResult: |
292 |
{%m--link-weight;} |
293 |
%link-to-it( |
294 |
label=>{%page-title(relative);}p, |
295 |
description=>{%page-name(absolute);}p, |
296 |
); |
297 |
%span(class=>headline,content=>{%page-headline;}p); |
298 |
|
299 |
## TODO: |
300 |
ViewFragment: |
301 |
@Name: navbar |
302 |
@Order: 21 |
303 |
@Formatting: |
304 |
%link-to-wikipage ( |
305 |
page => {RecentChanges}, |
306 |
label => {%link-to-it ( |
307 |
label=>"%res(name=>GoToRecentChanges);"p, |
308 |
description=>"%res(name=>GoToRecentChangesLong);"p, |
309 |
);}, |
310 |
rel => news, |
311 |
); |
312 |
|
313 |
## TODO: |
314 |
ViewFragment: |
315 |
@Name: links |
316 |
@Formatting: |
317 |
%link-to-wikipage ( |
318 |
page => {RecentChanges}, |
319 |
rel => news, |
320 |
label => {%html-link ( |
321 |
description => {%res(name=>GoToRecentChangesLink);}p, |
322 |
);}, |
323 |
); |