/[nn.old]/trunk/search/nn-swish.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/search/nn-swish.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 74 - (show annotations)
Tue Jun 25 15:06:47 2002 UTC (21 years, 9 months ago) by dpavlin
File MIME type: application/octet-stream
File size: 1797 byte(s)
Unable to calculate annotation data on binary file contents.
working title (utf8 -> iso8859-2 conversion)

1 #!/usr/bin/perl -w
2
3 use strict;
4 use CGI qw/:standard -no_xhtml/;
5 use Text::Query;
6 use CGI::Carp qw(fatalsToBrowser);
7 use SWISH;
8 use Unicode::String qw(utf8 utf16);
9 require Unicode::Map8;
10
11 my $dir='/home/dpavlin/nn/swish';
12
13 my $hits=0;
14
15 print header(-charset=>'iso-8859-2'),start_html(-title=>'NN pretrazivanje',-lang=>'hr'),start_form;
16 print "Potra¾i zakone sa riječima: ",textfield('search');
17 print submit(-value=>'prika¾i');
18 print end_form,hr;
19
20 if (param('search')) {
21
22 my $s=param('search');
23 $s=~tr/ššžčꊩŽČĘ/¹š¾čę©Š®ČĘ/; # 1250 -> iso8859-2
24 $s=~tr/¹©šŠčČęĘ¾®/sSdDcCcCzZ/;
25
26 my $l2_map = Unicode::Map8->new("ISO-8859-2") || die;
27 my $us = Unicode::String->new();
28
29 my $sh = SWISH->connect('Fork',
30 prog => "$dir/swish-e",
31 indexes => "$dir/nn.index",
32 properties => [qw/god br nr/],
33 results => sub {
34 my ($sh,$hit) = @_;
35
36 $us->utf8($hit->swishtitle);
37
38 print "<a href=\"",$hit->swishdocpath,"\"><tt>NN",$hit->god,"/",$hit->br,"</a> ",$hit->nr," </tt>",$l2_map->to8($us->utf16),"</a> [",$hit->swishrank,"]<br>\n";
39
40 # print $_[1]->as_string,"<br>\n";
41 # my @fields = $hit->field_names;
42 # print "Field '$_' = '", $hit->$_, "'<br>\n" for sort @fields;
43 },
44 );
45
46 die $SWISH::errstr unless $sh;
47
48 $hits = $sh->query("naslov_czs=($s)");
49
50 if ($hits > 0) {
51 print p,hr,"Našeno je $hits zakona...";
52 } else {
53 print p,"Nije našen niti jedan zakon... (",$sh->errstr,")";
54 }
55 } else {
56 print p('Kod pretra¾ivanja pretra¾ivač pronalazi sve zakone u kojima se pojavljuju <b>sve upisanje riječi</b>.',br,'Ako ispred riječi upi¹ete minus (-) neęe se prikazivati zakoni koji imaju takvu riječ. Npr. <tt>+kava +zakon -dopunama</tt>');
57 print p("Mo¾ete pročitati i <a href=\"http://www.rot13.org/~dpavlin/nn.html\">članak</a> o tome kako je ovaj pretra¾ivač napravljen i za¹to.");
58 }

Properties

Name Value
cvs2svn:cvs-rev 1.5
svn:executable *
svn:mime-type application/octet-stream

  ViewVC Help
Powered by ViewVC 1.1.26