/[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 73 - (show annotations)
Thu Jun 20 07:57:05 2002 UTC (21 years, 10 months ago) by dpavlin
File MIME type: application/octet-stream
File size: 1767 byte(s)
Unable to calculate annotation data on binary file contents.
nove upute

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 require Unicode::Map8;
9
10 my $dir='/home/dpavlin/nn/swish';
11
12 my $hits=0;
13
14 print header(-charset=>'iso-8859-2'),start_html(-title=>'NN pretrazivanje',-lang=>'hr'),start_form;
15 print "Potra¾i zakone sa riječima: ",textfield('search');
16 print submit(-value=>'prika¾i');
17 print end_form,hr;
18
19 if (param('search')) {
20
21 my $s=param('search');
22 $s=~tr/ššžčꊩŽČĘ/¹š¾čę©Š®ČĘ/; # 1250 -> iso8859-2
23 $s=~tr/¹©šŠčČęĘ¾®/sSdDcCcCzZ/;
24
25 my $l2_map = Unicode::Map8->new("ISO-8859-2") || die;
26 #my $utf8_map = Unicode::Map8->new("utf8") || die;
27
28 my $sh = SWISH->connect('Fork',
29 prog => "$dir/swish-e",
30 indexes => "$dir/nn.index",
31 properties => [qw/god br nr/],
32 results => sub {
33 my ($sh,$hit) = @_;
34
35 my $us=$hit->swishtitle;
36
37 print "<a href=\"",$hit->swishdocpath,"\"><tt>NN",$hit->god,"/",$hit->br,"</a> ",$hit->nr," </tt>",$hit->swishtitle,"</a> [",$hit->swishrank,"]<br>\n";
38
39 # print $_[1]->as_string,"<br>\n";
40 # my @fields = $hit->field_names;
41 # print "Field '$_' = '", $hit->$_, "'<br>\n" for sort @fields;
42 },
43 );
44
45 die $SWISH::errstr unless $sh;
46
47 $hits = $sh->query("naslov_czs=($s)");
48
49 if ($hits > 0) {
50 print p,hr,"Našeno je $hits zakona...";
51 } else {
52 print p,"Nije našen niti jedan zakon... (",$sh->errstr,")";
53 }
54 } else {
55 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>');
56 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.");
57 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26