/[webpac2]/Webpacus/lib/Webpacus/Controller/Search.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /Webpacus/lib/Webpacus/Controller/Search.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 382 by dpavlin, Sun Jan 22 02:52:24 2006 UTC revision 407 by dpavlin, Mon Feb 20 15:33:03 2006 UTC
# Line 4  use strict; Line 4  use strict;
4  use warnings;  use warnings;
5  use base 'Catalyst::Controller';  use base 'Catalyst::Controller';
6    
 use Data::Dumper;  
   
7  use lib '/data/webpac2/lib';  use lib '/data/webpac2/lib';
8  use WebPAC::Search::Estraier 0.03;  use WebPAC::Search::Estraier 0.03;
9    
# Line 33  Catalyst Controller for search fields Hy Line 31  Catalyst Controller for search fields Hy
31  sub default : Private {  sub default : Private {
32      my ( $self, $c ) = @_;      my ( $self, $c ) = @_;
33    
34      $c->log->debug("default search got param: ".Dumper($c->req->params));          $c->log->dumper($c->req->params, 'params');
35    
36      $c->stash->{template} = 'search.tt';      $c->stash->{template} = 'search.tt';
37  }  }
# Line 64  sub suggest : Local { Line 62  sub suggest : Local {
62          my $log = $c->log;          my $log = $c->log;
63    
64          my $webpac = $c->comp('Model::WebPAC');          my $webpac = $c->comp('Model::WebPAC');
65            #$c->log->dumper( $c->stash, 'stash' );
66            $webpac->setup_site( $c->stash->{site} );
67    
68          my $q = $c->req->params->{ $search || 'all' } || $c->response->body("no results");          my $q = $c->req->params->{ $search || 'all' } || $c->response->body("no results");
69    
# Line 134  sub results_ajax : Path( 'results/ajax' Line 134  sub results_ajax : Path( 'results/ajax'
134    
135          my $params = $c->req->params;          my $params = $c->req->params;
136          my $webpac = $c->comp('Model::WebPAC');          my $webpac = $c->comp('Model::WebPAC');
137            $webpac->setup_site( $c->stash->{site} );
138          my $log = $c->log;          my $log = $c->log;
139    
140          $log->debug("results got params: " . Dumper( $params ) );          $log->dumper($params, 'params');
141    
142          if (! $params->{_page} || $params->{_page} < 1) {          if (! $params->{_page} || $params->{_page} < 1) {
143                  $params->{_page} = 1;                  $params->{_page} = 1;
# Line 188  sub results_ajax : Path( 'results/ajax' Line 189  sub results_ajax : Path( 'results/ajax'
189    
190          $log->debug("using template $template to produce $hits_on_page results");          $log->debug("using template $template to produce $hits_on_page results");
191    
192          $c->stash->{html_results} = sub {          $c->stash->{html_results} = $webpac->search(
                 my $res = $webpac->search(  
193                          phrase => $q,                          phrase => $q,
194                          template => $template,                          template => $template,
195                          add_attr => $c->{stash}->{attr},                          add_attr => $c->{stash}->{attr},
196                          get_attr => [ '@uri' ],                          get_attr => [ '@uri' ],
197                          max => $hits_on_page,                          max => $hits_on_page,
198                          page => $params->{'_page'},                          page => $params->{'_page'},
199                  );          );
200  #               $log->debug("controller got " . ( $#{$res} + 1 ) . " results for '$q' " . Dumper( $res ));  
201                  return $res;          $c->stash->{hints} = $webpac->hints;
         };  
202    
203          $c->stash->{phrase} = $q;          $c->stash->{phrase} = $q;
204          $c->stash->{page} = $params->{'_page'};          $c->stash->{page} = $params->{'_page'};
# Line 246  forwarded to C</editor/record> Line 245  forwarded to C</editor/record>
245  sub record : Local {  sub record : Local {
246          my ( $self, $c ) = @_;          my ( $self, $c ) = @_;
247    
248          $c->forward( '/editor/record' );          $c->detach( '/editor/record' );
249  }  }
250    
251  =back  =back

Legend:
Removed from v.382  
changed lines
  Added in v.407

  ViewVC Help
Powered by ViewVC 1.1.26