/[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.5 - (hide annotations) (download)
Tue Mar 30 04:04:44 2004 UTC (21 years, 3 months ago) by wakaba
Branch: MAIN
Changes since 1.4: +9 -2 lines
Referer list navigation implemented

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24