--- Webpacus/lib/Webpacus/Model/WebPAC.pm 2005/11/22 14:45:17 100 +++ Webpacus/lib/Webpacus/Model/WebPAC.pm 2005/11/26 16:21:51 157 @@ -5,11 +5,13 @@ use lib '/data/webpac2/lib'; use base qw/ Catalyst::Model - WebPAC::Search::Estraier /; use Data::Dumper; use WebPAC::DB; use WebPAC::Output::TT; +use WebPAC::Search::Estraier 0.02; +use File::Slurp; +use Time::HiRes; =head1 NAME @@ -35,6 +37,7 @@ url: 'http://localhost:1978/node/webpac2' user: 'admin' passwd: 'admin' + hits_on_page: 100 webpac: db_path: '/data/webpac2/db' @@ -59,12 +62,15 @@ my $est_cfg = $c->config->{hyperestraier}; $est_cfg->{'log'} = $log; + $est_cfg->{encoding} = $est_cfg->{catalyst_encoding}; + $log->debug("using config:" . Dumper($est_cfg) ); $self->{est} = new WebPAC::Search::Estraier( %{ $est_cfg } ); my $db_path = $c->config->{webpac}->{db_path}; my $template_path = $c->config->{webpac}->{template_path}; + $self->{template_path} = $template_path; $log->debug("using db path '$db_path', template path '$template_path'"); @@ -78,6 +84,7 @@ filters => { foo => sub { shift } }, ); + # default template from config.yaml $self->{template} ||= $c->config->{webpac}->{template}; $self->{iconv} = new Text::Iconv( @@ -92,26 +99,96 @@ "'" ); + # save config parametars in object + foreach my $f (qw/hits_on_page/) { + $self->{$f} = $c->config->{hyperestraier}->{$f}; + $log->debug("self->{$f} = " . $self->{$f}); + } + return $self; } +=head2 iconv_on_save + + my $out = $m->iconv_on_save( $content ); + +Convert data saved to disk in Webpac encoding. + +=cut + +sub iconv_on_save { + my $self = shift; + + $self->{iconv_save} ||= new Text::Iconv( + $self->config->{webpac}->{out_encoding}, + $self->config->{webpac}->{webpac_encoding}, + ); + + $self->{iconv_save}->convert( @_ ); +} + + +=head2 search + + my $m->search( + phrase => 'query phrase', + add_attr => \@add_attr + get_attr => [ '@uri' ], + max => 42, + template => 'result_template.tt', + ); + +All fields are standard C parametars except +C