use SWISH;
use Unicode::String qw(utf8 utf16);
require Unicode::Map8;
+use DBI;
# configuration options
# FIX: they really should go in configuration file!
$self->run_modes(
'search' => 'show_search_form',
'results' => 'show_results_list',
-# 'user' => 'show_user_detail'
+# 'user' => 'show_user_detail',
+ 'index' => 'show_index',
);
$self->start_mode('search');
$self->mode_param('rm');
my @swish_results; # results from swish
# load template for this page
- my $tmpl = $self->load_tmpl('results.html');
my @s_arr; # all queries are located here
for(my $i = 1; $i <=10; $i++) {
- last if (! $q->param("f$i"));
+ return show_index($self, $i) if ($q->param("f".$i."_index"));
+ next if (! $q->param("f$i"));
next if (! $q->param("v$i"));
# re-write query from +/- to and/and not
}
}
- push @s_arr,$q->param("f$i")."=($s)";
+ push @s_arr,$q->param("f$i")."_swish=($s)";
}
+ my $tmpl = $self->load_tmpl('results.html');
+
my $l2_map = Unicode::Map8->new($CHARSET) || die;
my $us = Unicode::String->new();
return $html;
}
+sub show_index {
+ my $self = shift;
+ my $i = shift; # field number
+
+ my $q = $self->query();
+
+ my $html;
+
+ $html .= "show index of ".$q->param("f$i")." for ".$q->param("v$i");
+
+
+ return $html;
+}
+
1;
use XML::Simple;
use Text::Unaccent 1.02; # 1.01 won't compile on my platform,
require Unicode::Map8;
+use DBI;
my $config=XMLin(undef, forcearray => [ 'isis' ], forcecontent => 1);
+my $dbh = DBI->connect("DBI:Pg:dbname=webpac","","") || die $DBI::errstr; # FIX
+# FIX; select relname from pg_class where relname like 'index_%' ;
+$dbh->begin_work || die $dbh->errstr();
+
+$dbh->do("delete from index_author") || die $dbh->errstr();
+$dbh->do("delete from index_title") || die $dbh->errstr();
my %opts;
foreach my $field (keys %{$config->{indexer}}) {
my $display_data = "";
+ my $swish_data = "";
my $index_data = "";
foreach my $x (@{$config->{indexer}->{$field}->{isis}}) {
my $display_tmp = "";
+ my $swish_tmp = "";
my $index_tmp = "";
my $format = $x->{content};
- my $i = 1; # index only
+ my $s = 1; # swish only
my $d = 1; # display only
- $i = 0 if (lc($x->{type}) eq "display");
- $d = 0 if (lc($x->{type}) eq "index");
-#print "## i: $i d: $d ## $format ##";
+ my $i = 0; # index only
+ $s = 0 if (lc($x->{type}) eq "display");
+ $d = 0 if (lc($x->{type}) eq "swish");
+ ($s,$d,$i) = (0,0,1) if (lc($x->{type}) eq "index");
+#print STDERR "## s: $s d: $d i: $i ## $format ##\n";
# parse format
my $prefix = "";
if ($format =~ s/^([^\d]+)//) {
if ($isis_tmp) {
# $display_tmp .= $prefix . "/$1/$2/".$isis_tmp if ($d);
$display_tmp .= $prefix . $isis_tmp if ($d);
- $index_tmp .= $isis_tmp." " if ($i);
-#print " $isis_tmp <--\n";
+ $swish_tmp .= $isis_tmp." " if ($s);
+ $index_tmp .= $prefix . $isis_tmp if ($i);
+#print STDERR " $isis_tmp <--\n";
}
$prefix = "";
} elsif ($format =~ s/^([^\d]+)//) {
}
# add suffix
$display_tmp .= $prefix if ($display_tmp);
+ $index_tmp .= $prefix if ($index_tmp);
# $display_data .= $display_tmp if ($display_tmp ne "");
-# $index_data .= $index_tmp if ($index_tmp ne "");
+# $swish_data .= $swish_tmp if ($swish_tmp ne "");
$display_data .= $display_tmp;
+ $swish_data .= $swish_tmp;
$index_data .= $index_tmp;
}
-#print "--display:$display_data\n--index:$index_data\n";
+#print "--display:$display_data\n--swish:$swish_data\n";
#$xml->{$field."_display"} = $isis_map->tou($display_data)->utf8 if ($display_data);
- #$xml->{$field."_index"} = unac_string($config->{isis_codepage},$index_data) if ($index_data);
+ #$xml->{$field."_swish"} = unac_string($config->{isis_codepage},$swish_data) if ($swish_data);
$xml->{$field."_display" } = [ $isis_map->tou($display_data)->utf8 ] if ($display_data);
- $xml->{$field."_index"} = [ unac_string($config->{isis_codepage},$index_data)." jabuka" ] if ($index_data);
-
+ $xml->{$field."_swish"} = [ unac_string($config->{isis_codepage},$swish_data) ] if ($swish_data);
+
+ # index
+ if ($index_data && $index_data ne "") {
+ my $sql = "select $field from index_$field where upper($field)=upper(?)";
+ my $sth = $dbh->prepare($sql) || die $dbh->errstr();
+ $sth->execute($index_data) || die "SQL: $sql; ".$dbh->errstr();
+#print STDERR "--->$index_data<---\n";
+ if (! $sth->fetchrow_hashref) {
+ my $sql = "insert into index_$field values (?)";
+ my $sth = $dbh->prepare($sql) || die $dbh->errstr();
+#print STDERR "$sql: $index_data<!----\n";
+ $sth->execute($index_data) || die "SQL: $sql; ".$dbh->errstr();
+ }
+ }
+
}
if ($xml) {
return XMLout($xml, rootname => 'xml', keeproot => 0, noattr => 0 );
print STDERR "\n";
}
+$dbh->commit || die $dbh->errstr();
1;
__END__
>
<!--
- <isis type="index|display">_pre_000x_sep_000x_sep_000x_post_</isis>
+ <isis type="swish|display|index">_pre_000x_sep_000x_sep_000x_post_</isis>
-->
<indexer>
<headline>
</headline>
<author>
- <isis>700a 700b</isis>
+ <isis>700a, 700b</isis>
<isis>701a 701b</isis>
<isis>701c 701d</isis>
<isis>710a : 710b , 710c</isis>
<isis>711a : 711b , 711c</isis>
<isis>(711d ; 711f ; 711e)</isis>
<isis>503a, 503b</isis>
- <isis type="index">702</isis>
- <isis type="index">200f 200g</isis>
- <isis type="display">205</isis>
+ <isis type="swish">702</isis>
+ <isis type="swish">200f 200g</isis>
+ <isis type="index">700a, 700b</isis>
</author>
<title>
- <isis>200a ; $200k = $200d : 200e / 200f ; 200g. 200c / 200x ; 200y</isis>
- <isis type="index">532</isis>
- <isis type="index">424</isis>
- <isis type="index">230a 230e</isis>
- <isis type="index">231a 231e</isis>
- <isis type="index">232a 232e</isis>
- <isis type="index">233a 233e</isis>
+ <isis>200a ; 200k = 200d : 200e / 200f ; 200g. 200c / 200x ; 200y</isis>
+ <isis type="swish">532</isis>
+ <isis type="swish">424</isis>
+ <isis type="swish">230a 230e</isis>
+ <isis type="swish">231a 231e</isis>
+ <isis type="swish">232a 232e</isis>
+ <isis type="swish">233a 233e</isis>
<isis type="display"><br>230v : 230a. - 250. - 260<br>ISBN 290</isis>
<isis type="display"><br>231v : 231a. - 251. - 261<br>ISBN 291</isis>
<isis type="display"><br>232v : 232a. - 252. - 262<br>ISBN 292</isis>
<isis type="display"><br>233v : 233a. - 253. - 263<br>ISBN 293</isis>
- <isis type="index">270</isis>
- <isis type="index">271</isis>
- <isis type="index">272</isis>
- <isis type="index">273</isis>
+ <isis type="swish">270</isis>
+ <isis type="swish">271</isis>
+ <isis type="swish">272</isis>
+ <isis type="swish">273</isis>
</title>
</indexer>
#MetaNameAlias swishtitle title
PropertyNameAlias swishtitle headline_display
#PropertyNameAlias swishdefault title_display
+MetaNameAlias xml xml_swish
#MetaNamesRank -4 publisher
#MetaNamesRank 0 title.index
<td class="inputfield" width="280" > \r
<input type="hidden" name="f2" value="author">\r
<input size="30" type="text" name="v2" value="">\r
- index</td>\r
+ <input type=submit value="index" name="f2_index" class="navigacija">\r
+ </td>\r
<td class="example" >npr. </td>\r
</tr>\r
<tr> \r
<td class="inputfield" width="280"> \r
<input type="hidden" name="f3" value="title">\r
<input size="30" type="text" name="v3">\r
- index </td>\r
+ <input type=submit value="index" name="f3_index" class="navigacija">\r
+ </td>\r
<td class="example">npr.</td>\r
</tr>\r
<tr> \r
<td class="inputfield" width="280"> \r
<input type="hidden" name="f4" value="publisher">\r
<input size="30" type="text" name="v4">\r
- index </td>\r
+ <input type=submit value="index" name="f4_index" class="navigacija">\r
+ </td>\r
<td class="example">npr.</td>\r
</tr>\r
<tr> \r
<td class="inputfield" width="280"> \r
<input type="hidden" name="f5" value="isn">\r
<input size="15" type="text" name="v5">\r
- index </td>\r
+ <input type=submit value="index" name="f5_index" class="navigacija">\r
+ </td>\r
<td class="example">npr.</td>\r
</tr>\r
<tr> \r
<option value="610">Tema (podruèje)</option>\r
<option value="225">Nakl. cjelina</option>\r
<option value="300+">Napomene </option>\r
- <option value="330">Sadrµaj </option>\r
+ <option value="330">Sadr¾aj </option>\r
<option value="464">Analitika</option>\r
<option value="675">UDK </option>\r
<option value="686">CC </option>\r
</td>\r
<td valign="bottom" width="280"> \r
<input size="30" name="v9">\r
- index </td>\r
+ <input type=submit value="index" name="f9_index" class="navigacija">\r
+ </td>\r
<td> </td>\r
</tr>\r
<tr> \r
--- /dev/null
+--
+-- Selected TOC Entries:
+--
+\connect - dpavlin
+
+DROP INDEX "ind_index_author2";
+DROP INDEX "ind_index_author";
+DROP INDEX "ind_index_title2";
+DROP INDEX "ind_index_title";
+DROP TABLE "index_author";
+DROP PROCEDURAL LANGUAGE 'plpgsql';
+\connect - postgres
+
+DROP FUNCTION "plpgsql_call_handler" ();
+\connect - dpavlin
+
+DROP TABLE "index_title";
+--
+-- TOC Entry ID 2 (OID 831643)
+--
+-- Name: index_title Type: TABLE Owner: dpavlin
+--
+
+CREATE TABLE "index_title" (
+ "title" character varying(255)
+);
+
+\connect - postgres
+
+--
+-- TOC Entry ID 8 (OID 834826)
+--
+-- Name: "plpgsql_call_handler" () Type: FUNCTION Owner: postgres
+--
+
+CREATE FUNCTION "plpgsql_call_handler" () RETURNS opaque AS '/usr/lib/postgresql/lib/plpgsql.so', 'plpgsql_call_handler' LANGUAGE 'C';
+
+--
+-- TOC Entry ID 9 (OID 834827)
+--
+-- Name: plpgsql Type: PROCEDURAL LANGUAGE Owner:
+--
+
+CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER "plpgsql_call_handler" LANCOMPILER 'PL/pgSQL';
+
+\connect - dpavlin
+
+--
+-- TOC Entry ID 3 (OID 834828)
+--
+-- Name: index_author Type: TABLE Owner: dpavlin
+--
+
+CREATE TABLE "index_author" (
+ "author" character varying(255)
+);
+
+--
+-- TOC Entry ID 4 (OID 831645)
+--
+-- Name: "ind_index_title" Type: INDEX Owner: dpavlin
+--
+
+CREATE INDEX ind_index_title ON index_title USING btree (title);
+
+--
+-- TOC Entry ID 5 (OID 831646)
+--
+-- Name: "ind_index_title2" Type: INDEX Owner: dpavlin
+--
+
+CREATE INDEX ind_index_title2 ON index_title USING btree (upper(title));
+
+--
+-- TOC Entry ID 6 (OID 834830)
+--
+-- Name: "ind_index_author" Type: INDEX Owner: dpavlin
+--
+
+CREATE UNIQUE INDEX ind_index_author ON index_author USING btree (author);
+
+--
+-- TOC Entry ID 7 (OID 834831)
+--
+-- Name: "ind_index_author2" Type: INDEX Owner: dpavlin
+--
+
+CREATE UNIQUE INDEX ind_index_author2 ON index_author USING btree (upper(author));
+