From 3aef8942d3626647d8e93003aaa3b791da4f6ac7 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 1 Jun 2003 18:49:49 +0000 Subject: [PATCH] moved configuration (database part) to global.conf, added and, or and not operators git-svn-id: file:///home/dpavlin/private/svn/webpac/trunk@53 13eb9ef6-21d5-0310-b721-a9d68796d827 --- WebPac.pm | 14 +++++++++++++- global.conf | 9 +++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 global.conf diff --git a/WebPac.pm b/WebPac.pm index 42d423c..d995ca8 100644 --- a/WebPac.pm +++ b/WebPac.pm @@ -8,6 +8,7 @@ use HTML::FillInForm; use SWISH; use Text::Iconv; use DBI; +use Config::IniFiles; use lib '..'; use index_DBI; @@ -26,6 +27,10 @@ Text::Iconv->raise_error(0); # Conversion errors raise exceptions my $from_utf8 = Text::Iconv->new('UTF8', $CHARSET); +# read global.conf configuration +my $cfg_global = new Config::IniFiles( -file => '../global.conf' ) || die "can't open 'global.conf'"; + + sub setup { my $self = shift; $self->tmpl_path($TEMPLATE_PATH); @@ -90,6 +95,8 @@ sub show_results_list { $s.= ($s) ? "and " : ""; $s.="not " if ($1 eq "-"); $s.="$2* "; + } elsif (m/(and|or|not)/i) { + $s.="$_ "; } else { $s.="$_* "; } @@ -192,7 +199,12 @@ sub show_index { my $html; - my $index = new index_DBI(); + my $index = new index_DBI( + $cfg_global->val('global', 'dbi_dbd'), + $cfg_global->val('global', 'dbi_dsn'), + $cfg_global->val('global', 'dbi_user'), + $cfg_global->val('global', 'dbi_passwd') || '' + ); my $total = $index->check($field); if (! $total) { diff --git a/global.conf b/global.conf new file mode 100644 index 0000000..2840037 --- /dev/null +++ b/global.conf @@ -0,0 +1,9 @@ +# global configuration file (used by isis2xml.pl and webpac.cgi) + +[global] + # define database to use for indexes + dbi_dbd=Pg + dbi_dsn=dbname=webpac + dbi_user=dpavlin + dbi_passwd=xx + -- 2.20.1