6 |
use HTML::Pager; |
use HTML::Pager; |
7 |
use HTML::FillInForm; |
use HTML::FillInForm; |
8 |
use SWISH; |
use SWISH; |
9 |
use Unicode::String qw(utf8 utf16); |
use Unicode::MapUTF8 qw(to_utf8 from_utf8 utf8_supported_charset); |
|
require Unicode::Map8; |
|
10 |
use DBI; |
use DBI; |
11 |
|
|
12 |
|
use lib '..'; |
13 |
|
use index_DBI; |
14 |
|
|
15 |
# configuration options |
# configuration options |
16 |
# FIX: they really should go in configuration file! |
# FIX: they really should go in configuration file! |
17 |
my $TEMPLATE_PATH = '/data/webpac/template_html'; |
my $TEMPLATE_PATH = '/data/webpac/template_html'; |
18 |
my $CHARSET = 'ISO-8859-2'; |
my $CHARSET = 'ISO-8859-2'; |
19 |
my $SWISH = '/data/swish/swish-e'; |
my $SWISH = '/usr/local/bin/swish-e'; |
20 |
my $INDEX = '/data/webpac/index/isis.index'; |
my $INDEX = '/data/webpac/index/isis.index'; |
21 |
my $MAX_HITS = 500; |
my $MAX_HITS = 500; |
22 |
my $ON_PAGE = 10; |
my $ON_PAGE = 10; |
93 |
|
|
94 |
my $tmpl = $self->load_tmpl('results.html'); |
my $tmpl = $self->load_tmpl('results.html'); |
95 |
|
|
|
my $l2_map = Unicode::Map8->new($CHARSET) || die; |
|
|
my $us = Unicode::String->new(); |
|
|
|
|
96 |
# call swish |
# call swish |
97 |
my $sh = SWISH->connect('Fork', |
my $sh = SWISH->connect('Fork', |
98 |
prog => $SWISH, |
prog => $SWISH, |
101 |
results => sub { |
results => sub { |
102 |
my ($sh,$hit) = @_; |
my ($sh,$hit) = @_; |
103 |
|
|
|
$us->utf8($hit->swishtitle); |
|
|
|
|
104 |
push @swish_results, { |
push @swish_results, { |
105 |
nr => ($#swish_results + 2), |
nr => ($#swish_results + 2), |
106 |
path => $hit->swishdocpath, |
path => $hit->swishdocpath, |
107 |
title => $l2_map->to8($us->utf16), |
title => to_utf8({ -string => $hit->swishtitle, -charset => $CHARSET }), |
108 |
rank => $hit->swishrank }; |
rank => $hit->swishrank }; |
109 |
|
|
110 |
# my @fields = $hit->field_names; |
# my @fields = $hit->field_names; |
168 |
|
|
169 |
my $q = $self->query(); |
my $q = $self->query(); |
170 |
|
|
171 |
|
my $field = $q->param("f$i"); |
172 |
|
my $limit = $q->param("v$i"); |
173 |
|
|
174 |
|
|
175 |
my $html; |
my $html; |
176 |
|
|
177 |
$html .= "show index of ".$q->param("f$i")." for ".$q->param("v$i"); |
my $index = new index_DBI(); |
178 |
|
|
179 |
|
if (! $index->check($field)) { |
180 |
|
my $tmpl = $self->load_tmpl('no_index.html'); |
181 |
|
$tmpl->param('field',$field); |
182 |
|
$html = $tmpl->output; |
183 |
|
return $html; |
184 |
|
} |
185 |
|
|
186 |
|
my @index_arr = $index->fetch($field,'item',$limit); |
187 |
|
|
188 |
|
$html .= "show index of <i>$field</i>"; |
189 |
|
$html .= " for <i>$limit</i>" if ($limit); |
190 |
|
|
191 |
|
while (my $row = shift @index_arr) { |
192 |
|
$html .= "<br>".$row->{item}."\n"; |
193 |
|
} |
194 |
|
|
195 |
return $html; |
return $html; |
196 |
} |
} |