diff options
author | Ralph Amissah <ralph@amissah.com> | 2014-02-08 23:37:06 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2014-02-08 23:37:06 -0500 |
commit | d8cd4b664dfc08cbbcad08fca774f9b1dc080ac2 (patch) | |
tree | ca0c78abafe16a0579864c5ca8a70a7c8f6ddaba /lib | |
parent | v5 v6: version & changelog (& rakefile) (diff) |
v5 v6: cgi, sample search form (generator), using cgi ENV variables
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v5/cgi_pgsql.rb | 18 | ||||
-rw-r--r-- | lib/sisu/v5/cgi_sql_common.rb | 10 | ||||
-rw-r--r-- | lib/sisu/v5/cgi_sqlite.rb | 12 | ||||
-rw-r--r-- | lib/sisu/v5/sysenv.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v6/cgi_pgsql.rb | 18 | ||||
-rw-r--r-- | lib/sisu/v6/cgi_sql_common.rb | 10 | ||||
-rw-r--r-- | lib/sisu/v6/cgi_sqlite.rb | 12 | ||||
-rw-r--r-- | lib/sisu/v6/sysenv.rb | 4 |
8 files changed, 48 insertions, 38 deletions
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(/(<a\s+href="https?:\/\/[^><\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{<span style="background-color: #{@color_match}">\\1</span>})) : c['body'] - %{<hr><p><font size="2">ocn <b><a href="#{path_filename(location,c['seg'],c['language_document_char'])}##{c['ocn']}">#{c['ocn']}</a></b>:</font></p>#{matched_para}} + %{<hr><p><font size="2">ocn <b><a href="#{path_filename(location,c['seg'],c['language_document_char'])}#o#{c['ocn']}">#{c['ocn']}</a></b>:</font></p>#{matched_para}} elsif c['suffix'] =~/1/ #doc %{#{title}<hr><p><font size="2">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=%{<a href="#{path_filename(location,c['seg'],c['language_document_char'])}##{c['ocn']}">#{c['ocn']}</a>, } if @text_search_flag + index=%{<a href="#{path_filename(location,c['seg'],c['language_document_char'])}#o#{c['ocn']}">#{c['ocn']}</a>, } if @text_search_flag elsif c['suffix'] =~/1/ #doc #FIX - index=%{<a href="#{path_html_doc(location,c['language_document_char'])}##{c['ocn']}">#{c['ocn']}</a>, } + index=%{<a href="#{path_html_doc(location,c['language_document_char'])}#o#{c['ocn']}">#{c['ocn']}</a>, } 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(/(<a\s+href="https?:\/\/[^><\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{<span style="background-color: #{@color_match}">\\1</span>})) : e['body'] - output=%{#{title}<hr><font size="2">note <b><a href="#{path_endnotes(location,e['language_document_char'])}#_#{e['nr']}">#{e['nr']}</a></b> referred to from ocn <a href="#{path_html_doc(location,e['language_document_char'])}##{e['ocn']}">#{e['ocn']}</a>:</font> #{matched_endnote}} + output=%{#{title}<hr><font size="2">note <b><a href="#{path_endnotes(location,e['language_document_char'])}#_#{e['nr']}">#{e['nr']}</a></b> referred to from ocn <a href="#{path_html_doc(location,e['language_document_char'])}#o#{e['ocn']}">#{e['ocn']}</a>:</font> #{matched_endnote}} else #elsif cgi['view']=~/index/ #doc #FIX #% idx endnotes @counter_endn_ocn+=1 - output=%{#{title}<a href="#{path_endnotes(location,e['language_document_char'])}#_#{e['nr']}">#{e['nr']}</a> [§ <a href="#{path_html_doc(location,e['language_document_char'])}##{e['ocn']}">#{e['ocn']}</a>], } + output=%{#{title}<a href="#{path_endnotes(location,e['language_document_char'])}#_#{e['nr']}">#{e['nr']}</a> [§ <a href="#{path_html_doc(location,e['language_document_char'])}#o#{e['ocn']}">#{e['ocn']}</a>], } 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(/(<a\s+href="https?:\/\/[^><\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{<span style="background-color: #{@color_match}">\\1</span>})) : c['body'] - %{<hr><p><font size="2">ocn <b><a href="#{path_filename(location,c['seg'],c['language_document_char'])}##{c['ocn']}">#{c['ocn']}</a></b>:</font></p>#{matched_para}} + %{<hr><p><font size="2">ocn <b><a href="#{path_filename(location,c['seg'],c['language_document_char'])}#o#{c['ocn']}">#{c['ocn']}</a></b>:</font></p>#{matched_para}} elsif c['suffix'] =~/1/ #doc %{#{title}<hr><p><font size="2">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=%{<a href="#{path_filename(location,c['seg'],c['language_document_char'])}##{c['ocn']}">#{c['ocn']}</a>, } if @text_search_flag + index=%{<a href="#{path_filename(location,c['seg'],c['language_document_char'])}#o#{c['ocn']}">#{c['ocn']}</a>, } if @text_search_flag elsif c['suffix'] =~/1/ #doc #FIX - index=%{<a href="#{path_html_doc(location,c['language_document_char'])}##{c['ocn']}">#{c['ocn']}</a>, } + index=%{<a href="#{path_html_doc(location,c['language_document_char'])}#o#{c['ocn']}">#{c['ocn']}</a>, } 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(/(<a\s+href="https?:\/\/[^><\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{<span style="background-color: #{@color_match}">\\1</span>})) : e['body'] - output=%{#{title}<hr><font size="2">note <b><a href="#{path_endnotes(location,e['language_document_char'])}#_#{e['nr']}">#{e['nr']}</a></b> referred to from ocn <a href="#{path_html_doc(location,e['language_document_char'])}##{e['ocn']}">#{e['ocn']}</a>:</font> #{matched_endnote}} + output=%{#{title}<hr><font size="2">note <b><a href="#{path_endnotes(location,e['language_document_char'])}#_#{e['nr']}">#{e['nr']}</a></b> referred to from ocn <a href="#{path_html_doc(location,e['language_document_char'])}#o#{e['ocn']}">#{e['ocn']}</a>:</font> #{matched_endnote}} else #elsif cgi['view']=~/index/ #doc #FIX #% idx endnotes @counter_endn_ocn+=1 - output=%{#{title}<a href="#{path_endnotes(location,e['language_document_char'])}#_#{e['nr']}">#{e['nr']}</a> [§ <a href="#{path_html_doc(location,e['language_document_char'])}##{e['ocn']}">#{e['ocn']}</a>], } + output=%{#{title}<a href="#{path_endnotes(location,e['language_document_char'])}#_#{e['nr']}">#{e['nr']}</a> [§ <a href="#{path_html_doc(location,e['language_document_char'])}#o#{e['ocn']}">#{e['ocn']}</a>], } 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)/ |