line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::OpenSearch::Service; |
2
|
1
|
|
|
1
|
|
23962
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
3
|
|
|
|
|
|
|
our $VERSION = 0.02; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
494
|
use Kwiki::Plugin '-Base'; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
7
|
|
|
|
|
|
|
use Kwiki ':char_classes'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
const class_id => 'opensearch_service'; |
10
|
|
|
|
|
|
|
const class_title => 'OpenSearch Service'; |
11
|
|
|
|
|
|
|
const cgi_class => 'Kwiki::OpenSearch::Service::CGI'; |
12
|
|
|
|
|
|
|
const config_file => 'opensearch_service.yaml'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub register { |
15
|
|
|
|
|
|
|
$self->hub->config->add_file($self->config_file); |
16
|
|
|
|
|
|
|
my $registry = shift; |
17
|
|
|
|
|
|
|
$registry->add(action => "opensearch_service"); |
18
|
|
|
|
|
|
|
$registry->add(action => "opensearch_description"); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub opensearch_service { |
22
|
|
|
|
|
|
|
$self->hub->headers->content_type('application/rss+xml'); |
23
|
|
|
|
|
|
|
$self->template_process( |
24
|
|
|
|
|
|
|
"opensearch_rss.xml", |
25
|
|
|
|
|
|
|
pages => $self->perform_opensearch_service, |
26
|
|
|
|
|
|
|
q => $self->cgi->q, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub opensearch_description { |
31
|
|
|
|
|
|
|
$self->hub->headers->content_type('application/opensearch+xml'); |
32
|
|
|
|
|
|
|
$self->template_process("opensearch_description.xml"); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# XXX copied from Kwiki::LiveSearch |
36
|
|
|
|
|
|
|
sub perform_opensearch_service { |
37
|
|
|
|
|
|
|
my $query = $self->cgi->q; |
38
|
|
|
|
|
|
|
$query =~ s/[^$WORD\ \-\.\^\$\*\|\:]//g; |
39
|
|
|
|
|
|
|
[ |
40
|
|
|
|
|
|
|
grep { |
41
|
|
|
|
|
|
|
$_->content =~ m{$query}i and $_->active; |
42
|
|
|
|
|
|
|
} $self->pages->all |
43
|
|
|
|
|
|
|
] |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
package Kwiki::OpenSearch::Service::CGI; |
47
|
|
|
|
|
|
|
use Kwiki::CGI '-base'; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
cgi 'q'; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
package Kwiki::OpenSearch::Service; |
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
__DATA__ |