/[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.3 - (hide annotations) (download)
Sat Feb 14 10:52:27 2004 UTC (21 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.2: +5 -2 lines
(match): New parameter

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24