/[webpac2]/Webpacus/lib/Webpacus/Model/WebPAC.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/Model/WebPAC.pm

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

revision 200 by dpavlin, Wed Nov 30 23:21:30 2005 UTC revision 222 by dpavlin, Mon Dec 5 19:15:01 2005 UTC
# Line 7  use base qw/ Line 7  use base qw/
7          Catalyst::Model          Catalyst::Model
8  /;  /;
9  use Data::Dumper;  use Data::Dumper;
10  use WebPAC::DB;  use WebPAC::Store 0.03;
11  use WebPAC::Output::TT 0.02;  use WebPAC::Output::TT 0.02;
12  use WebPAC::Search::Estraier 0.02;  use WebPAC::Search::Estraier 0.05;
13  use File::Slurp;  use File::Slurp;
14  use Time::HiRes;  use Time::HiRes;
15    
# Line 34  Configuration for hyperestraier in C<con Line 34  Configuration for hyperestraier in C<con
34    
35   # configuration for hyper estraier full text search engine   # configuration for hyper estraier full text search engine
36   hyperestraier:   hyperestraier:
37    url: 'http://localhost:1978/node/webpac2'    masterurl: 'http://localhost:1978/node/webpac2'
38      defaultnode: 'webpac2'
39      defaultdepth: 1
40    user: 'admin'    user: 'admin'
41    passwd: 'admin'    passwd: 'admin'
42    hits_on_page: 100    hits_on_page: 100
# Line 66  sub new { Line 68  sub new {
68    
69          $log->debug("using config:" . Dumper($est_cfg) );          $log->debug("using config:" . Dumper($est_cfg) );
70    
71            if (! $est_cfg->{database}) {
72                    my $defaultnode = $est_cfg->{defaultnode} || $log->logdie("can't find defaultnode in estraier configuration");
73                    $log->info("using default node $defaultnode");
74                    $est_cfg->{database} = $defaultnode;
75            }
76    
77          $self->{est} = new WebPAC::Search::Estraier( %{ $est_cfg } );          $self->{est} = new WebPAC::Search::Estraier( %{ $est_cfg } );
78    
79          # save config parametars in object          # save config parametars in object
80          foreach my $f (qw/db_path template_path hits_on_page webpac_encoding out_encoding/) {          foreach my $f (qw/db_path template_path hits_on_page webpac_encoding out_encoding defaultdepth/) {
81                  $self->{$f} = $c->config->{hyperestraier}->{$f} ||                  $self->{$f} = $c->config->{hyperestraier}->{$f} ||
82                          $c->config->{webpac}->{$f};                          $c->config->{webpac}->{$f};
83                  $log->debug("self->{$f} = " . $self->{$f});                  $log->debug("self->{$f} = " . $self->{$f});
# Line 79  sub new { Line 87  sub new {
87    
88          $log->debug("using db path '$db_path', template path '$template_path'");          $log->debug("using db path '$db_path', template path '$template_path'");
89    
90          $self->{db} = new WebPAC::DB(          $self->{db} = new WebPAC::Store(
91                  path => $db_path,                  path => $db_path,
92                  read_only => 1,                  read_only => 1,
93          );          );
# Line 118  sub new { Line 126  sub new {
126          get_attr => [ '@uri' ],          get_attr => [ '@uri' ],
127          max => 42,          max => 42,
128          template => 'result_template.tt',          template => 'result_template.tt',
129            depth => 1,
130    );    );
131    
132  All fields are standard C<WebPAC::Search::Estraier> parametars except  All fields are standard C<WebPAC::Search::Estraier> parametars except
# Line 156  sub search { Line 165  sub search {
165    
166          my $t = time();          my $t = time();
167    
168            # transfer depth of search
169            if (! $args->{depth}) {
170                    my $default = $self->{defaultdepth} || $log->logdie("can't find defaultdepth in estraier configuration");
171                    $args->{depth} = $default;
172                    $log->warn("using default search depth $default");
173            }
174    
175          my @results = $self->{est}->search( %{ $args } );          my @results = $self->{est}->search( %{ $args } );
176    
177          $times->{est} += time() - $t;          $times->{est} += time() - $t;

Legend:
Removed from v.200  
changed lines
  Added in v.222

  ViewVC Help
Powered by ViewVC 1.1.26