/[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.2 - (hide annotations) (download)
Sun Feb 8 08:46:47 2004 UTC (21 years, 5 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +22 -18 lines
New WikiName interface

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     @License: %%GPL%%
10     @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     $Date: 2004/02/01 12:09:44 $
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     __ATTRTEXT:%mode__;
140     try {
141     for (sort {$a->[1] cmp $b->[1]}
142 wakaba 1.2 map {[$_, join '//', @{$_}]} # make sort key
143 wakaba 1.1 $o->{wiki}->{db}->keys ('content',
144 wakaba 1.2 -ns => $ns,
145 wakaba 1.1 -type => 'key',
146     -recursive => $p->{recursive})) {
147     last if $i++ == $p->{n};
148    
149     my $li = $list->append_new_node
150     (type => '#element',
151     namespace_uri => $NS_XHTML1,
152     local_name => 'li');
153     $WIKILINKING->to_wikipage_in_html ({
154     label => $p->{template},
155     } => {
156 wakaba 1.2 base => $o->{wiki}->{var}->{page},
157     page_name_relative => $o->{wiki}->name ($_->[0]),
158 wakaba 1.1 wiki_mode => $p->{mode},
159     }, {
160     o => $o,
161     parent => $li,
162     });
163     }
164     } catch SuikaWiki::DB::Util::Error with {
165     #
166     };
167     $p->{-parent}->remove_child_node ($list) unless $list->count;
168    
169     FormattingRule:
170     @Category[list]:
171     form-input
172     view
173     view-resource
174     @Name: search-result
175     @Formatting:
176     __ATTRTEXT:%key__;
177 wakaba 1.2 $p->{key} ||= $o->{wiki}->{var}->{page}->stringify (wiki => $o->{wiki});
178 wakaba 1.1 __ATTRTEXT:%case_sensible__;
179     my $word = $p->{case_sensible} ? $p->{key} : lc $p->{key};
180     my @r;
181     my $sr = $o->{wiki}->{db}->get (m__search_result => [$word]);
182     unless ($sr) {
183     for my $page ($o->{wiki}->{db}->keys ('content')) {
184     my $content;
185     try {
186     $content = $o->{wiki}->{db}->get (content => $page);
187     } catch SuikaWiki::DB::Util::Error with {
188     $content = undef;
189     };
190     $content = $p->{case_sensible} ? $content : lc $content;
191     $content =~ s/^[^\x0A\x0D]+[\x0D\x0A]+//s;
192 wakaba 1.2 $page = $o->{wiki}->name ($page);
193     my $n_page = $page->stringify (wiki => $o->{wiki});
194     $n_page = lc $n_page unless $p->{case_sensible};
195 wakaba 1.1 if (index ($n_page, $word) > -1) {
196     my $c = $content =~ s/\Q$word\E//g;
197     push @r, [$page, $c+20];
198     } elsif (index ($word, $n_page) > -1) {
199     my $c = $content =~ s/\Q$word\E//g;
200     push @r, [$page, $c+10];
201     } elsif (my $c = $content =~ s/\Q$word\E//g) {
202     push @r, [$page, $c];
203     }
204     }
205     @r = sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r;
206 wakaba 1.2 $sr = join "\x1E",
207     map {$_->[0]->stringify (wiki => $o->{wiki}, delimiter => "\x1D")
208     ."\x1F".$_->[1]} @r;
209 wakaba 1.1 $o->{wiki}->{db}->set (m__search_result => [$word] => $sr);
210     ## TODO: Cache & case-sensibility
211     } else {
212 wakaba 1.2 @r = map {[$o->{wiki}->name ($_->[0], delimiter_reg => qr/\x1D/), $_->[1]]}
213 wakaba 1.1 map {[split /\x1F/, $_, 2]} split /\x1E/, $sr;
214     }
215     return unless @r;
216     my $list = $p->{-parent}->append_new_node
217     (type => '#element',
218     namespace_uri => $NS_XHTML1,
219     local_name => 'ol');
220     __ATTRTEXT:%template__;
221     $p->{template} ||= $WIKIRESOURCE->get
222     (name => 'Link:toWikiPage:SourceLabelLong:SearchResult',
223     wiki => $o->{wiki}, o => $o);
224     for (@r) {
225     my $li = $list->append_new_node
226     (type => '#element',
227     namespace_uri => $NS_XHTML1,
228     local_name => 'li');
229     $WIKILINKING->to_wikipage_in_html ({
230     label => $p->{template},
231     } => {
232 wakaba 1.2 base => $o->{wiki}->{var}->{page},
233 wakaba 1.1 page_name_relative => $_->[0],
234     wiki_mode => $p->{mode},
235     }, {
236     o => $o,
237     parent => $li,
238     -m__weight => $_->[1],
239     });
240     }
241    
242     FormattingRule:
243     @Category[list]:
244     page-link
245     @Name: m--link-weight
246     @Formatting:
247     $p->{-parent}->append_text ($o->{link}->{option}->{-m__weight}+0);
248    
249     ViewFragment:
250     @Name: ws--post-content
251     @Description:
252     @@@: After content body -- navigation bar
253     @@lang:en
254     @Order: 100
255     @Formatting:
256     %section (
257     id => children,
258     title => {%res(name=>{Children:Title});}p, heading,
259     content => {%page-list (
260     ns => {%page-name;}p, recursive => 0,
261     type => both,
262     template => {%resource-as-plain-text (name => {Children:Item});}p,
263     );}p,
264     );
265     %section (
266     id => see-also,
267     title => {%res(name=>SeeAlso);}p, heading,
268     content => {%search-result;}p,
269     );
270     %section (
271     id => referer,
272     title => {%res(name=>Referer);}p, heading,
273     content => {%referer-list;}p,
274     );
275    
276     Resource:
277     @Children:Title:
278     %link-to-it(label=>{%ns-short-page-name;}p,
279     description=>{%page-name(absolute);}p,
280     );
281     %span(class=>headline, content=>{%page-headline;}p);
282     @Link:toWikiPage:SourceLabelLong:PageList:
283     %link-to-it(
284     label=>{%page-title(relative);}p,
285     description=>{%page-name(absolute);}p,
286     );
287     %span(class=>headline,content=>{%page-headline;}p);
288     @Link:toWikiPage:SourceLabelLong:RecentChangeItem:
289     %last-modified;
290     %link-to-it(
291     label=>{%page-title(relative);}p,
292     description=>{%page-name(absolute);}p,
293     );
294     %span(class=>headline,content=>{%page-headline;}p);
295     @Link:toWikiPage:SourceLabelLong:SearchResult:
296     {%m--link-weight;}
297     %link-to-it(
298     label=>{%page-title(relative);}p,
299     description=>{%page-name(absolute);}p,
300     );
301     %span(class=>headline,content=>{%page-headline;}p);
302    
303     ## TODO:
304     ViewFragment:
305     @Name: navbar
306     @Order: 21
307     @Formatting:
308     %link-to-wikipage (
309     page => {RecentChanges},
310     label => {%link-to-it (
311     label=>"%res(name=>GoToRecentChanges);"p,
312     description=>"%res(name=>GoToRecentChangesLong);"p,
313     );},
314     rel => news,
315     );
316    
317     ## TODO:
318     ViewFragment:
319     @Name: links
320     @Formatting:
321     %link-to-wikipage (
322     page => {RecentChanges},
323     rel => news,
324     label => {%html-link (
325     description => {%res(name=>GoToRecentChangesLink);}p,
326     );},
327     );

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24