--- Webpacus/lib/Webpacus/Model/WebPAC.pm 2005/11/22 12:57:20 94 +++ Webpacus/lib/Webpacus/Model/WebPAC.pm 2005/11/22 12:57:25 95 @@ -8,6 +8,8 @@ WebPAC::Search::Estraier /; use Data::Dumper; +use WebPAC::DB; +use WebPAC::Output::TT; =head1 NAME @@ -52,6 +54,23 @@ $self->{est} = new WebPAC::Search::Estraier( %{ $est_cfg } ); + my $db_path = $c->config->{webpac}->{db_path}; + my $template_path = $c->config->{webpac}->{template_path}; + + $log->debug("using db path '$db_path', template path '$template_path'"); + + $self->{db} = new WebPAC::DB( + path => $db_path, + read_only => 1, + ); + + $self->{out} = new WebPAC::Output::TT( + include_path => $template_path, + filters => { foo => sub { shift } }, + ); + + $self->{template} ||= $c->config->{webpac}->{template}; + return $self; } @@ -59,7 +78,11 @@ sub search { my ( $self, $query ) = @_; - $self->{log}->debug("search got query: $query<--"); + my $log = $self->{log}; + + $log->debug("search got query: $query<--"); + + my $template_filename = $self->{template}; my @results = $self->{est}->search( query => $query, @@ -67,7 +90,20 @@ max => 100, ); - return @results; + for my $i ( 0 .. $#results ) { + + my $mfn = $1 if ( $results[$i]->{'@uri'} =~ m#/(\d+)$#); + + $log->debug("load_ds( $mfn )"); + + my $ds = $self->{db}->load_ds( $mfn ) || next; + $results[$i]->{ html } = $self->{out}->apply( + template => $template_filename, + data => $ds, + ); + } + + return \@results; }