From c7c3ab1b867f615344cd36925d5bcd886535bb0e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 4 May 2011 23:52:51 -0400 Subject: v3: sample search form, revert to generating ruby 1.8.7 sample * sisu3 using ruby >=1.9.2p180 generates search form for ruby 1.8.7, so: generate sample form using sisu3 -F (options), then; start webrick using ruby 1.8.7 & sisu -W (not sisu3) * take account of alternative output directory structures [work on, test] --- lib/sisu/v3/cgi_sql_common.rb | 93 +++++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 26 deletions(-) (limited to 'lib/sisu/v3/cgi_sql_common.rb') diff --git a/lib/sisu/v3/cgi_sql_common.rb b/lib/sisu/v3/cgi_sql_common.rb index 924b1533..1174be6e 100644 --- a/lib/sisu/v3/cgi_sql_common.rb +++ b/lib/sisu/v3/cgi_sql_common.rb @@ -299,9 +299,9 @@ module SiSU_CGI_sql end def text_to_match(identifier='') m={ - string: /#{identifier}\s*(.+?)/, - string: /#{identifier}\s*(.+?)(?:;|\n|\r|$)/, - word: /#{identifier}[\s(]*(\S+)/ + :string => /#{identifier}\s*(.+?)/, + :string => /#{identifier}\s*(.+?)(?:;|\n|\r|$)/, + :word => /#{identifier}[\s(]*(\S+)/ } search_string=if @search_field =~m[:word] search_string=if @search_field =~m[:braces]; m[:braces].match(@search_field)[1] @@ -328,10 +328,10 @@ module SiSU_CGI_sql def initialize(conn,search_for,q,c) @conn=conn @text_search_flag=false - @sql_statement={ body: '', endnotes: '',range: '' } + @sql_statement={ :body => '', :endnotes => '', :range => '' } #@offset||=@@offset #@offset+=@@limit - search={ text: [], endnotes: [] } + search={ :text => [], :endnotes => [] } cse=(c =~/\S/) ? true : false st=Dbi_search_string.new('doc_objects.clean',search_for.text1,q['s1'],cse).string se=Dbi_search_string.new('endnotes.clean',search_for.text1,q['s1'],cse).string @@ -645,7 +645,7 @@ module SiSU_CGI_sql @counters_txt,@counters_endn,@sql_select_body,@sql_select_endnotes='','','','' FCGI.each_cgi do |cgi| begin # all code goes in begin section - @search={ text: [], endnotes: [] } + @search={ :text => [], :endnotes => [] } q=CGI.new @db=if cgi['db'] =~/\S+/; @stub=/#{@db_name_prefix}(\S+)/.match(cgi['db'])[1] @@ -656,13 +656,13 @@ module SiSU_CGI_sql end checked_url,checked_stats,checked_searched,checked_tip,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,selected_db='','','','','','','','','' result_type=(cgi['view']=~/text/) \ - ? result_type={ index: '', text: 'checked'} \ - : result_type={ index: 'checked', text: ''} + ? result_type={ :index => '', :text => 'checked'} \ + : result_type={ :index => 'checked', :text => ''} @@limit=if cgi['sql_match_limit'].to_s=~/2500/ - checked_sql_limit={ l1000: '', l2500: 'checked'} + checked_sql_limit={ :l1000 => '', :l2500 => 'checked'} '2500' else - checked_sql_limit={ l1000: 'checked', l2500: ''} + checked_sql_limit={ :l1000 => 'checked', :l2500 => ''} '1000' end checked_echo='checked' if cgi['echo'] =~/\S/ @@ -792,7 +792,7 @@ module SiSU_CGI_sql WOK #eg = %{canned search e.g.:
#{url}
find: #{analyze}
database: #{database}} - #dbi_canning + #% dbi_canning @header=Form.new(@base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can).submission_form #% form unless q['s1'] =~/\S/ or q['au'] =~/\S/ or @search[:text][1] =~/\S/ print "Content-type: text/html\n\n" @@ -808,13 +808,13 @@ module SiSU_CGI_sql @search[:text]<<%{doc_objects.clean~*'#{CGI.unescape(s1)}'} @search[:endnotes]<<%{endnotes.clean~*'#{CGI.unescape(s1)}'} end - #dbi_request + #% dbi_request dbi_statement=Dbi_search_statement.new(@conn,@search_for,q,checked_case) @text_search_flag=false @text_search_flag=dbi_statement.text_search_flag s_contents=dbi_statement.contents s_endnotes=dbi_statement.endnotes - @body_main,@endnotes=[],[] + @body_main,@endnotes='','' @search_regx=nil oldtid=0 if @text_search_flag @@ -827,7 +827,48 @@ module SiSU_CGI_sql @endnotes << '



Endnotes:
' << sql_select_endnotes else end - #text_objects_body + @hostpath="#{@hosturl_files}/#{@stub}" + @ln='en' + def output_dir_structure + def by_language_code? + true + end + def by_filetype? + false + end + def by_filename? + false + end + self + end + def path_manifest(fn,ln=nil) + if output_dir_structure.by_language_code? + manifest_at="#{@hostpath}/#{ln}/manifest/#{fn}.manifest.html" + elsif output_dir_structure.by_filetype? + manifest_at="#{@hostpath}/manifest/#{fn}.manifest.html" + elsif output_dir_structure.by_filename? + manifest_at="#{@hostpath}/#{fn}/manifest.html" + end + end + def path_html_seg(fn,ln=nil) + if output_dir_structure.by_language_code? + html_at="#{@hostpath}/#{ln}/html/#{fn}" + elsif output_dir_structure.by_filetype? + html_at="#{@hostpath}/html/#{fn}" + elsif output_dir_structure.by_filename? + html_at="#{@hostpath}/#{fn}" + end + end + def path_html_doc(fn,ln=nil) + if output_dir_structure.by_language_code? + html_at="#{@hostpath}/#{ln}/html/#{fn}.html" + elsif output_dir_structure.by_filetype? + html_at="#{@hostpath}/html/#{fn}.html" + elsif output_dir_structure.by_filename? + html_at="#{@hostpath}/#{fn}/doc.html" + end + end + #% text_objects_body s_contents.each do |c| #% text body location=c['src_filename'][/(.+?)\.(?:ssm\.sst|sst)$/,1] file_suffix=c['src_filename'][/.+?\.(_?sst|ssm)$/,1] @@ -837,13 +878,13 @@ module SiSU_CGI_sql l=".#{l}" else '' end - #metadata_found_body + #% metadata_found_body if c['tid'].to_i != oldtid.to_i ti=c['title'] can_txt_srch=(cgi['view']=~/index/) \ ? %{search } \ : %{search } - title=%{toc html #{ti} by #{c['creator_author']} #{can_txt_srch}toc html epub pdf portrait pdf landscape odf manifest
} if file_suffix=~/s/ #hmm watch file_suffix + title=%{toc html #{ti} by #{c['creator_author']} #{can_txt_srch}toc html manifest
} if file_suffix=~/s/ #hmm watch file_suffix title=@text_search_flag \ ? '

'+title \ : '
'+title @@ -880,7 +921,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 @@ -888,9 +929,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 - elsif c['suffix'] =~/1/ #doc - index=%{#{c['ocn']}, } + index=%{#{c['ocn']}, } if @text_search_flag + elsif c['suffix'] =~/1/ #doc #FIX + index=%{#{c['ocn']}, } end if c['seg'] =~/\S+/ if @text_search_flag @@ -936,7 +977,7 @@ module SiSU_CGI_sql can_txt_srch=(cgi['view']=~/index/) \ ? %{search } \ : %{search } - title=%{


toc html #{ti} by #{e['creator_author']} #{can_txt_srch}toc html epub pdf portrait pdf landscape odf manifest
} if file_suffix=~/s/ + title=%{

toc html #{ti} by #{e['creator_author']} #{can_txt_srch}toc html manifest
} if file_suffix=~/s/ @counter_endn_doc+=1 oldtid=e['metadata_tid'].to_i else title = '' @@ -947,10 +988,10 @@ module SiSU_CGI_sql matched_endnote=(@search_regx.to_s.class==String && @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}} - else #elsif cgi['view']=~/index/ #% idx endnotes + 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/ @@ -964,7 +1005,7 @@ module SiSU_CGI_sql end end @endnotes << output #+ details - else @endnotes=[] #does not take out yet + else @endnotes='' #does not take out yet end end offset=dbi_statement.sql_offset.to_s @@ -974,7 +1015,7 @@ module SiSU_CGI_sql ? dbi_statement.pre_next(true,@image_src).to_s \ : dbi_statement.pre_next(false,@image_src).to_s limit=dbi_statement.sql_match_limit.to_s - cgi.out{@header + @counters_txt + @counters_endn + canned + @body_main.join + @endnotes.join + canned + @tail} #% print cgi_output_header+counters+body+endnotes + cgi.out{@header + @counters_txt + @counters_endn + canned + @body_main + @endnotes + canned + @tail} #% print cgi_output_header+counters+body+endnotes end rescue Exception => e s='
' + CGI::escapeHTML(e.backtrace.reverse.join("\n"))
-- 
cgit v1.2.3