--- Webpacus/lib/Webpacus/Model/WebPAC.pm 2005/11/25 01:24:31 143 +++ Webpacus/lib/Webpacus/Model/WebPAC.pm 2005/12/25 23:31:59 322 @@ -7,10 +7,11 @@ Catalyst::Model /; use Data::Dumper; -use WebPAC::DB; -use WebPAC::Output::TT; -use WebPAC::Search::Estraier 0.02; +use WebPAC::Store 0.08; +use WebPAC::Output::TT 0.06; +use WebPAC::Search::Estraier 0.05; use File::Slurp; +use Time::HiRes; =head1 NAME @@ -33,10 +34,13 @@ # configuration for hyper estraier full text search engine hyperestraier: - url: 'http://localhost:1978/node/webpac2' + masterurl: 'http://localhost:1978/node/webpac2' + defaultnode: 'webpac2' + defaultdepth: 1 user: 'admin' passwd: 'admin' hits_on_page: 100 + hits_for_pager: 1000 webpac: db_path: '/data/webpac2/db' @@ -61,21 +65,33 @@ my $est_cfg = $c->config->{hyperestraier}; $est_cfg->{'log'} = $log; - $est_cfg->{encoding} = $est_cfg->{catalyst_encoding}; + $est_cfg->{encoding} = $est_cfg->{catalyst_encoding} || $c->config->{catalyst_encoding} or $c->log->fatal("can't find catalyst_encoding"); $log->debug("using config:" . Dumper($est_cfg) ); + if (! $est_cfg->{database}) { + my $defaultnode = $est_cfg->{defaultnode} || $log->logdie("can't find defaultnode in estraier configuration"); + $log->info("using default node $defaultnode"); + $est_cfg->{database} = $defaultnode; + } + $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; + # save config parametars in object + foreach my $f (qw/db_path template_path hits_on_page webpac_encoding out_encoding defaultdepth/) { + $self->{$f} = $c->config->{hyperestraier}->{$f} || + $c->config->{webpac}->{$f}; + $log->debug("self->{$f} = " . $self->{$f}); + } + my $db_path = $self->{db_path}; + my $template_path = $self->{template_path}; $log->debug("using db path '$db_path', template path '$template_path'"); - $self->{db} = new WebPAC::DB( + $self->{db} = new WebPAC::Store( path => $db_path, read_only => 1, + database => $est_cfg->{database}, ); $self->{out} = new WebPAC::Output::TT( @@ -98,87 +114,195 @@ "'" ); + $self->{databases} = $c->config->{databases} || $log->error("can't find databases in config"); + return $self; } -=head2 iconv_on_save - my $out = $m->iconv_on_save( $content ); +=head2 search -Convert data saved to disk in Webpac encoding. + my $m->search( + phrase => 'query phrase', + add_attr => \@add_attr + get_attr => [ '@uri' ], + max => 42, + template => 'result_template.tt', + depth => 1, + ); + +All fields are standard C parametars except +C