aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2011-06-09 23:09:12 -0400
committerRalph Amissah <ralph@amissah.com>2011-06-09 23:09:14 -0400
commit5a1e3ba75950045f600e5667fb09a1131da2b790 (patch)
tree2540594a5657cc2b0c8d8ee835627e2cb175ae18
parentv3: cgi, sample search form reverted to '#!/usr/bin/env ruby' (diff)
v3: cgi, sample search form, force utf-8 character encoding to avoid issuessisu_3.0.12
-rw-r--r--data/doc/sisu/CHANGELOG_v33
-rw-r--r--lib/sisu/v3/cgi_sql_common.rb53
2 files changed, 43 insertions, 13 deletions
diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3
index 89d301a9..5af32fc2 100644
--- a/data/doc/sisu/CHANGELOG_v3
+++ b/data/doc/sisu/CHANGELOG_v3
@@ -33,6 +33,9 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.0.12.orig.tar.gz
1.9.2, so cgi headers changed back to #!/usr/bin/env ruby [however must
use ruby >=1.9.2] (from #!/usr/bin/ruby1.8) [see sisu-3.0.8 NOTE &
"sample search form" solution, (now superseded)]
+ * force utf-8 character encoding to avoid issues, fix
+ (incompatible character encodings: UTF-8 and US-ASCII)
+ * correction of a variable name, fix
* options
* restrict glob rule checks to when --glob (-G) or --find (-f) requested
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/) \
? %{<a href="#{@canned_base_url}&fns=#{c['src_filename']}&lang=#{c['language_document_char']}&view=text"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a>&nbsp;} \
: %{<a href="#{@canned_base_url}&fns=#{c['src_filename']}&lang=#{c['language_document_char']}&view=index"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a>&nbsp;}
- title=%{<span style="background-color: #{@color_heading}"><a href="#{path_html_seg(location,c['language_document_char'])}/toc.html"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html">&nbsp;#{ti}</a></span> [#{c['language_document_char']}] by #{c['creator_author']} #{can_txt_srch}<a href="#{path_html_seg(location,c['language_document_char'])}/toc.html"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"></a>&nbsp;<a href="#{path_manifest(location,c['language_document_char'])}"><img border="0" width="15" height="15" src="#{@image_src}/b_info.png" alt="manifest"></a><br />} if file_suffix=~/s/ #hmm watch file_suffix
+ title=%{<span style="background-color: #{@color_heading}"><a href="#{path_toc(location,c['language_document_char'])}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html">&nbsp;#{ti}</a></span> [#{c['language_document_char']}] by #{c['creator_author']} #{can_txt_srch}<a href="#{path_toc(location,c['language_document_char'])}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"></a>&nbsp;<a href="#{path_manifest(location,c['language_document_char'])}"><img border="0" width="15" height="15" src="#{@image_src}/b_info.png" alt="manifest"></a><br />} if file_suffix=~/s/ #hmm watch file_suffix
title=@text_search_flag \
? '<br /><hr>'+title \
: '<br />'+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(/(<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_html_seg(location,@ln)}/#{c['seg']}#{lang}.html##{c['ocn']}">#{c['ocn']}</a></b>:</font></p>#{matched_para}}
+ %{<hr><p><font size="2">ocn <b><a href="#{path_filename(location,c['seg'],@ln)}##{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
@@ -935,7 +962,7 @@ module SiSU_CGI_sql
output=title+text
else #elsif cgi['view']=~/index/ #% idx body
if c['suffix'] !~/1/ #seg
- index=%{<a href="#{path_html_seg(location,@ln)}/#{c['seg']}#{lang}.html##{c['ocn']}">#{c['ocn']}</a>, } if @text_search_flag
+ index=%{<a href="#{path_filename(location,c['seg'],@ln)}##{c['ocn']}">#{c['ocn']}</a>, } if @text_search_flag
elsif c['suffix'] =~/1/ #doc #FIX
index=%{<a href="#{path_html_doc(location,@ln)}##{c['ocn']}">#{c['ocn']}</a>, }
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/) \
- ? %{<a href="#{@canned_base_url}&fns=#{e['src_filename']}&lang=#{c['language_document_char']}&view=text"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a>&nbsp;} \
- : %{<a href="#{@canned_base_url}&fns=#{e['src_filename']}&lang=#{c['language_document_char']}&view=index"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a>&nbsp;}
- title=%{<br /><hr><span style="background-color: #{@color_heading}"><a href="#{path_html_seg(location,@ln)}/toc.html"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html">&nbsp;#{ti}</a></span> [#{c['language_document_char']}] by #{e['creator_author']} #{can_txt_srch}<a href="#{path_html_seg(location,@ln)}/toc.html"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"></a>&nbsp;<a href="#{path_manifest(location,@ln)}"><img border="0" width="15" height="15" src="#{@image_src}/b_info.png" alt="manifest"></a><br />} if file_suffix=~/s/
+ ? %{<a href="#{@canned_base_url}&fns=#{e['src_filename']}&lang=#{e['language_document_char']}&view=text"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a>&nbsp;} \
+ : %{<a href="#{@canned_base_url}&fns=#{e['src_filename']}&lang=#{e['language_document_char']}&view=index"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a>&nbsp;}
+ title=%{<br /><hr><span style="background-color: #{@color_heading}"><a href="#{path_toc(location,@ln)}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html">&nbsp;#{ti}</a></span> [#{e['language_document_char']}] by #{e['creator_author']} #{can_txt_srch}<a href="#{path_toc(location,@ln)}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"></a>&nbsp;<a href="#{path_manifest(location,@ln)}"><img border="0" width="15" height="15" src="#{@image_src}/b_info.png" alt="manifest"></a><br />} 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(/(<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_html_seg(location,@ln)}/endnotes.html#_#{e['nr']}">#{e['nr']}</a></b> referred to from ocn <a href="#{path_html_doc(location,@ln)}##{e['ocn']}">#{e['ocn']}</a>:</font> #{matched_endnote}}
+ output=%{#{title}<hr><font size="2">note <b><a href="#{path_endnotes(location,@ln)}#_#{e['nr']}">#{e['nr']}</a></b> referred to from ocn <a href="#{path_html_doc(location,@ln)}##{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_html_seg(location,@ln)}/endnotes.html#_#{e['nr']}">#{e['nr']}</a> [&sect; <a href="#{path_html_doc(location,@ln)}##{e['ocn']}">#{e['ocn']}</a>], }
+ output=%{#{title}<a href="#{path_endnotes(location,@ln)}#_#{e['nr']}">#{e['nr']}</a> [&sect; <a href="#{path_html_doc(location,@ln)}##{e['ocn']}">#{e['ocn']}</a>], }
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='<pre>' + CGI::escapeHTML(e.backtrace.reverse.join("\n"))