/[pub]/suikawiki/script/misc/plugins/link/namazu.wp2
Suika

Contents of /suikawiki/script/misc/plugins/link/namazu.wp2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Fri Mar 19 11:24:47 2004 UTC (21 years, 4 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +3 -2 lines
*** empty log message ***

1 #?SuikaWikiConfig/2.0
2
3 Plugin:
4 @Name: Namazu
5 @Description:
6 @@@:
7 Namazu interface
8 @@lang:en
9 @License: %%Perl%%
10 @Author:
11 @@Name:
12 @@@@: Wakaba
13 @@@lang:ja
14 @@@script:Latn
15 @@Mail[list]: w@suika.fam.cx
16 @Date.RCS:
17 $Date: 2004/03/19 03:42:06 $
18 @RequiredModule[list]:
19 Search::Namazu
20 @RequiredPlugin[list]:
21 WikiLinking
22 @Use:
23 use Search::Namazu;
24 use Message::Util::Error;
25 my $WIKILINKING;
26 my $WIKIRESOURCE;
27
28 PluginConst:
29 @NS_XHTML1:
30 http://www.w3.org/1999/xhtml
31 @WIKILINKING:
32 {($WIKILINKING ||= SuikaWiki::Plugin->module_package ('WikiLinking'))}
33 @WIKIRESOURCE:
34 {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))}
35
36 FormattingRule:
37 @Category[list]:
38 view
39 view-resource
40 form-input
41 @Name: namazu-search
42 @Formatting:
43 __ATTRTEXT:%query__;
44 $p->{query} ||= ($o->{wiki}->{input} ?
45 $o->{wiki}->{input}->parameter ('search__query') : undef)
46 || $o->{wiki}->{var}->{page}->stringify (wiki => $o->{wiki});
47 my $list = $p->{-parent}->append_new_node
48 (type => '#element',
49 namespace_uri => $NS_XHTML1,
50 local_name => 'ol');
51 my $template = $p->{template} ||
52 $WIKIRESOURCE->get_text
53 (name => 'Namazu:Result:Item:Template',
54 o => $o, wiki => $o->{wiki});
55 my @result = Search::Namazu::Search
56 (index => $o->{wiki}->{config}->{path_to}->{namazu__index_dir},
57 query => $p->{query},
58 sortMethod => NMZ_SORTBYSCORE,
59 sortOrder => NMZ_ASCENDSORT,
60 lang => 'ja');
61 __ATTRTEXT:%start__;__ATTRTEXT:%number__;
62 my $start = length $p->{start} ? $p->{start} :
63 $o->{wiki}->{input}->parameter ('search--range-start') || 0;
64 $p->{number} = $o->{wiki}->{input}->parameter ('search--range-number')
65 unless length $p->{number};
66 my $end = $p->{number} ? $start + $p->{number} - 1 : $start + 29;
67 $start = 0 if $start > $#result or $start < 0;
68 $end = $#result if $end < $start or $end > $#result;
69 $end = $start + 255 if $end > $start + 255;
70 local $o->{var}->{search__result} = {
71 min => 0,
72 max => $#result,
73 start => $start,
74 end => $end,
75 number => $p->{number} || 30,
76 query => $p->{query},
77 };
78 for my $result (@result[$start..$end]) {
79 next unless $result;
80 $WIKILINKING->to_resource_by_uri_in_html ({
81 label => $template,
82 } => {
83 uri => $o->{wiki}->{config}->{nmz__uri_to_uri}->($result->uri, o => $o),
84 nmz__result => $result,
85 }, {
86 o => $o,
87 parent => $list->append_new_node
88 (type => '#element',
89 namespace_uri => $NS_XHTML1,
90 local_name => 'li'),
91 nmz__query => $p->{query},
92 });
93 }
94 if ($list->count) {
95 $list->set_attribute (start => $start + 1);
96 __ATTRNODE:%post_list->{$p->{-parent}}__;
97 } else {
98 $p->{-parent}->remove_child_node ($list);
99 }
100
101 FormattingRule:
102 @Category[list]:
103 link-to-resource
104 @Name: nmz--rank
105 @Formatting:
106 $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->rank + 0);
107
108 FormattingRule:
109 @Category[list]:
110 link-to-resource
111 @Name: nmz--score
112 @Formatting:
113 $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->score + 0);
114
115 FormattingRule:
116 @Category[list]:
117 link-to-resource
118 @Name: nmz--title
119 @Formatting:
120 $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->title);
121
122 FormattingRule:
123 @Category[list]:
124 link-to-resource
125 @Name: nmz--uri
126 @Formatting:
127 $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->uri);
128
129 FormattingRule:
130 @Category[list]:
131 link-to-resource
132 @Name: nmz--summary
133 @Formatting:
134 $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->summary);
135
136 Resource:
137 @Namazu:Result:Item:Template:
138 %line (content => {
139 {%nmz--score;}
140 %link-to-it (
141 label => {%nmz--title;}p,
142 description => {%nmz--title; <%uri-reference;>}p,
143 );
144 }p);
145 %line (content => {%nmz--summary;}p);
146
147
148
149
150
151
152

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24