/[webpac]/trunk/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 /trunk/WebPac.pm

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

revision 11 by dpavlin, Wed Jan 22 20:24:32 2003 UTC revision 13 by dpavlin, Sun Feb 16 22:41:37 2003 UTC
# Line 11  use DBI; Line 11  use DBI;
11    
12  use lib '..';  use lib '..';
13  use index_DBI;  use index_DBI;
14    use back2html;
15    
16  # configuration options  # configuration options
17  # FIX: they really should go in configuration file!  # FIX: they really should go in configuration file!
18  my $TEMPLATE_PATH = '/data/webpac/template_html';  my $TEMPLATE_PATH = '/data/webpac/template_html';
19  my $CHARSET = 'ISO-8859-2';  my $CHARSET = 'ISO-8859-2';
20  my $SWISH = '/usr/local/bin/swish-e';  my $SWISH = '/usr/bin/swish-e';
21  my $INDEX = '/data/webpac/index/isis.index';  my $INDEX = '/data/webpac/index/isis.index';
22  my $MAX_HITS = 500;  my $MAX_HITS = 500;
23  my $ON_PAGE = 10;  my $ON_PAGE = 10;
# Line 97  sub show_results_list { Line 98  sub show_results_list {
98          my $sh = SWISH->connect('Fork',          my $sh = SWISH->connect('Fork',
99                  prog     => $SWISH,                  prog     => $SWISH,
100                  indexes  => $INDEX,                  indexes  => $INDEX,
101                  #properties  => [qw/god br nr/],                  properties  => [qw/swishdocpath swishrank swishtitle headline html/],
102                  results  => sub {                  results  => sub {
103                          my ($sh,$hit) = @_;                          my ($sh,$hit) = @_;
104    
105                          push @swish_results, {                          push @swish_results, {
106                                  nr => ($#swish_results + 2),                                  nr => ($#swish_results + 2),
107                                  path => $hit->swishdocpath,                                  path => $hit->swishdocpath,
108                                  title => to_utf8({ -string => $hit->swishtitle, -charset => $CHARSET }),                                  headline => from_utf8({ -string => $hit->headline, -charset => $CHARSET }),
109                                    html => back2html(from_utf8({ -string => $hit->html, -charset => $CHARSET })),
110                                  rank => $hit->swishrank };                                  rank => $hit->swishrank };
111    
 #                       my @fields = $hit->field_names;  
 #                       print "Field '$_' = '", $hit->$_, "'<br>\n" for sort @fields;  
112                  },                  },
113                  #startnum => 0,                  #startnum => 0,
114                  maxhits => $MAX_HITS,                  maxhits => $MAX_HITS,
# Line 171  sub show_index { Line 171  sub show_index {
171          my $field = $q->param("f$i");          my $field = $q->param("f$i");
172          my $limit = $q->param("v$i");          my $limit = $q->param("v$i");
173    
   
174          my $html;          my $html;
175    
176          my $index = new index_DBI();          my $index = new index_DBI();
177    
178          if (! $index->check($field)) {          my $total = $index->check($field);
179            if (! $total) {
180                  my $tmpl = $self->load_tmpl('no_index.html');                  my $tmpl = $self->load_tmpl('no_index.html');
181                  $tmpl->param('field',$field);                  $tmpl->param('field',$field);
182                  $html = $tmpl->output;                  $html = $tmpl->output;
183                  return $html;                  return $html;
184          }          }
185    
186          my @index_arr = $index->fetch($field,'item',$limit);          my $tmpl = $self->load_tmpl('index_res.html');
187            $tmpl->param('field',$field);
188            $tmpl->param('limit',$limit);
189            $tmpl->param('total',$total);
190    
191          $html .= "show index of <i>$field</i>";          my $pager = HTML::Pager->new(
192          $html .= " for <i>$limit</i>" if ($limit);                  query => $q,
193                    get_data_callback => sub {
194                            my ($offset, $rows) = @_;
195    
196          while (my $row = shift @index_arr) {                          my @result = $index->fetch($field,'item',$limit, $offset, $rows);
197                  $html .= "<br>".$row->{item}."\n";                          return \@result;
198          }                  },
199                    rows => $total,
200                    page_size => $ON_PAGE,
201                    persist_vars => [
202                            'rm',
203                            "f$i", "v$i", "f".$i."_index",
204                            'offset',
205                            ],
206                    debug => 1,
207                    template => $tmpl,
208            );
209    
210          return $html;          return $pager->output;
211  }  }
212    
213  1;  1;

Legend:
Removed from v.11  
changed lines
  Added in v.13

  ViewVC Help
Powered by ViewVC 1.1.26