line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AxKit::XSP::Swish; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
@ISA = ('Apache::AxKit::Language::XSP::TaglibHelper'); |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# Swish-e Taglib |
6
|
|
|
|
|
|
|
$VERSION = '0.2'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$NS = 'http://nexus-is.ca/NS/xsp/swish/v1'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@EXPORT_TAGLIB = ( |
11
|
|
|
|
|
|
|
'send($index,$query;$title,$props,$sort,$context,$limit):as_xml=1', |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
772
|
use vars qw/@ISA $VERSION $NS @EXPORT_TAGLIB/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
79
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# libs and prototypes |
17
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
18
|
1
|
|
|
1
|
|
2082
|
use SWISHE; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Apache::AxKit::Language::XSP::TaglibHelper; |
20
|
|
|
|
|
|
|
sub parse_char { Apache::AxKit::Language::XSP::TaglibHelper::parse_char(@_); } |
21
|
|
|
|
|
|
|
sub parse_start { Apache::AxKit::Language::XSP::TaglibHelper::parse_start(@_); } |
22
|
|
|
|
|
|
|
sub parse_end { Apache::AxKit::Language::XSP::TaglibHelper::parse_end(@_); } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
## Taglib subs |
26
|
|
|
|
|
|
|
sub send ($$;$$$$$) { |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my ($index,$query,$title,$props,$sort,$context,$limit) = @_; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
die "No index file provided" unless $index; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $handle = SwishOpen( $index ) or die "Failed to open index: $index check path or permissions"; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Use an array for a hash slice when reading results. |
35
|
|
|
|
|
|
|
my @labels = qw/ |
36
|
|
|
|
|
|
|
rank |
37
|
|
|
|
|
|
|
file_name |
38
|
|
|
|
|
|
|
title |
39
|
|
|
|
|
|
|
content_length |
40
|
|
|
|
|
|
|
/; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $num_results = SwishSearch( |
43
|
|
|
|
|
|
|
$handle, |
44
|
|
|
|
|
|
|
$query, |
45
|
|
|
|
|
|
|
$context, |
46
|
|
|
|
|
|
|
$props, |
47
|
|
|
|
|
|
|
$sort, |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
unless ( $num_results ) { |
51
|
|
|
|
|
|
|
my $error = SwishError( $handle ); |
52
|
|
|
|
|
|
|
SwishClose ($handle); |
53
|
|
|
|
|
|
|
return "No Results$error"; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my %result; |
57
|
|
|
|
|
|
|
my %props; |
58
|
|
|
|
|
|
|
my @properties = split /\s+/, $props; |
59
|
|
|
|
|
|
|
my $return_list=""; |
60
|
|
|
|
|
|
|
my $count=1; |
61
|
|
|
|
|
|
|
if ($limit == undef) { $limit = '1000000';} elsif ($limit < 0) { $limit = 0 } # max results hard coded to 1M |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
while ( ( ( @result{ @labels }, @props{@properties} ) = SwishNext( $handle ) ) && ($count <= $limit) ) { |
64
|
|
|
|
|
|
|
$return_list .= ""; |
65
|
|
|
|
|
|
|
for ( @labels ) { |
66
|
|
|
|
|
|
|
$return_list .= "<$_>" . $result{$_} . "$_>"; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
for ( @properties ) { |
69
|
|
|
|
|
|
|
$return_list .= "<$_>" . $props{$_} . "$_>"; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
$return_list .= ""; |
72
|
|
|
|
|
|
|
$count ++; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Free the memory. |
76
|
|
|
|
|
|
|
SwishClose( $handle ); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return ($title) ? ('' . $return_list . ''):($return_list); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |