1 |
use strict; |
2 |
package SuikaWiki::Plugin::Registry; |
3 |
|
4 |
|
5 |
our %Info; |
6 |
$Info{q#Namazu#}->{Name} = q#Namazu#; |
7 |
$Info{q#Namazu#}->{q#Version#} = q#2005.0626.0234#; |
8 |
$Info{q#Namazu#}->{q#InterfaceVersion#} = q#2.9.1#; |
9 |
$Info{q#Namazu#}->{q#mkpluginVersion#} = q#2.1.21#; |
10 |
$Info{q#Namazu#}->{q#module_name#} = q#SuikaWiki::Plugin::plugin::Namazu1050526023438PsvN#; |
11 |
$Info{q#Namazu#}->{q#Date.RCS#} = q#$Date: 2005/02/06 12:25:59 $#; |
12 |
$Info{q#Namazu#}->{RequiredPlugin} = [q#WikiLinking#]; |
13 |
$Info{q#Namazu#}->{RequiredModule} = [q#Search::Namazu#]; |
14 |
$Info{q#Namazu#}->{Description} = [[q#Namazu interface#, q#en#, q##]]; |
15 |
$Info{q#Namazu#}->{License} = [[q#%%Perl%%#, q##, q##]]; |
16 |
$Info{q#Namazu#}->{Author} = [[[[q#Wakaba#, q#ja#, q#Latn#]], [[q#w@suika.fam.cx#]], [q##]]]; |
17 |
package SuikaWiki::Plugin::plugin::Namazu1050526023438PsvN; |
18 |
|
19 |
|
20 |
#line 1 "(WikiPlugin module source namazu.wp2, block Plugin/Use)" |
21 |
use Search::Namazu; |
22 |
use Message::Util::Error; |
23 |
my $WIKILINKING; |
24 |
my $WIKIRESOURCE; |
25 |
#line 1 "(WikiPlugin module Namazu, chunk 1)" |
26 |
|
27 |
{my $def = {q#Parameter#, {}, q#Description#, [], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; |
28 |
|
29 |
#line 1 "(WikiPlugin module source namazu.wp2, block FormattingRule[name()='[q#view#, q#view-resource#, q#form-input#]/namazu_search']/Formatting)" |
30 |
$p->{q#query#} = do { my $r = $f->parse_attr ($p=>q#query#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r}; |
31 |
$p->{query} ||= ($o->{wiki}->{input} ? |
32 |
$o->{wiki}->{input}->parameter ('search__query') : undef); |
33 |
unless (defined $p->{query} or length $p->{query}) { |
34 |
$p->{query} = join ' ', |
35 |
map {my $s = length $_ > 2 ? '*'.$_.'*' : $_; |
36 |
$s =~ s/^\*\*+//; $s =~ s/\*\*+$/*/; $s} |
37 |
@{$o->{wiki}->{var}->{page}}; |
38 |
} |
39 |
my $list = $p->{-parent}->append_new_node |
40 |
(type => '#element', |
41 |
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
42 |
local_name => 'ol'); |
43 |
my $template = $p->{template} || |
44 |
($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))->get_text |
45 |
(name => 'Namazu:Result:Item:Template', |
46 |
o => $o, wiki => $o->{wiki}); |
47 |
my @result = Search::Namazu::Search |
48 |
(index => $o->{wiki}->{config}->{path_to}->{namazu__index_dir}, |
49 |
query => $p->{query}, |
50 |
sortMethod => NMZ_SORTBYSCORE, |
51 |
sortOrder => NMZ_ASCENDSORT, |
52 |
lang => 'ja'); |
53 |
$p->{q#start#} = do { my $r = $f->parse_attr ($p=>q#start#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r};$p->{q#number#} = do { my $r = $f->parse_attr ($p=>q#number#, $o, -non_parsed_to_node => 1, %opt); ref $r?$r->inner_text:$r}; |
54 |
my $start = length $p->{start} ? $p->{start} : |
55 |
$o->{wiki}->{input}->parameter ('search--range-start') || 0; |
56 |
$p->{number} = $o->{wiki}->{input}->parameter ('search--range-number') |
57 |
unless length $p->{number}; |
58 |
my $end = $p->{number} ? $start + $p->{number} - 1 : $start + 29; |
59 |
$start = 0 if $start > $#result or $start < 0; |
60 |
$end = $#result if $end < $start or $end > $#result; |
61 |
$end = $start + 255 if $end > $start + 255; |
62 |
local $o->{var}->{search__result} = { |
63 |
min => 0, |
64 |
max => $#result, |
65 |
start => $start, |
66 |
end => $end, |
67 |
number => $p->{number} || 30, |
68 |
query => $p->{query}, |
69 |
param_prefix => 'search', |
70 |
}; |
71 |
for my $result (@result[$start..$end]) { |
72 |
next unless $result; |
73 |
my ($reluri, $absuri) = $o->{wiki}->{config}->{nmz__uri_to_uri} |
74 |
->($result->uri, o => $o); |
75 |
($WIKILINKING ||= SuikaWiki::Plugin->module_package ('WikiLinking'))->to_resource_by_uri_in_html ({ |
76 |
label => $template, |
77 |
} => { |
78 |
uri => $reluri, |
79 |
absolute_uri => $absuri, |
80 |
nmz__result => $result, |
81 |
}, { |
82 |
o => $o, |
83 |
parent => $list->append_new_node |
84 |
(type => '#element', |
85 |
namespace_uri => q#http://www.w3.org/1999/xhtml#, |
86 |
local_name => 'li'), |
87 |
nmz__query => $p->{query}, |
88 |
}); |
89 |
} |
90 |
if ($list->count) { |
91 |
$list->set_attribute (start => $start + 1); |
92 |
$f->parse_attr ($p=>q#post_list#, $o, -parent => $p->{-parent}, -non_parsed_to_node => 1, %opt); |
93 |
} else { |
94 |
$p->{-parent}->remove_child_node ($list); |
95 |
}}} |
96 |
#line 1 "(WikiPlugin module Namazu, chunk 2)" |
97 |
; |
98 |
$SuikaWiki::Plugin::Rule{view}->{namazu_search} = $def; |
99 |
$SuikaWiki::Plugin::Rule{view_resource}->{namazu_search} = $def; |
100 |
$SuikaWiki::Plugin::Rule{form_input}->{namazu_search} = $def; |
101 |
}; |
102 |
|
103 |
$SuikaWiki::Plugin::Rule{link_to_resource}->{nmz__rank} = {q#Parameter#, {}, q#Description#, [], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; |
104 |
|
105 |
#line 1 "(WikiPlugin module source namazu.wp2, block FormattingRule[name()='[q#link-to-resource#]/nmz__rank']/Formatting)" |
106 |
$p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->rank + 0);}} |
107 |
#line 1 "(WikiPlugin module Namazu, chunk 4)" |
108 |
; |
109 |
|
110 |
$SuikaWiki::Plugin::Rule{link_to_resource}->{nmz__score} = {q#Parameter#, {}, q#Description#, [], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; |
111 |
|
112 |
#line 1 "(WikiPlugin module source namazu.wp2, block FormattingRule[name()='[q#link-to-resource#]/nmz__score']/Formatting)" |
113 |
$p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->score + 0);}} |
114 |
#line 1 "(WikiPlugin module Namazu, chunk 6)" |
115 |
; |
116 |
|
117 |
$SuikaWiki::Plugin::Rule{link_to_resource}->{nmz__title} = {q#Parameter#, {}, q#Description#, [], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; |
118 |
|
119 |
#line 1 "(WikiPlugin module source namazu.wp2, block FormattingRule[name()='[q#link-to-resource#]/nmz__title']/Formatting)" |
120 |
my $title = $o->{link}->{dest}->{nmz__result}->title; |
121 |
$title =~ s/([0-9A-F][0-9A-F])/pack 'C', hex $1/ge and $title =~ s/\.txt$// |
122 |
if $title =~ /^(?:[0-9A-F][0-9A-F])+\.txt$/; |
123 |
$p->{-parent}->append_text ($title);}} |
124 |
#line 1 "(WikiPlugin module Namazu, chunk 8)" |
125 |
; |
126 |
|
127 |
$SuikaWiki::Plugin::Rule{link_to_resource}->{nmz__uri} = {q#Parameter#, {}, q#Description#, [], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; |
128 |
|
129 |
#line 1 "(WikiPlugin module source namazu.wp2, block FormattingRule[name()='[q#link-to-resource#]/nmz__uri']/Formatting)" |
130 |
$p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->uri);}} |
131 |
#line 1 "(WikiPlugin module Namazu, chunk 10)" |
132 |
; |
133 |
|
134 |
$SuikaWiki::Plugin::Rule{link_to_resource}->{nmz__summary} = {q#Parameter#, {}, q#Description#, [], q#main#, sub {my ($f, $rule_name, $p, $o, %opt) = @_; |
135 |
|
136 |
#line 1 "(WikiPlugin module source namazu.wp2, block FormattingRule[name()='[q#link-to-resource#]/nmz__summary']/Formatting)" |
137 |
$p->{-parent}->append_text ($o->{link}->{dest}->{nmz__result}->summary);}} |
138 |
#line 1 "(WikiPlugin module Namazu, chunk 12)" |
139 |
; |
140 |
|
141 |
package SuikaWiki::Plugin::Resource; |
142 |
|
143 |
our $BaseResource; |
144 |
$BaseResource->{q#und#}->{q##}->{q#Namazu:Result:Item:Template#} = q#%line (content => { {%nmz--score;} %link-to-it ( label => {%nmz--title;}p, description => {%nmz--title; <%uri-reference;>}p, ); }p); %line (content => {%nmz--summary;}p);#; |
145 |
package SuikaWiki::Plugin::Registry; |
146 |
|
147 |
$Info{q#Namazu#}->{provide} = {q#rule#, {q#link_to_resource#, [q#nmz__rank#, q#nmz__score#, q#nmz__title#, q#nmz__uri#, q#nmz__summary#], q#form_input#, [q#namazu_search#], q#view#, [q#namazu_search#], q#view_resource#, [q#namazu_search#]}}; |
148 |
|
149 |
1; |