From 5a1e3ba75950045f600e5667fb09a1131da2b790 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 9 Jun 2011 23:09:12 -0400 Subject: v3: cgi, sample search form, force utf-8 character encoding to avoid issues --- lib/sisu/v3/cgi_sql_common.rb | 53 ++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/cgi_sql_common.rb b/lib/sisu/v3/cgi_sql_common.rb index c782d48f..8dce0743 100644 --- a/lib/sisu/v3/cgi_sql_common.rb +++ b/lib/sisu/v3/cgi_sql_common.rb @@ -842,6 +842,15 @@ module SiSU_CGI_sql 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 @@ -849,25 +858,43 @@ module SiSU_CGI_sql when /filetype/ <<-'WOK_SQL' def path_manifest(fn,ln=nil) - "#{@hostpath}/manifest/#{fn}.html" + "#{@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}.html" + "#{@hostpath}/html/#{fn}.#{ln}.html" end WOK_SQL else <<-'WOK_SQL' def path_manifest(fn,ln=nil) - "#{@hostpath}/#{fn}/manifest.html" + "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html" end def path_html_seg(fn,ln=nil) "#{@hostpath}/#{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}/#{fn}/doc.html" + "#{path_html_seg(fn,ln)}/scroll.#{ln}.html" end WOK_SQL end @@ -890,7 +917,7 @@ module SiSU_CGI_sql can_txt_srch=(cgi['view']=~/index/) \ ? %{search } \ : %{search } - title=%{toc html #{ti} [#{c['language_document_char']}] by #{c['creator_author']} #{can_txt_srch}toc html manifest
} if file_suffix=~/s/ #hmm watch file_suffix + title=%{toc html #{ti} [#{c['language_document_char']}] by #{c['creator_author']} #{can_txt_srch}toc html manifest
} if file_suffix=~/s/ #hmm watch file_suffix title=@text_search_flag \ ? '

'+title \ : '
'+title @@ -927,7 +954,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 @@ -935,7 +962,7 @@ 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']}, } end @@ -981,9 +1008,9 @@ module SiSU_CGI_sql if e['metadata_tid'].to_i != oldtid.to_i ti=e['title'] can_txt_srch=(cgi['view']=~/index/) \ - ? %{search } \ - : %{search } - title=%{


toc html #{ti} [#{c['language_document_char']}] by #{e['creator_author']} #{can_txt_srch}toc html manifest
} if file_suffix=~/s/ + ? %{search } \ + : %{search } + title=%{

toc html #{ti} [#{e['language_document_char']}] 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 = '' @@ -994,10 +1021,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}} + 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/ @@ -1021,7 +1048,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 + @endnotes + canned + @tail} #% print cgi_output_header+counters+body+endnotes + cgi.out{@header.force_encoding("UTF-8") + @counters_txt.force_encoding("UTF-8") + @counters_endn.force_encoding("UTF-8") + canned.force_encoding("UTF-8") + @body_main.force_encoding("UTF-8") + @endnotes.force_encoding("UTF-8") + canned.force_encoding("UTF-8") + @tail.force_encoding("UTF-8")} #% print cgi_output_header+counters+body+endnotes end rescue Exception => e s='
' + CGI::escapeHTML(e.backtrace.reverse.join("\n"))
-- 
cgit v1.2.3