diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v5/cgi_pgsql.rb | 24 | ||||
-rw-r--r-- | lib/sisu/v5/cgi_sql_common.rb | 113 | ||||
-rw-r--r-- | lib/sisu/v5/cgi_sqlite.rb | 24 | ||||
-rw-r--r-- | lib/sisu/v5/sysenv.rb | 4 |
4 files changed, 87 insertions, 78 deletions
diff --git a/lib/sisu/v5/cgi_pgsql.rb b/lib/sisu/v5/cgi_pgsql.rb index bdb457f3..d44e8993 100644 --- a/lib/sisu/v5/cgi_pgsql.rb +++ b/lib/sisu/v5/cgi_pgsql.rb @@ -73,11 +73,14 @@ module SiSU_CGI_PgSQL get_init=SiSU_Env::GetInit.new @rc=get_init.sisu_yaml.rc @name_of={} - @name_of[:output_dir_structure]=if defined? @rc['output_dir_structure_by'] \ - and defined? @rc['output_dir_structure_by'] =~/(language|filetype|filename)/ - @rc['output_dir_structure_by'] + @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 + else 'multi' + end if defined? @rc['search'] \ and defined? @rc['search']['sisu'] \ and defined? @rc['search']['sisu']['action'] \ @@ -93,8 +96,7 @@ module SiSU_CGI_PgSQL @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="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by.to_s}_pgsql.cgi" - @cgi_link_name=@name_of[:cgi_script] #sisu_pgsql.cgi, + @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) end @@ -161,24 +163,19 @@ module SiSU_CGI_PgSQL # if necessary make the directory '/usr/lib/cgi-bin' # here we copy the postgresql search form to cgi-bin # (copy #{@cgi_file_name} to your cgi directory) - # set file permissions to 755, & - # make symbolic link to #{@cgi_link_name} + # set file permissions to 755 WOK a=case @webserv when /pwd/; '' else <<-WOK sudo cp -vi #{Dir.pwd}/#{@cgi_file_name} /usr/lib/cgi-bin/.; \\ - cd /usr/lib/cgi-bin && \\ - sudo chmod -v 755 #{@cgi_file_name}; \\ - sudo rm -vi #{@cgi_link_name}; \\ - sudo ln -s #{@cgi_file_name} #{@cgi_link_name}; \\ - cd - + sudo chmod -v 755 /usr/lib/cgi-bin/#{@cgi_file_name} WOK end SiSU_Screen::Ansi.new(@opt.cmd,a).warn a=<<-WOK - #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_link_name} + #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name} WOK SiSU_Screen::Ansi.new(@opt.cmd,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']" @@ -202,6 +199,7 @@ module SiSU_CGI_PgSQL @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}' diff --git a/lib/sisu/v5/cgi_sql_common.rb b/lib/sisu/v5/cgi_sql_common.rb index b551d6c8..0944ab61 100644 --- a/lib/sisu/v5/cgi_sql_common.rb +++ b/lib/sisu/v5/cgi_sql_common.rb @@ -845,72 +845,77 @@ module SiSU_CGI_SQL @hostpath="#{@hosturl_files}/#{@stub}" WOK_SQL end - def dir_structure - case @opt.dir_structure_by - when :language - <<-'WOK_SQL' - def path_manifest(fn,ln=nil) - "#{@hostpath}/#{ln}/manifest/#{fn}.html" - end - def path_html_seg(fn,ln=nil) - "#{@hostpath}/#{ln}/html/#{fn}" - end - def path_toc(fn,ln=nil) - "#{path_html_seg(fn,ln)}/toc.html" - end - def path_filename(fn,seg,ln=nil) - "#{path_html_seg(fn,ln)}/#{seg}.html" - end - def path_endnotes(fn,ln=nil) - "#{path_html_seg(fn,ln)}/endnotes.html" - end - def path_html_doc(fn,ln=nil) - "#{@hostpath}/#{ln}/html/#{fn}.html" - end - WOK_SQL - when :filetype - <<-'WOK_SQL' - def path_manifest(fn,ln=nil) - "#{@hostpath}/manifest/#{fn}.#{ln}.html" - end - def path_html_seg(fn,ln=nil) - "#{@hostpath}/html/#{fn}" - end - def path_toc(fn,ln=nil) - "#{path_html_seg(fn,ln)}/toc.#{ln}.html" - end - def path_filename(fn,seg,ln=nil) - "#{path_html_seg(fn,ln)}/#{seg}.#{ln}.html" - end - def path_endnotes(fn,ln=nil) - "#{path_html_seg(fn,ln)}/endnotes.#{ln}.html" - end - def path_html_doc(fn,ln=nil) - "#{@hostpath}/html/#{fn}.#{ln}.html" - end - WOK_SQL - else - <<-'WOK_SQL' + def dir_structure #@opt.dir_structure_by + <<-'WOK_SQL' def path_manifest(fn,ln=nil) - "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html" + case @output_dir_structure_by + when 'filename' + @lingual =='mono' \ + ? "#{@hostpath}/#{fn}/sisu_manifest.html" + : "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html" + when 'filetype' + @lingual =='mono' \ + ? "#{@hostpath}/manifest/#{fn}.html" + : "#{@hostpath}/manifest/#{fn}.#{ln}.html" + else + "#{@hostpath}/#{ln}/manifest/#{fn}.html" + end end def path_html_seg(fn,ln=nil) - "#{@hostpath}/#{fn}" + case @output_dir_structure_by + when 'filename' + "#{@hostpath}/#{fn}" + when 'filetype' + "#{@hostpath}/html/#{fn}" + else + "#{@hostpath}/#{ln}/html/#{fn}" + end end def path_toc(fn,ln=nil) - "#{path_html_seg(fn,ln)}/toc.#{ln}.html" + if @output_dir_structure_by =='filename' \ + or @output_dir_structure_by =='filetype' + @lingual =='mono' \ + ? "#{path_html_seg(fn,ln)}/toc.html" + : "#{path_html_seg(fn,ln)}/toc.#{ln}.html" + else + "#{path_html_seg(fn,ln)}/toc.html" + end end def path_filename(fn,seg,ln=nil) - "#{path_html_seg(fn,ln)}/#{seg}.#{ln}.html" + if @output_dir_structure_by =='filename' \ + or @output_dir_structure_by =='filetype' + @lingual =='mono' \ + ? "#{path_html_seg(fn,ln)}/#{seg}.html" + : "#{path_html_seg(fn,ln)}/#{seg}.#{ln}.html" + else + "#{path_html_seg(fn,ln)}/#{seg}.html" + end end def path_endnotes(fn,ln=nil) - "#{path_html_seg(fn,ln)}/endnotes.#{ln}.html" + if @output_dir_structure_by =='filename' \ + or @output_dir_structure_by =='filetype' + @lingual =='mono' \ + ? "#{path_html_seg(fn,ln)}/endnotes.html" + : "#{path_html_seg(fn,ln)}/endnotes.#{ln}.html" + else + "#{path_html_seg(fn,ln)}/endnotes.html" + end end def path_html_doc(fn,ln=nil) - "#{path_html_seg(fn,ln)}/scroll.#{ln}.html" + case @output_dir_structure_by + when 'filename' + @lingual =='mono' \ + ? "#{path_html_seg(fn,ln)}/scroll.html" + : "#{path_html_seg(fn,ln)}/scroll.#{ln}.html" + when 'filetype' + @lingual =='mono' \ + ? "#{@hostpath}/html/#{fn}.html" + : "#{@hostpath}/html/#{fn}.#{ln}.html" + else + "#{@hostpath}/#{ln}/html/#{fn}.html" + end end - WOK_SQL - end + WOK_SQL end def main3 <<-'WOK_SQL' diff --git a/lib/sisu/v5/cgi_sqlite.rb b/lib/sisu/v5/cgi_sqlite.rb index e53497e1..62e50c72 100644 --- a/lib/sisu/v5/cgi_sqlite.rb +++ b/lib/sisu/v5/cgi_sqlite.rb @@ -69,8 +69,17 @@ module SiSU_CGI_SQLite @cX=SiSU_Screen::Ansi.new(opt.cmd).cX @env=SiSU_Env::InfoEnv.new('',opt) @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 + else 'language' + end + @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="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by.to_s}_sqlite.cgi" + @cgi_file_name=@env.url.cgi_sample_search_form_name(@opt) @name_of_sqlite_db_file='sisu_sqlite.db' end def sqlite @@ -126,26 +135,21 @@ module SiSU_CGI_SQLite # if necessary make the directory '/usr/lib/cgi-bin' # here we copy the postgresql search form to cgi-bin # (copy #{@cgi_file_name} to your cgi directory) - # set file permissions to 755, & - # make symbolic link to #{@cgi_link_name} + # set file permissions to 755 WOK a=case @webserv when /pwd/; '' else <<-WOK sudo cp -vi #{Dir.pwd}/#{@cgi_file_name} /usr/lib/cgi-bin/.; \\ - cd /usr/lib/cgi-bin && \\ - sudo chmod -v 755 #{@cgi_file_name}; \\ - sudo rm -vi #{@env.url.cgi_sample_search_form_name(@opt)}; \\ - sudo ln -sf #{@cgi_file_name} #{@env.url.cgi_sample_search_form_name(@opt)}; \\ - cd - + sudo chmod -v 755 /usr/lib/cgi-bin/#{@cgi_file_name} WOK end b='(to create and populate sisu sqlite database see "man sisu" and in particular the -d flag)' SiSU_Screen::Ansi.new(@opt.cmd,a,b).warn a=<<-WOK - #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_link_name} + #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name} WOK SiSU_Screen::Ansi.new(@opt.cmd,a).print_blue @@ -167,6 +171,8 @@ module SiSU_CGI_SQLite @image_src='#{@image_src}' @hosturl_cgi='#{@env.url.webserv_base_cgi(@opt)}/cgi-bin' @hosturl_files='#{@env.url.webserv_files_from_db(@opt)}' + @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 WOK_SQL diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb index 63981be3..9ddc763e 100644 --- a/lib/sisu/v5/sysenv.rb +++ b/lib/sisu/v5/sysenv.rb @@ -2519,8 +2519,8 @@ WOK /(?:https?:\/\/\S+?)\/([^\/]+?\.cgi)$/.match(@rc['search']['sisu']['action'])[1] else (opt.mod.inspect =~/--db[=-]["']?sqlite/) \ - ? 'sisu_sqlite.cgi' \ - : 'sisu_pgsql.cgi' + ? "#{Db[:name_prefix_db]}sqlite.cgi" \ + : "#{Db[:name_prefix_db]}pgsql.cgi" end end def sample_search_form_title(organised_by=:language) |