/[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.9 - (hide annotations) (download)
Sun Jul 25 06:54:29 2004 UTC (20 years, 11 months ago) by wakaba
Branch: MAIN
Changes since 1.8: +2 -2 lines
Property Editor 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.9 $Date: 2004/06/03 06:38:48 $
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.1 __ATTRTEXT:%start__;__ATTRTEXT:%number__;
67     my $start = length $p->{start} ? $p->{start} :
68     $o->{wiki}->{input}->parameter ('search--range-start') || 0;
69     $p->{number} = $o->{wiki}->{input}->parameter ('search--range-number')
70     unless length $p->{number};
71     my $end = $p->{number} ? $start + $p->{number} - 1 : $start + 29;
72     $start = 0 if $start > $#result or $start < 0;
73     $end = $#result if $end < $start or $end > $#result;
74     $end = $start + 255 if $end > $start + 255;
75     local $o->{var}->{search__result} = {
76     min => 0,
77     max => $#result,
78     start => $start,
79     end => $end,
80     number => $p->{number} || 30,
81     query => $p->{query},
82 wakaba 1.5 param_prefix => 'search',
83 wakaba 1.1 };
84     for my $result (@result[$start..$end]) {
85     next unless $result;
86 wakaba 1.3 my ($reluri, $absuri) = $o->{wiki}->{config}->{nmz__uri_to_uri}
87     ->($result->uri, o => $o);
88 wakaba 1.1 $WIKILINKING->to_resource_by_uri_in_html ({
89     label => $template,
90     } => {
91 wakaba 1.3 uri => $reluri,
92     absolute_uri => $absuri,
93 wakaba 1.1 nmz__result => $result,
94     }, {
95     o => $o,
96     parent => $list->append_new_node
97     (type => '#element',
98     namespace_uri => $NS_XHTML1,
99     local_name => 'li'),
100     nmz__query => $p->{query},
101     });
102     }
103     if ($list->count) {
104     $list->set_attribute (start => $start + 1);
105     __ATTRNODE:%post_list->{$p->{-parent}}__;
106     } else {
107     $p->{-parent}->remove_child_node ($list);
108     }
109    
110     FormattingRule:
111     @Category[list]:
112     link-to-resource
113     @Name: nmz--rank
114     @Formatting:
115     $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->rank + 0);
116    
117     FormattingRule:
118     @Category[list]:
119     link-to-resource
120     @Name: nmz--score
121     @Formatting:
122     $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->score + 0);
123    
124     FormattingRule:
125     @Category[list]:
126     link-to-resource
127     @Name: nmz--title
128     @Formatting:
129 wakaba 1.5 # $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->title);
130    
131     ## TODO: Remove this code after SuikaWiki/0.9 filter for Namazu available
132     my $title = $o->{link}->{dest}->{nmz__result}->title;
133     $title =~ s/([0-9A-F][0-9A-F])/pack 'C', hex $1/ge and $title =~ s/\.txt$//
134     if $title =~ /^(?:[0-9A-F][0-9A-F])+\.txt$/;
135     $p->{-parent}->append_text ($title);
136 wakaba 1.1
137     FormattingRule:
138     @Category[list]:
139     link-to-resource
140     @Name: nmz--uri
141     @Formatting:
142     $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->uri);
143    
144     FormattingRule:
145     @Category[list]:
146     link-to-resource
147     @Name: nmz--summary
148     @Formatting:
149     $p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->summary);
150    
151     Resource:
152     @Namazu:Result:Item:Template:
153     %line (content => {
154     {%nmz--score;}
155     %link-to-it (
156     label => {%nmz--title;}p,
157     description => {%nmz--title; <%uri-reference;>}p,
158     );
159     }p);
160     %line (content => {%nmz--summary;}p);
161    
162    
163    
164    
165    
166    
167    

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24