From d8cd4b664dfc08cbbcad08fca774f9b1dc080ac2 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 8 Feb 2014 23:37:06 -0500 Subject: v5 v6: cgi, sample search form (generator), using cgi ENV variables --- lib/sisu/v5/cgi_pgsql.rb | 18 +++++++++--------- lib/sisu/v5/cgi_sql_common.rb | 10 +++++----- lib/sisu/v5/cgi_sqlite.rb | 12 ++++++++---- lib/sisu/v5/sysenv.rb | 2 +- lib/sisu/v6/cgi_pgsql.rb | 18 +++++++++--------- lib/sisu/v6/cgi_sql_common.rb | 10 +++++----- lib/sisu/v6/cgi_sqlite.rb | 12 ++++++++---- lib/sisu/v6/sysenv.rb | 4 +++- 8 files changed, 48 insertions(+), 38 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v5/cgi_pgsql.rb b/lib/sisu/v5/cgi_pgsql.rb index 4281d9d3..53c73c8d 100644 --- a/lib/sisu/v5/cgi_pgsql.rb +++ b/lib/sisu/v5/cgi_pgsql.rb @@ -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[:host_url_cgi]=%q{http://#{ENV['HTTP_HOST']}#{ENV['PATH_INFO']}} + @name_of[:host_url_docs]=%q{http://#{ENV['HTTP_HOST']}} + @name_of[:cgi_script]=%q{#{ENV['SCRIPT_NAME']}} @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" + @image_src=%q{http://#{ENV['HTTP_HOST']}/_sisu/image_sys} @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,opt,@image_src,@env) + @cgi_file_name=@env.url.cgi_sample_search_form_name(opt) end def pgsql serve=[] @@ -200,15 +200,15 @@ module SiSU_CGI_PgSQL puts 'cgi, fcgi or dbi NOT FOUND (LoadError)' end @stub_default='#{@name_of[:db]}' - @image_src='#{@image_src}' - @hosturl_cgi='#{@name_of[:host_url_cgi]}' - @hosturl_files='#{@name_of[:host_url_docs]}' + @image_src="#{@image_src}" + @hosturl_cgi="#{@name_of[:host_url_cgi]}" + @hosturl_files="#{@name_of[:host_url_docs]}" @output_dir_structure_by='#{@name_of[:output_dir_structure]}' @lingual='#{@name_of[:lingual]}' @port='#{@db.psql.port}' @db_name_prefix='#{Db[:name_prefix]}' @user='#{@name_of[:user]}' # check user name for access to pg database: e.g. www-data or '#{@env.user}' - @base='#{@name_of[:host_url_cgi]}/#{@name_of[:cgi_script]}' + @base="#{@name_of[:host_url_cgi]}#{@name_of[:cgi_script]}" WOK_SQL end def search_statement diff --git a/lib/sisu/v5/cgi_sql_common.rb b/lib/sisu/v5/cgi_sql_common.rb index 42c648e0..c760a9db 100644 --- a/lib/sisu/v5/cgi_sql_common.rb +++ b/lib/sisu/v5/cgi_sql_common.rb @@ -973,7 +973,7 @@ module SiSU_CGI_SQL matched_para=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \ ? (c['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1})) : c['body'] - %{

ocn #{c['ocn']}:

#{matched_para}} + %{

ocn #{c['ocn']}:

#{matched_para}} elsif c['suffix'] =~/1/ #doc %{#{title}

ocn #{c['ocn']}:#{c['body']}} end @@ -981,9 +981,9 @@ module SiSU_CGI_SQL output=title+text else #elsif cgi['view']=~/index/ #% idx body if c['suffix'] !~/1/ #seg - index=%{#{c['ocn']}, } if @text_search_flag + index=%{#{c['ocn']}, } if @text_search_flag elsif c['suffix'] =~/1/ #doc #FIX - index=%{#{c['ocn']}, } + index=%{#{c['ocn']}, } end if c['seg'] =~/\S+/ if @text_search_flag @@ -1041,10 +1041,10 @@ module SiSU_CGI_SQL && @search_regx.to_s=~/\S\S+/) \ ? (matched=e['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1})) : e['body'] - output=%{#{title}


note #{e['nr']} referred to from ocn #{e['ocn']}: #{matched_endnote}} + output=%{#{title}
note #{e['nr']} referred to from ocn #{e['ocn']}: #{matched_endnote}} else #elsif cgi['view']=~/index/ #doc #FIX #% idx endnotes @counter_endn_ocn+=1 - output=%{#{title}#{e['nr']}#{e['ocn']}], } + output=%{#{title}#{e['nr']}#{e['ocn']}], } end @counters_endn=if @counter_endn_doc > 0 if checked_stats =~/\S/ diff --git a/lib/sisu/v5/cgi_sqlite.rb b/lib/sisu/v5/cgi_sqlite.rb index c4222ecb..4351a64c 100644 --- a/lib/sisu/v5/cgi_sqlite.rb +++ b/lib/sisu/v5/cgi_sqlite.rb @@ -79,6 +79,10 @@ module SiSU_CGI_SQLite opt.lingual.to_s else 'multi' end + @name_of[:host_url_cgi]=%q{http://#{ENV['HTTP_HOST']}#{ENV['PATH_INFO']}} + @name_of[:host_url_docs]=%q{http://#{ENV['HTTP_HOST']}} + @name_of[:cgi_script]=%q{#{ENV['SCRIPT_NAME']}} + @image_src=%q{http://#{ENV['HTTP_HOST']}/_sisu/image_sys} @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' @@ -173,13 +177,13 @@ module SiSU_CGI_SQLite puts 'cgi, fcgi or dbi NOT FOUND (LoadError)' end @stub_default='sisu_sqlite' - @image_src='#{@image_src}' - @hosturl_cgi='#{@env.url.webserv_base_cgi(@opt)}/cgi-bin' - @hosturl_files='#{@env.url.webserv_files_from_db(@opt)}' + @image_src="#{@image_src}" + @hosturl_cgi="#{@name_of[:host_url_cgi]}" + @hosturl_files="#{@name_of[:host_url_docs]}" @output_dir_structure_by='#{@name_of[:output_dir_structure]}' @lingual='#{@name_of[:lingual]}' @db_name_prefix='#{Db[:name_prefix]}' - @base='#{@env.url.webserv_base_cgi(@opt)}/cgi-bin/#{@env.url.cgi_sample_search_form_name(@opt)}' #fix sqlite + @base="#{@name_of[:host_url_cgi]}#{@name_of[:cgi_script]}" WOK_SQL end def search_statement diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb index 537e52ca..7d8a9766 100644 --- a/lib/sisu/v5/sysenv.rb +++ b/lib/sisu/v5/sysenv.rb @@ -215,7 +215,7 @@ module SiSU_Env BUNDLE => false, CONCORD_MAX => 260000, DIGEST => 'sha256', - WEBSERV_HOST_CGI => ' http://localhost', + WEBSERV_HOST_CGI => 'http://localhost', WEBSERV_PORT_CGI => 8081, #8111,8123,8081 POSTGRESQL_USER => @@user, #'ralph', # change user !!! POSTGRESQL_PORT => port_pgsql, diff --git a/lib/sisu/v6/cgi_pgsql.rb b/lib/sisu/v6/cgi_pgsql.rb index 26db0341..a52b62e3 100644 --- a/lib/sisu/v6/cgi_pgsql.rb +++ b/lib/sisu/v6/cgi_pgsql.rb @@ -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[:host_url_cgi]=%q{http://#{ENV['HTTP_HOST']}#{ENV['PATH_INFO']}} + @name_of[:host_url_docs]=%q{http://#{ENV['HTTP_HOST']}} + @name_of[:cgi_script]=%q{#{ENV['SCRIPT_NAME']}} @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" + @image_src=%q{http://#{ENV['HTTP_HOST']}/_sisu/image_sys} @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,opt,@image_src,@env) + @cgi_file_name=@env.url.cgi_sample_search_form_name(opt) end def pgsql serve=[] @@ -200,15 +200,15 @@ module SiSU_CGI_PgSQL puts 'cgi, fcgi or dbi NOT FOUND (LoadError)' end @stub_default='#{@name_of[:db]}' - @image_src='#{@image_src}' - @hosturl_cgi='#{@name_of[:host_url_cgi]}' - @hosturl_files='#{@name_of[:host_url_docs]}' + @image_src="#{@image_src}" + @hosturl_cgi="#{@name_of[:host_url_cgi]}" + @hosturl_files="#{@name_of[:host_url_docs]}" @output_dir_structure_by='#{@name_of[:output_dir_structure]}' @lingual='#{@name_of[:lingual]}' @port='#{@db.psql.port}' @db_name_prefix='#{Db[:name_prefix]}' @user='#{@name_of[:user]}' # check user name for access to pg database: e.g. www-data or '#{@env.user}' - @base='#{@name_of[:host_url_cgi]}/#{@name_of[:cgi_script]}' + @base="#{@name_of[:host_url_cgi]}#{@name_of[:cgi_script]}" WOK_SQL end def search_statement diff --git a/lib/sisu/v6/cgi_sql_common.rb b/lib/sisu/v6/cgi_sql_common.rb index 44d06880..6e9ddf25 100644 --- a/lib/sisu/v6/cgi_sql_common.rb +++ b/lib/sisu/v6/cgi_sql_common.rb @@ -973,7 +973,7 @@ module SiSU_CGI_SQL matched_para=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \ ? (c['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1})) : c['body'] - %{

ocn #{c['ocn']}:

#{matched_para}} + %{

ocn #{c['ocn']}:

#{matched_para}} elsif c['suffix'] =~/1/ #doc %{#{title}

ocn #{c['ocn']}:#{c['body']}} end @@ -981,9 +981,9 @@ module SiSU_CGI_SQL output=title+text else #elsif cgi['view']=~/index/ #% idx body if c['suffix'] !~/1/ #seg - index=%{#{c['ocn']}, } if @text_search_flag + index=%{#{c['ocn']}, } if @text_search_flag elsif c['suffix'] =~/1/ #doc #FIX - index=%{#{c['ocn']}, } + index=%{#{c['ocn']}, } end if c['seg'] =~/\S+/ if @text_search_flag @@ -1041,10 +1041,10 @@ module SiSU_CGI_SQL && @search_regx.to_s=~/\S\S+/) \ ? (matched=e['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1})) : e['body'] - output=%{#{title}


note #{e['nr']} referred to from ocn #{e['ocn']}: #{matched_endnote}} + output=%{#{title}
note #{e['nr']} referred to from ocn #{e['ocn']}: #{matched_endnote}} else #elsif cgi['view']=~/index/ #doc #FIX #% idx endnotes @counter_endn_ocn+=1 - output=%{#{title}#{e['nr']}#{e['ocn']}], } + output=%{#{title}#{e['nr']}#{e['ocn']}], } end @counters_endn=if @counter_endn_doc > 0 if checked_stats =~/\S/ diff --git a/lib/sisu/v6/cgi_sqlite.rb b/lib/sisu/v6/cgi_sqlite.rb index 6db31b48..696b6817 100644 --- a/lib/sisu/v6/cgi_sqlite.rb +++ b/lib/sisu/v6/cgi_sqlite.rb @@ -79,6 +79,10 @@ module SiSU_CGI_SQLite opt.lingual.to_s else 'multi' end + @name_of[:host_url_cgi]=%q{http://#{ENV['HTTP_HOST']}#{ENV['PATH_INFO']}} + @name_of[:host_url_docs]=%q{http://#{ENV['HTTP_HOST']}} + @name_of[:cgi_script]=%q{#{ENV['SCRIPT_NAME']}} + @image_src=%q{http://#{ENV['HTTP_HOST']}/_sisu/image_sys} @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' @@ -173,13 +177,13 @@ module SiSU_CGI_SQLite puts 'cgi, fcgi or dbi NOT FOUND (LoadError)' end @stub_default='sisu_sqlite' - @image_src='#{@image_src}' - @hosturl_cgi='#{@env.url.webserv_base_cgi(@opt)}/cgi-bin' - @hosturl_files='#{@env.url.webserv_files_from_db(@opt)}' + @image_src="#{@image_src}" + @hosturl_cgi="#{@name_of[:host_url_cgi]}" + @hosturl_files="#{@name_of[:host_url_docs]}" @output_dir_structure_by='#{@name_of[:output_dir_structure]}' @lingual='#{@name_of[:lingual]}' @db_name_prefix='#{Db[:name_prefix]}' - @base='#{@env.url.webserv_base_cgi(@opt)}/cgi-bin/#{@env.url.cgi_sample_search_form_name(@opt)}' #fix sqlite + @base="#{@name_of[:host_url_cgi]}#{@name_of[:cgi_script]}" WOK_SQL end def search_statement diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb index 60d963dc..16fbbf4c 100644 --- a/lib/sisu/v6/sysenv.rb +++ b/lib/sisu/v6/sysenv.rb @@ -215,7 +215,7 @@ module SiSU_Env BUNDLE => false, CONCORD_MAX => 260000, DIGEST => 'sha256', - WEBSERV_HOST_CGI => ' http://localhost', + WEBSERV_HOST_CGI => 'http://localhost', WEBSERV_PORT_CGI => 8081, #8111,8123,8081 POSTGRESQL_USER => @@user, #'ralph', # change user !!! POSTGRESQL_PORT => port_pgsql, @@ -2519,6 +2519,7 @@ WOK end end http=http.strip + #%q{http://#{ENV['HTTP_HOST']}} end def webrick #must have a port #REMOVE if defined? @rc['webserv_cgi']['host'] \ @@ -2581,6 +2582,7 @@ WOK else webserv_base_cgi(opt) end end + #%q{http://#{ENV['HTTP_HOST']}/cgi-bin} end def cgi_sample_search_form_name(opt=nil) if opt.mod.inspect =~/--(?:cgi-)?search-form-name[=-]["']?(\S+?\.cgi)/ -- cgit v1.2.3