--- Webpacus/lib/Webpacus/Controller/Search.pm 2005/11/26 01:54:31 153 +++ Webpacus/lib/Webpacus/Controller/Search.pm 2005/11/26 01:54:42 155 @@ -12,15 +12,15 @@ =head1 NAME -Webpacus::Controller::Search - Catalyst Controller +Webpacus::Controller::Search - Search WebPAC data =head1 SYNOPSIS -See L +See L, L =head1 DESCRIPTION -Catalyst Controller for autocompleting search fields. +Catalyst Controller for search fields Hyper Estraier =head1 METHODS @@ -39,6 +39,10 @@ Returns results for URLs like C +It will return field from URL (C in example>) and use +same filed in paramerers (comming from form or URL) or if it doesn't +exist field named C. + =cut sub suggest : Regex('^search/suggest/*([^/]*)') { @@ -48,10 +52,7 @@ my $log = $c->log; - my $est_conf = $c->config->{hyperestraier}; - $est_conf->{log} = $c->log; - - my $est = new WebPAC::Search::Estraier( %{ $est_conf } ); + my $webpac = $c->comp('Model::WebPAC'); my $q = $c->req->params->{$what} || $c->req->params->{all} || $c->res->output("no results"); @@ -59,14 +60,18 @@ $log->info("search for '$q' in $what\n"); - my $max = $est_conf->{'hits_for_suggest'}; + my $max = $c->config->{'hits_for_suggest'}; if (! $max) { $log->info("hits_for_suggest isn't defined, defaulting to 10"); $c->config->{'hits_for_suggest'} = 10; $max = 10; } - my @hits = $est->search( phrase => $q, max => $max, get_attr => [ $what ] ); + my @hits = $webpac->search( + phrase => $q, + max => $max, + get_attr => [ $what ], + ); my $used; my @suggestions; @@ -138,14 +143,19 @@ my $q = join(" $operator ", @words); - my $template = $params->{'_template'}; + my $template = $params->{'_template'} || $c->config->{webpac}->{template}; + + $log->die("can't find _template or default from configuration!") unless ($template); + $log->debug("using template $template"); $c->stash->{html_results} = sub { my $res = $webpac->search( phrase => $q, template => $template, - add_attr => \@attr + add_attr => \@attr, + get_attr => [ '@uri' ], + max => $c->config->{'hits_on_page'}, ); # $log->debug("controller got " . ( $#{$res} + 1 ) . " results for '$q' " . Dumper( $res )); return $res;