/[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 157 by dpavlin, Sat Nov 26 16:21:51 2005 UTC revision 167 by dpavlin, Sat Nov 26 21:11:41 2005 UTC
# Line 68  sub new { Line 68  sub new {
68    
69          $self->{est} = new WebPAC::Search::Estraier( %{ $est_cfg } );          $self->{est} = new WebPAC::Search::Estraier( %{ $est_cfg } );
70    
71          my $db_path = $c->config->{webpac}->{db_path};          # save config parametars in object
72          my $template_path = $c->config->{webpac}->{template_path};          foreach my $f (qw/db_path template_path hits_on_page/) {
73          $self->{template_path} = $template_path;                  $self->{$f} = $c->config->{hyperestraier}->{$f} ||
74                            $c->config->{webpac}->{$f};
75                    $log->debug("self->{$f} = " . $self->{$f});
76            }
77            my $db_path = $self->{db_path};
78            my $template_path = $self->{template_path};
79    
80          $log->debug("using db path '$db_path', template path '$template_path'");          $log->debug("using db path '$db_path', template path '$template_path'");
81    
# Line 99  sub new { Line 104  sub new {
104                  "'"                  "'"
105          );          );
106    
         # save config parametars in object  
         foreach my $f (qw/hits_on_page/) {  
                 $self->{$f} = $c->config->{hyperestraier}->{$f};  
                 $log->debug("self->{$f} = " . $self->{$f});  
         }  
107    
108          return $self;          return $self;
109    
# Line 235  sub search { Line 235  sub search {
235          return \@html_results;          return \@html_results;
236  }  }
237    
238    =head2 record
239    
240      my $html = $m->record(
241            mfn => 42,
242            template => 'foo.tt',
243      );
244    
245    This will load one record, convert it to html using C<template> and return
246    it.
247    
248    =cut
249    
250    sub record {
251            my $self = shift;
252    
253            my $args = {@_};
254            my $log = $self->{log};
255            $log->debug("args: " . Dumper( $args ));
256    
257            foreach my $f (qw/mfn template/) {
258                    $log->die("need $f") unless ($args->{$f});
259            }
260    
261            my $mfn = $args->{mfn};
262    
263            my $ds = $self->{db}->load_ds( $mfn ) || $log->error("can't load_ds( $mfn )") && next;
264    
265            my $html = $self->{out}->apply(
266                    template => $args->{template},
267                    data => $ds,
268            );
269    
270            $html = $self->{iconv}->convert( $html ) || $log->error("can't convert: $html");
271    
272            return $html;
273    }
274    
275  =head2 save_html  =head2 save_html
276    
277    $m->save_html( '/full/path/to/file', $content );    $m->save_html( '/full/path/to/file', $content );

Legend:
Removed from v.157  
changed lines
  Added in v.167

  ViewVC Help
Powered by ViewVC 1.1.26