/[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.11 - (hide annotations) (download)
Sun Feb 6 12:25:59 2005 UTC (20 years, 5 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, HEAD
Branch point for: helowiki, helowiki-2005
Changes since 1.10: +10 -10 lines
2005-01-30 change reverted since it does not work

1 wakaba 1.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 wakaba 1.11 $Date: 2005/01/30 12:25:07 $
18 wakaba 1.1 @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 wakaba 1.6 $o->{wiki}->{input}->parameter ('search__query') : undef);
46     unless (defined $p->{query} or length $p->{query}) {
47     $p->{query} = join ' ',
48 wakaba 1.9 map {my $s = length $_ > 2 ? '*'.$_.'*' : $_;
49 wakaba 1.8 $s =~ s/^\*\*+//; $s =~ s/\*\*+$/*/; $s}
50 wakaba 1.6 @{$o->{wiki}->{var}->{page}};
51     }
52 wakaba 1.1 my $list = $p->{-parent}->append_new_node
53     (type => '#element',
54     namespace_uri => $NS_XHTML1,
55     local_name => 'ol');
56     my $template = $p->{template} ||
57     $WIKIRESOURCE->get_text
58     (name => 'Namazu:Result:Item:Template',
59     o => $o, wiki => $o->{wiki});
60     my @result = Search::Namazu::Search
61     (index => $o->{wiki}->{config}->{path_to}->{namazu__index_dir},
62     query => $p->{query},
63     sortMethod => NMZ_SORTBYSCORE,
64 wakaba 1.2 sortOrder => NMZ_ASCENDSORT,
65     lang => 'ja');
66 wakaba 1.11 # unless (@result) {
67     # $p->{query} =~ tr/\*/ /;
68     # \ @result = Search::Namazu::Search
69     # (index => $o->{wiki}->{config}->{path_to}->{namazu__index_dir},
70     # query => $p->{query},
71     # sortMethod => NMZ_SORTBYSCORE,
72     # sortOrder => NMZ_ASCENDSORT,
73     # lang => 'ja');
74     # }
75 wakaba 1.1 __ATTRTEXT:%start__;__ATTRTEXT:%number__;
76     my $start = length $p->{start} ? $p->{start} :
77     $o->{wiki}->{input}->parameter ('search--range-start') || 0;
78     $p->{number} = $o->{wiki}->{input}->parameter ('search--range-number')
79     unless length $p->{number};
80     my $end = $p->{number} ? $start + $p->{number} - 1 : $start + 29;
81     $start = 0 if $start > $#result or $start < 0;
82     $end = $#result if $end < $start or $end > $#result;
83     $end = $start + 255 if $end > $start + 255;
84     local $o->{var}->{search__result} = {
85     min => 0,
86     max => $#result,
87     start => $start,
88     end => $end,
89     number => $p->{number} || 30,
90     query => $p->{query},
91 wakaba 1.5 param_prefix => 'search',
92 wakaba 1.1 };
93     for my $result (@result[$start..$end]) {
94     next unless $result;
95 wakaba 1.3 my ($reluri, $absuri) = $o->{wiki}->{config}->{nmz__uri_to_uri}
96     ->($result->uri, o => $o);
97 wakaba 1.1 $WIKILINKING->to_resource_by_uri_in_html ({
98     label => $template,
99     } => {
100 wakaba 1.3 uri => $reluri,
101     absolute_uri => $absuri,
102 wakaba 1.1 nmz__result => $result,
103     }, {
104     o => $o,
105     parent => $list->append_new_node
106     (type => '#element',
107     namespace_uri => $NS_XHTML1,
108     local_name => 'li'),
109     nmz__query => $p->{query},
110     });
111     }
112     if ($list->count) {
113     $list->set_attribute (start => $start + 1);
114     __ATTRNODE:%post_list->{$p->{-parent}}__;
115     } else {
116     $p->{-parent}->remove_child_node ($list);
117     }
118    
119     FormattingRule:
120     @Category[list]:
121     link-to-resource
122     @Name: nmz--rank
123     @Formatting:
124     $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->rank + 0);
125    
126     FormattingRule:
127     @Category[list]:
128     link-to-resource
129     @Name: nmz--score
130     @Formatting:
131     $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->score + 0);
132    
133     FormattingRule:
134     @Category[list]:
135     link-to-resource
136     @Name: nmz--title
137     @Formatting:
138 wakaba 1.5 # $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->title);
139    
140     ## TODO: Remove this code after SuikaWiki/0.9 filter for Namazu available
141     my $title = $o->{link}->{dest}->{nmz__result}->title;
142     $title =~ s/([0-9A-F][0-9A-F])/pack 'C', hex $1/ge and $title =~ s/\.txt$//
143     if $title =~ /^(?:[0-9A-F][0-9A-F])+\.txt$/;
144     $p->{-parent}->append_text ($title);
145 wakaba 1.1
146     FormattingRule:
147     @Category[list]:
148     link-to-resource
149     @Name: nmz--uri
150     @Formatting:
151     $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->uri);
152    
153     FormattingRule:
154     @Category[list]:
155     link-to-resource
156     @Name: nmz--summary
157     @Formatting:
158     $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->summary);
159    
160     Resource:
161     @Namazu:Result:Item:Template:
162     %line (content => {
163     {%nmz--score;}
164     %link-to-it (
165     label => {%nmz--title;}p,
166     description => {%nmz--title; <%uri-reference;>}p,
167     );
168     }p);
169     %line (content => {%nmz--summary;}p);
170    
171    
172    
173    
174    
175    
176    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24