From 0cad9edcc02c9816759c348f8c483cfa5c54dcf8 Mon Sep 17 00:00:00 2001
From: Ralph Amissah <ralph@amissah.com>
Date: Wed, 5 Feb 2014 01:11:53 -0500
Subject: v5 v6: cgi (pgsql & sqlite), fix

---
 data/doc/sisu/CHANGELOG_v5 |  2 ++
 data/doc/sisu/CHANGELOG_v6 |  2 ++
 lib/sisu/v5/cgi_pgsql.rb   | 26 +++++++++++++-------------
 lib/sisu/v5/cgi_sqlite.rb  | 18 +++++++++---------
 lib/sisu/v6/cgi_pgsql.rb   | 26 +++++++++++++-------------
 lib/sisu/v6/cgi_sqlite.rb  | 18 +++++++++---------
 6 files changed, 48 insertions(+), 44 deletions(-)

diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5
index 654a8fa6..ce118aec 100644
--- a/data/doc/sisu/CHANGELOG_v5
+++ b/data/doc/sisu/CHANGELOG_v5
@@ -58,6 +58,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.3.1.orig.tar.xz
   * txt
   * odt
 
+* cgi (pgsql, sqlite) fixes
+
 * error/warn messages, including wrappers round require
 
 %% 5.3.0.orig.tar.xz (2014-01-26:03/7)
diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6
index 4634ce09..6a861ac4 100644
--- a/data/doc/sisu/CHANGELOG_v6
+++ b/data/doc/sisu/CHANGELOG_v6
@@ -48,6 +48,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_6.0.1.orig.tar.xz
   * txt
   * odt
 
+* cgi (pgsql, sqlite) fixes
+
 * error/warn messages, including wrappers round require
 
 %% 6.0.0.orig.tar.xz (2014-01-26:03/7)
diff --git a/lib/sisu/v5/cgi_pgsql.rb b/lib/sisu/v5/cgi_pgsql.rb
index 0a514672..4281d9d3 100644
--- a/lib/sisu/v5/cgi_pgsql.rb
+++ b/lib/sisu/v5/cgi_pgsql.rb
@@ -74,12 +74,12 @@ module  SiSU_CGI_PgSQL
       get_init=SiSU_Env::GetInit.new
       @rc=get_init.sisu_yaml.rc
       @name_of={}
-      @name_of[:output_dir_structure]=if @opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/
-        @opt.dir_structure_by.to_s
+      @name_of[:output_dir_structure]=if opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/
+        opt.dir_structure_by.to_s
       else 'language'
       end
-      @name_of[:lingual]=if @opt.lingual.to_s =~/(?:mono|multi)/
-        @opt.lingual.to_s
+      @name_of[:lingual]=if opt.lingual.to_s =~/(?:mono|multi)/
+        opt.lingual.to_s
       else 'multi'
       end
       if defined? @rc['search'] \
@@ -93,13 +93,13 @@ module  SiSU_CGI_PgSQL
         @name_of[:db]=@env.path.stub_pwd #'sisu' #breaks if not present
         false
       end
-      @name_of[:host_url_cgi]="#{@env.url.webserv_base_cgi(@opt)}/cgi-bin"
-      @name_of[:host_url_docs]=@env.url.webserv_files_from_db(@opt)
-      @name_of[:cgi_script]=@env.url.cgi_sample_search_form_name(@opt)
-      @name_of[:user]=@db.psql.user(@opt)
+      @name_of[:host_url_cgi]="#{@env.url.webserv_base_cgi(opt)}/cgi-bin"
+      @name_of[:host_url_docs]=@env.url.webserv_files_from_db(opt)
+      @name_of[:cgi_script]=@env.url.cgi_sample_search_form_name(opt)
+      @name_of[:user]=@db.psql.user(opt)
       @cgi_file_name=@name_of[:cgi_script]
-      @image_src="#{@env.url.webserv_base_cgi(@opt)}/_sisu/image_sys"
-      @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env)
+      @image_src="#{@env.url.webserv_base_cgi(opt)}/_sisu/image_sys"
+      @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,opt,@image_src,@env)
     end
     def pgsql
       serve=[]
@@ -174,13 +174,13 @@ module  SiSU_CGI_PgSQL
               sudo chmod -v 755  /usr/lib/cgi-bin/#{@cgi_file_name}
           WOK
         end
-        SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).warn
+        SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).warn
         a=<<-WOK
               #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name}
         WOK
-        SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).print_blue
+        SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).print_blue
         a="\n\t(to create and populate postgresql database see 'man sisu' and in particular the --pg option)\n\t[the database to be used for this directory (#{@db.psql.db}) will have to be created manually if it does not exist,\n\tusing postgresql tools directly: 'createdb #{@db.psql.db}' for a list of existing databases try 'psql --list']"
-        SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).txt_grey
+        SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).txt_grey
       else puts 'failed in attempt to write #{@cgi_file_name} to present directory,  is directory writable?'
       end
     end
diff --git a/lib/sisu/v5/cgi_sqlite.rb b/lib/sisu/v5/cgi_sqlite.rb
index aa38e6f1..c4222ecb 100644
--- a/lib/sisu/v5/cgi_sqlite.rb
+++ b/lib/sisu/v5/cgi_sqlite.rb
@@ -69,18 +69,18 @@ module  SiSU_CGI_SQLite
       @opt,@webserv=opt,webserv
       @cX=SiSU_Screen::Ansi.new(opt.act[:color_state][:set]).cX
       @env=SiSU_Env::InfoEnv.new('',opt)
-      @image_src="#{@env.url.webserv_cgi(@opt)}/_sisu/image_sys"
+      @image_src="#{@env.url.webserv_cgi(opt)}/_sisu/image_sys"
       @name_of={}
-      @name_of[:output_dir_structure]=if @opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/
-        @opt.dir_structure_by.to_s
+      @name_of[:output_dir_structure]=if opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/
+        opt.dir_structure_by.to_s
       else 'language'
       end
-      @name_of[:lingual]=if @opt.lingual.to_s =~/(?:mono|multi)/
-        @opt.lingual.to_s
+      @name_of[:lingual]=if opt.lingual.to_s =~/(?:mono|multi)/
+        opt.lingual.to_s
       else 'multi'
       end
-      @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env)
-      @cgi_file_name=@env.url.cgi_sample_search_form_name(@opt)
+      @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,opt,@image_src,@env)
+      @cgi_file_name=@env.url.cgi_sample_search_form_name(opt)
       @name_of_sqlite_db_file='sisu_sqlite.db'
     end
     def sqlite
@@ -147,13 +147,13 @@ module  SiSU_CGI_SQLite
           WOK
         end
         b='(to create and populate sisu sqlite database see "man sisu" and in particular the -d flag)'
-        SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a,b).warn
+        SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a,b).warn
         a=<<-WOK
 
               #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name}
 
         WOK
-        SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).print_blue
+        SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).print_blue
       else puts "failed in attempt to write #{@cgi_file_name} to present directory, is directory writable?"
       end
     end
diff --git a/lib/sisu/v6/cgi_pgsql.rb b/lib/sisu/v6/cgi_pgsql.rb
index 3b0b610b..26db0341 100644
--- a/lib/sisu/v6/cgi_pgsql.rb
+++ b/lib/sisu/v6/cgi_pgsql.rb
@@ -74,12 +74,12 @@ module  SiSU_CGI_PgSQL
       get_init=SiSU_Env::GetInit.new
       @rc=get_init.sisu_yaml.rc
       @name_of={}
-      @name_of[:output_dir_structure]=if @opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/
-        @opt.dir_structure_by.to_s
+      @name_of[:output_dir_structure]=if opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/
+        opt.dir_structure_by.to_s
       else 'language'
       end
-      @name_of[:lingual]=if @opt.lingual.to_s =~/(?:mono|multi)/
-        @opt.lingual.to_s
+      @name_of[:lingual]=if opt.lingual.to_s =~/(?:mono|multi)/
+        opt.lingual.to_s
       else 'multi'
       end
       if defined? @rc['search'] \
@@ -93,13 +93,13 @@ module  SiSU_CGI_PgSQL
         @name_of[:db]=@env.path.stub_pwd #'sisu' #breaks if not present
         false
       end
-      @name_of[:host_url_cgi]="#{@env.url.webserv_base_cgi(@opt)}/cgi-bin"
-      @name_of[:host_url_docs]=@env.url.webserv_files_from_db(@opt)
-      @name_of[:cgi_script]=@env.url.cgi_sample_search_form_name(@opt)
-      @name_of[:user]=@db.psql.user(@opt)
+      @name_of[:host_url_cgi]="#{@env.url.webserv_base_cgi(opt)}/cgi-bin"
+      @name_of[:host_url_docs]=@env.url.webserv_files_from_db(opt)
+      @name_of[:cgi_script]=@env.url.cgi_sample_search_form_name(opt)
+      @name_of[:user]=@db.psql.user(opt)
       @cgi_file_name=@name_of[:cgi_script]
-      @image_src="#{@env.url.webserv_base_cgi(@opt)}/_sisu/image_sys"
-      @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env)
+      @image_src="#{@env.url.webserv_base_cgi(opt)}/_sisu/image_sys"
+      @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,opt,@image_src,@env)
     end
     def pgsql
       serve=[]
@@ -174,13 +174,13 @@ module  SiSU_CGI_PgSQL
               sudo chmod -v 755  /usr/lib/cgi-bin/#{@cgi_file_name}
           WOK
         end
-        SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).warn
+        SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).warn
         a=<<-WOK
               #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name}
         WOK
-        SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).print_blue
+        SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).print_blue
         a="\n\t(to create and populate postgresql database see 'man sisu' and in particular the --pg option)\n\t[the database to be used for this directory (#{@db.psql.db}) will have to be created manually if it does not exist,\n\tusing postgresql tools directly: 'createdb #{@db.psql.db}' for a list of existing databases try 'psql --list']"
-        SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).txt_grey
+        SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).txt_grey
       else puts 'failed in attempt to write #{@cgi_file_name} to present directory,  is directory writable?'
       end
     end
diff --git a/lib/sisu/v6/cgi_sqlite.rb b/lib/sisu/v6/cgi_sqlite.rb
index daf915e6..6db31b48 100644
--- a/lib/sisu/v6/cgi_sqlite.rb
+++ b/lib/sisu/v6/cgi_sqlite.rb
@@ -69,18 +69,18 @@ module  SiSU_CGI_SQLite
       @opt,@webserv=opt,webserv
       @cX=SiSU_Screen::Ansi.new(opt.act[:color_state][:set]).cX
       @env=SiSU_Env::InfoEnv.new('',opt)
-      @image_src="#{@env.url.webserv_cgi(@opt)}/_sisu/image_sys"
+      @image_src="#{@env.url.webserv_cgi(opt)}/_sisu/image_sys"
       @name_of={}
-      @name_of[:output_dir_structure]=if @opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/
-        @opt.dir_structure_by.to_s
+      @name_of[:output_dir_structure]=if opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/
+        opt.dir_structure_by.to_s
       else 'language'
       end
-      @name_of[:lingual]=if @opt.lingual.to_s =~/(?:mono|multi)/
-        @opt.lingual.to_s
+      @name_of[:lingual]=if opt.lingual.to_s =~/(?:mono|multi)/
+        opt.lingual.to_s
       else 'multi'
       end
-      @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env)
-      @cgi_file_name=@env.url.cgi_sample_search_form_name(@opt)
+      @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,opt,@image_src,@env)
+      @cgi_file_name=@env.url.cgi_sample_search_form_name(opt)
       @name_of_sqlite_db_file='sisu_sqlite.db'
     end
     def sqlite
@@ -147,13 +147,13 @@ module  SiSU_CGI_SQLite
           WOK
         end
         b='(to create and populate sisu sqlite database see "man sisu" and in particular the -d flag)'
-        SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a,b).warn
+        SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a,b).warn
         a=<<-WOK
 
               #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name}
 
         WOK
-        SiSU_Screen::Ansi.new(opt.act[:color_state][:set],a).print_blue
+        SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).print_blue
       else puts "failed in attempt to write #{@cgi_file_name} to present directory, is directory writable?"
       end
     end
-- 
cgit v1.2.3