32 |
|
|
33 |
# configuration for hyper estraier full text search engine |
# configuration for hyper estraier full text search engine |
34 |
hyperestraier: |
hyperestraier: |
35 |
url: 'http://localhost:1978/node/webpac2' |
url: 'http://localhost:1978/node/webpac2' |
36 |
user: 'admin' |
user: 'admin' |
37 |
passwd: 'admin' |
passwd: 'admin' |
38 |
|
|
39 |
|
webpac: |
40 |
|
db_path: '/data/webpac2/db' |
41 |
|
template_path: '/data/webpac2/conf/output/tt' |
42 |
|
template: 'html_ffzg_results_short.tt' |
43 |
|
# encoding comming from webpac |
44 |
|
webpac_encoding: 'iso-8859-2' |
45 |
|
# encoding expected by Catalyst |
46 |
|
out_encoding: 'UTF-8' |
47 |
|
|
48 |
=cut |
=cut |
49 |
|
|
78 |
filters => { foo => sub { shift } }, |
filters => { foo => sub { shift } }, |
79 |
); |
); |
80 |
|
|
81 |
|
# default template from config.yaml |
82 |
$self->{template} ||= $c->config->{webpac}->{template}; |
$self->{template} ||= $c->config->{webpac}->{template}; |
83 |
|
|
84 |
|
$self->{iconv} = new Text::Iconv( |
85 |
|
$c->config->{webpac}->{webpac_encoding}, |
86 |
|
$c->config->{webpac}->{out_encoding} |
87 |
|
); |
88 |
|
|
89 |
|
$log->debug("converting encoding from webpac_encoding '" . |
90 |
|
$c->config->{webpac}->{webpac_encoding} . |
91 |
|
"' to '" . |
92 |
|
$c->config->{webpac}->{out_encoding} . |
93 |
|
"'" |
94 |
|
); |
95 |
|
|
96 |
return $self; |
return $self; |
97 |
|
|
98 |
} |
} |
99 |
|
|
100 |
sub search { |
sub search { |
101 |
my ( $self, $query ) = @_; |
my ( $self, $query, $template ) = @_; |
102 |
|
|
103 |
my $log = $self->{log}; |
my $log = $self->{log}; |
104 |
|
|
105 |
$log->debug("search got query: $query<--"); |
$log->debug("search model query: -->$query<--"); |
106 |
|
|
107 |
my $template_filename = $self->{template}; |
my $template_filename = $template || $self->{template}; |
108 |
|
|
109 |
my @results = $self->{est}->search( |
my @results = $self->{est}->search( |
110 |
query => $query, |
query => $query, |
112 |
max => 100, |
max => 100, |
113 |
); |
); |
114 |
|
|
115 |
|
$log->debug("loading " . ($#results + 1) . " results"); |
116 |
|
|
117 |
|
my @html_results; |
118 |
|
|
119 |
for my $i ( 0 .. $#results ) { |
for my $i ( 0 .. $#results ) { |
120 |
|
|
121 |
my $mfn = $1 if ( $results[$i]->{'@uri'} =~ m#/(\d+)$#); |
my $mfn = $1 if ( $results[$i]->{'@uri'} =~ m#/(\d+)$#); |
122 |
|
|
123 |
$log->debug("load_ds( $mfn )"); |
# $log->debug("load_ds( $mfn )"); |
124 |
|
|
125 |
my $ds = $self->{db}->load_ds( $mfn ) || next; |
my $ds = $self->{db}->load_ds( $mfn ) || next; |
126 |
$results[$i]->{ html } = $self->{out}->apply( |
|
127 |
|
my $html = $self->{out}->apply( |
128 |
template => $template_filename, |
template => $template_filename, |
129 |
data => $ds, |
data => $ds, |
130 |
); |
); |
131 |
|
|
132 |
|
$html = $self->{iconv}->convert( $html ) || $log->error("can't convert: $html"); |
133 |
|
|
134 |
|
push @html_results, $html; |
135 |
|
|
136 |
} |
} |
137 |
|
|
138 |
return \@results; |
return \@html_results; |
139 |
} |
} |
140 |
|
|
141 |
|
|