68 |
|
|
69 |
$self->{est} = new WebPAC::Search::Estraier( %{ $est_cfg } ); |
$self->{est} = new WebPAC::Search::Estraier( %{ $est_cfg } ); |
70 |
|
|
71 |
my $db_path = $c->config->{webpac}->{db_path}; |
# save config parametars in object |
72 |
my $template_path = $c->config->{webpac}->{template_path}; |
foreach my $f (qw/db_path template_path hits_on_page/) { |
73 |
$self->{template_path} = $template_path; |
$self->{$f} = $c->config->{hyperestraier}->{$f} || |
74 |
|
$c->config->{webpac}->{$f}; |
75 |
|
$log->debug("self->{$f} = " . $self->{$f}); |
76 |
|
} |
77 |
|
my $db_path = $self->{db_path}; |
78 |
|
my $template_path = $self->{template_path}; |
79 |
|
|
80 |
$log->debug("using db path '$db_path', template path '$template_path'"); |
$log->debug("using db path '$db_path', template path '$template_path'"); |
81 |
|
|
104 |
"'" |
"'" |
105 |
); |
); |
106 |
|
|
|
# save config parametars in object |
|
|
foreach my $f (qw/hits_on_page/) { |
|
|
$self->{$_} = $c->config->{$_}; |
|
|
$log->debug("self->{$_} = " . $c->config->{$_}); |
|
|
} |
|
107 |
|
|
108 |
return $self; |
return $self; |
109 |
|
|
235 |
return \@html_results; |
return \@html_results; |
236 |
} |
} |
237 |
|
|
238 |
|
=head2 record |
239 |
|
|
240 |
|
my $html = $m->record( |
241 |
|
mfn => 42, |
242 |
|
template => 'foo.tt', |
243 |
|
); |
244 |
|
|
245 |
|
This will load one record, convert it to html using C<template> and return |
246 |
|
it. |
247 |
|
|
248 |
|
=cut |
249 |
|
|
250 |
|
sub record { |
251 |
|
my $self = shift; |
252 |
|
|
253 |
|
my $args = {@_}; |
254 |
|
my $log = $self->{log}; |
255 |
|
$log->debug("args: " . Dumper( $args )); |
256 |
|
|
257 |
|
foreach my $f (qw/mfn template/) { |
258 |
|
$log->die("need $f") unless ($args->{$f}); |
259 |
|
} |
260 |
|
|
261 |
|
my $mfn = $args->{mfn}; |
262 |
|
|
263 |
|
my $ds = $self->{db}->load_ds( $mfn ) || $log->error("can't load_ds( $mfn )") && next; |
264 |
|
|
265 |
|
my $html = $self->{out}->apply( |
266 |
|
template => $args->{template}, |
267 |
|
data => $ds, |
268 |
|
); |
269 |
|
|
270 |
|
$html = $self->{iconv}->convert( $html ) || $log->error("can't convert: $html"); |
271 |
|
|
272 |
|
return $html; |
273 |
|
} |
274 |
|
|
275 |
=head2 save_html |
=head2 save_html |
276 |
|
|
277 |
$m->save_html( '/full/path/to/file', $content ); |
$m->save_html( '/full/path/to/file', $content ); |