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

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

revision 12 by dpavlin, Wed Jan 22 22:27:19 2003 UTC revision 41 by dpavlin, Sat Mar 15 21:34:36 2003 UTC
# Line 6  use strict; Line 6  use strict;
6  use HTML::Pager;  use HTML::Pager;
7  use HTML::FillInForm;  use HTML::FillInForm;
8  use SWISH;  use SWISH;
9  use Unicode::MapUTF8 qw(to_utf8 from_utf8 utf8_supported_charset);  use Text::Iconv;
10  use DBI;  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;
24    
25    Text::Iconv->raise_error(0);     # Conversion errors raise exceptions
26    
27    my $from_utf8 = Text::Iconv->new('UTF8', $CHARSET);
28    
29  sub setup {  sub setup {
30          my $self = shift;          my $self = shift;
# Line 87  sub show_results_list { Line 91  sub show_results_list {
91                                  $s.="$_* ";                                  $s.="$_* ";
92                          }                          }
93                  }                  }
94                    $s =~ s/\*+/*/g;
95    
96                  push @s_arr,$q->param("f$i")."_swish=($s)";                  push @s_arr,$q->param("f$i")."_swish=($s)";
97          }          }
# Line 97  sub show_results_list { Line 102  sub show_results_list {
102          my $sh = SWISH->connect('Fork',          my $sh = SWISH->connect('Fork',
103                  prog     => $SWISH,                  prog     => $SWISH,
104                  indexes  => $INDEX,                  indexes  => $INDEX,
105                  #properties  => [qw/god br nr/],                  properties  => [qw/swishdocpath swishrank swishtitle headline html/],
106                  results  => sub {                  results  => sub {
107                          my ($sh,$hit) = @_;                          my ($sh,$hit) = @_;
108    
109                          push @swish_results, {                          push @swish_results, {
110                                  nr => ($#swish_results + 2),                                  nr => ($#swish_results + 2),
111                                  path => $hit->swishdocpath,                                  path => $hit->swishdocpath,
112                                  title => to_utf8({ -string => $hit->swishtitle, -charset => $CHARSET }),                                  headline => $from_utf8->convert($hit->headline),
113                                    html => back2html($from_utf8->convert($hit->html)),
114                                  rank => $hit->swishrank };                                  rank => $hit->swishrank };
115    
 #                       my @fields = $hit->field_names;  
 #                       print "Field '$_' = '", $hit->$_, "'<br>\n" for sort @fields;  
116                  },                  },
117                  #startnum => 0,                  #startnum => 0,
118                  maxhits => $MAX_HITS,                  maxhits => $MAX_HITS,
# Line 188  sub show_index { Line 192  sub show_index {
192          $tmpl->param('limit',$limit);          $tmpl->param('limit',$limit);
193          $tmpl->param('total',$total);          $tmpl->param('total',$total);
194    
195    # FIX: I should set offset and leave out limit from fetch!!
196    #       if (! $q->param("PAGER_offset") {
197    #               $q->param("Pager_offet)
198    #       }
199    
200          my $pager = HTML::Pager->new(          my $pager = HTML::Pager->new(
201                  query => $q,                  query => $q,
202                  get_data_callback => sub {                  get_data_callback => sub {

Legend:
Removed from v.12  
changed lines
  Added in v.41

  ViewVC Help
Powered by ViewVC 1.1.26