aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2007-07-16 12:50:53 +0100
committerRalph Amissah <ralph@amissah.com>2007-07-16 12:50:53 +0100
commit7b15f4d032cbc8e0a313a48095373216a942ede9 (patch)
tree6601d3c5b80ca4acf9990788485cc86b32bb976b
parentrefactoring, tidy (diff)
cgi_sql_common, generated sample search form, indentation
-rw-r--r--lib/sisu/v0/cgi_sql_common.rb304
1 files changed, 152 insertions, 152 deletions
diff --git a/lib/sisu/v0/cgi_sql_common.rb b/lib/sisu/v0/cgi_sql_common.rb
index 50fce2fc..633be166 100644
--- a/lib/sisu/v0/cgi_sql_common.rb
+++ b/lib/sisu/v0/cgi_sql_common.rb
@@ -488,7 +488,7 @@ module SiSU_CGI_sql
end
else
if page.to_s =~ /^1$/; ''
- elsif /^[2]$/
+ elsif page.to_s =~ /^2$/
%{<hr /><br /><center>
<a href="#{can.previous}">
<img border="0" width="22" height="22" src="#{img}/arrow_prev_red.png" alt="&lt;&lt;&nbsp;" />
@@ -749,178 +749,178 @@ module SiSU_CGI_sql
#{p_text} #{p_keywords} #{p_title} #{p_author} #{p_subject} #{p_description} #{p_publisher} #{p_contributor} #{p_date} #{p_type} #{p_format} #{p_identifier} #{p_source} #{p_language} #{p_relation} #{p_coverage} #{p_rights} #{p_comment} #{p_abstract} #{p_filename}
</font>
WOK
- #eg = %{canned search e.g.:<br /> <a href="#{url}">#{url}</a><br />find: #{analyze}<br />database: #{database}}
- #dbi_canning
- @header=Form.new(@base,search_field,selected_db,checked_index,checked_text,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"
- puts (@header+@tail)
- else #% searches
- s1=if @search_for.text1 =~/\S/
- @search_for.text1
- else 'Unavailable'
+ #eg = %{canned search e.g.:<br /> <a href="#{url}">#{url}</a><br />find: #{analyze}<br />database: #{database}}
+ #dbi_canning
+ @header=Form.new(@base,search_field,selected_db,checked_index,checked_text,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"
+ puts (@header+@tail)
+ else #% searches
+ s1=if @search_for.text1 =~/\S/
+ @search_for.text1
+ else 'Unavailable'
+ end
+ if checked_case=~/\S/
+ @search[:text]<<%{documents.clean~'#{CGI.unescape(s1)}'}
+ @search[:endnotes]<<%{endnotes.clean~'#{CGI.unescape(s1)}'}
+ else
+ @search[:text]<<%{documents.clean~*'#{CGI.unescape(s1)}'}
+ @search[:endnotes]<<%{endnotes.clean~*'#{CGI.unescape(s1)}'}
+ end
+ #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=[],[]
+ @search_regx=nil
+ oldtid=0
+ if @text_search_flag
+ if checked_sql =~/\S/
+ sql_select_body=dbi_statement.sql_select_body_format
+ sql_select_endnotes=dbi_statement.sql_select_endnotes_format
+ else sql_select_body,sql_select_endnotes='',''
end
- if checked_case=~/\S/
- @search[:text]<<%{documents.clean~'#{CGI.unescape(s1)}'}
- @search[:endnotes]<<%{endnotes.clean~'#{CGI.unescape(s1)}'}
- else
- @search[:text]<<%{documents.clean~*'#{CGI.unescape(s1)}'}
- @search[:endnotes]<<%{endnotes.clean~*'#{CGI.unescape(s1)}'}
+ @body_main << '<p><hr><br /><b>Main Text:</b><br />' << sql_select_body
+ @endnotes << '<p><hr><br /><b>Endnotes:</b><br />' << sql_select_endnotes
+ else
+ end
+ #text_objects_body
+ s_contents.each do |c| #% text body
+ location=c['filename'][/(.+?)\.(?:_?sst|ssm)$/,1]
+ file_suffix=c['filename'][/.+?\.(_?sst|ssm)$/,1]
+ lang=if location =~ /\S+?~(\S\S\S?)$/
+ l=location[/\S+?~(\S\S\S?)$/,1]
+ location.gsub!(/(\S+?)~\S\S\S?/,'\1')
+ l=".#{l}"
+ else ''
end
- #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=[],[]
- @search_regx=nil
- oldtid=0
- if @text_search_flag
- if checked_sql =~/\S/
- sql_select_body=dbi_statement.sql_select_body_format
- sql_select_endnotes=dbi_statement.sql_select_endnotes_format
- else sql_select_body,sql_select_endnotes='',''
+ #metadata_found_body
+ if c['tid'].to_i != oldtid.to_i
+ ti=if c['subtitle'] =~/\S+/; "#{c['title']} - #{c['subtitle']}"
+ else c['title']
end
- @body_main << '<p><hr><br /><b>Main Text:</b><br />' << sql_select_body
- @endnotes << '<p><hr><br /><b>Endnotes:</b><br />' << sql_select_endnotes
- else
- end
- #text_objects_body
- s_contents.each do |c| #% text body
- location=c['filename'][/(.+?)\.(?:_?sst|ssm)$/,1]
- file_suffix=c['filename'][/.+?\.(_?sst|ssm)$/,1]
- lang=if location =~ /\S+?~(\S\S\S?)$/
- l=location[/\S+?~(\S\S\S?)$/,1]
- location.gsub!(/(\S+?)~\S\S\S?/,'\1')
- l=".#{l}"
- else ''
+ can_txt_srch=if cgi['view']=~/index/; %{<a href="#{@canned_base_url}&fns=#{c['filename']}&view=text"><img border="0" width="12" height="12" src="#@image_src/bullet_red.png" alt="red bullet"></a>&nbsp;}
+ else %{<a href="#{@canned_base_url}&fns=#{c['filename']}&view=index"><img border="0" width="12" height="12" src="#@image_src/bullet_red.png" alt="red bullet"></a>&nbsp;}
end
- #metadata_found_body
- if c['tid'].to_i != oldtid.to_i
- ti=if c['subtitle'] =~/\S+/; "#{c['title']} - #{c['subtitle']}"
- else c['title']
- end
- can_txt_srch=if cgi['view']=~/index/; %{<a href="#{@canned_base_url}&fns=#{c['filename']}&view=text"><img border="0" width="12" height="12" src="#@image_src/bullet_red.png" alt="red bullet"></a> }
- else %{<a href="#{@canned_base_url}&fns=#{c['filename']}&view=index"><img border="0" width="12" height="12" src="#@image_src/bullet_red.png" alt="red bullet"></a> }
- end
- title=%{<span style="background-color: #@color_heading"><a href="#@hosturl_files/#@stub/#{location}/toc#{lang}.html"><img border="0" width="15" height="18" src="#@image_src/b_toc.png" alt="toc html">&nbsp;#{ti}</a></span> by #{c['creator']} #{can_txt_srch}<a href="#@hosturl_files/#@stub/#{location}/toc#{lang}.html"><img border="0" width="15" height="18" src="#@image_src/b_toc.png" alt="toc html"></a> <a href="#@hosturl_files/#@stub/#{location}/portrait#{lang}.pdf"><img border="0" width="15" height="18" src="#@image_src/b_pdf.png" alt="pdf portrait"></a> <a href="#@hosturl_files/#@stub/#{location}/landscape#{lang}.pdf"><img border="0" width="18" height="15" src="#@image_src/b_pdf.png" alt="pdf landscape"></a> <a href="#@hosturl_files/#@stub/#{location}/opendocument#{lang}.odt"><img border="0" width="15" height="15" src="#@image_src/b_odf.png" alt="odf"></a> <a href="#@hosturl_files/#@stub/#{location}/sisu_manifest#{lang}.html"><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
- if @text_search_flag; title='<br /><hr>'+title
- else title='<br />'+title
- end
- @counter_txt_doc+=1
- oldtid=c['tid'].to_i
- else title=''
+ title=%{<span style="background-color: #@color_heading"><a href="#@hosturl_files/#@stub/#{location}/toc#{lang}.html"><img border="0" width="15" height="18" src="#@image_src/b_toc.png" alt="toc html">&nbsp;#{ti}</a></span> by #{c['creator']} #{can_txt_srch}<a href="#@hosturl_files/#@stub/#{location}/toc#{lang}.html"><img border="0" width="15" height="18" src="#@image_src/b_toc.png" alt="toc html"></a>&nbsp;<a href="#@hosturl_files/#@stub/#{location}/portrait#{lang}.pdf"><img border="0" width="15" height="18" src="#@image_src/b_pdf.png" alt="pdf portrait"></a>&nbsp;<a href="#@hosturl_files/#@stub/#{location}/landscape#{lang}.pdf"><img border="0" width="18" height="15" src="#@image_src/b_pdf.png" alt="pdf landscape"></a>&nbsp;<a href="#@hosturl_files/#@stub/#{location}/opendocument#{lang}.odt"><img border="0" width="15" height="15" src="#@image_src/b_odf.png" alt="odf"></a>&nbsp;<a href="#@hosturl_files/#@stub/#{location}/sisu_manifest#{lang}.html"><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
+ if @text_search_flag; title='<br /><hr>'+title
+ else title='<br />'+title
end
- if @text_search_flag
- if cgi['view']=~/text/ #% txt body
- text=if c['suffix'] !~/1/ #seg
- if @search_for.text1 =~/\S+/ or q['s1'] =~/\S+/ #% only this branch is working !!
- unescaped_search=if @search_for.text1 =~/\S+/; CGI.unescape(@search_for.text1)
- elsif q['s1'] =~/\S+/; CGI.unescape(q['s1'])
- else nil
- end
- @search_regx=if unescaped_search #check
- search_regex=[]
- build=unescaped_search.scan(/\S+/).each do |g|
- if g.to_s =~/(AND|OR)/
- search_regex << '|'
- else search_regex << %{#{g.to_s}}
- end
- end
- search_regex=search_regex.join(' ')
- search_regex=search_regex.gsub(/\s*\|\s*/,'|')
- Regexp.new(search_regex, Regexp::IGNORECASE)
- else nil
- end
+ @counter_txt_doc+=1
+ oldtid=c['tid'].to_i
+ else title=''
+ end
+ if @text_search_flag
+ if cgi['view']=~/text/ #% txt body
+ text=if c['suffix'] !~/1/ #seg
+ if @search_for.text1 =~/\S+/ or q['s1'] =~/\S+/ #% only this branch is working !!
+ unescaped_search=if @search_for.text1 =~/\S+/; CGI.unescape(@search_for.text1)
+ elsif q['s1'] =~/\S+/; CGI.unescape(q['s1'])
else nil
end
- matched_para=if (@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/)
- matched=c['body'].gsub(/(<a\s+href="https?:\/\/[^><\s]+#{@search_regx}[^>]+?>|#@search_regx)/mi,%{<span style="background-color: #@color_match">\\1</span>})
- else c['body']
+ @search_regx=if unescaped_search #check
+ search_regex=[]
+ build=unescaped_search.scan(/\S+/).each do |g|
+ if g.to_s =~/(AND|OR)/
+ search_regex << '|'
+ else search_regex << %{#{g.to_s}}
+ end
+ end
+ search_regex=search_regex.join(' ')
+ search_regex=search_regex.gsub(/\s*\|\s*/,'|')
+ Regexp.new(search_regex, Regexp::IGNORECASE)
+ else nil
end
- %{<hr><p><font size="2">ocn <b><a href="#@hosturl_files/#@stub/#{location}/#{c['seg']}#{lang}.html##{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']}}
+ else nil
end
- @counter_txt_ocn+=1
- output=if c['seg'] =~/\S+/; title+text
- else text
- end
- elsif cgi['view']=~/index/ #% idx body
- if c['suffix'] !~/1/ #seg
- index=%{<a href="#@hosturl_files/#@stub/#{location}/#{c['seg']}#{lang}.html##{c['ocn']}">#{c['ocn']}</a>, } if @text_search_flag
- elsif c['suffix'] =~/1/ #doc
- index=%{<a href="#@hosturl_files/#@stub/#{location}/doc#{lang}.html##{c['ocn']}">#{c['ocn']}</a>, }
+ matched_para=if (@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/)
+ matched=c['body'].gsub(/(<a\s+href="https?:\/\/[^><\s]+#{@search_regx}[^>]+?>|#@search_regx)/mi,%{<span style="background-color: #@color_match">\\1</span>})
+ else c['body']
end
- if c['seg'] =~/\S+/
- if @text_search_flag
- @counter_txt_ocn+=1
- output=title+index
- end
- else
+ %{<hr><p><font size="2">ocn <b><a href="#@hosturl_files/#@stub/#{location}/#{c['seg']}#{lang}.html##{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
+ @counter_txt_ocn+=1
+ output=if c['seg'] =~/\S+/; title+text
+ else text
+ end
+ elsif cgi['view']=~/index/ #% idx body
+ if c['suffix'] !~/1/ #seg
+ index=%{<a href="#@hosturl_files/#@stub/#{location}/#{c['seg']}#{lang}.html##{c['ocn']}">#{c['ocn']}</a>, } if @text_search_flag
+ elsif c['suffix'] =~/1/ #doc
+ index=%{<a href="#@hosturl_files/#@stub/#{location}/doc#{lang}.html##{c['ocn']}">#{c['ocn']}</a>, }
+ end
+ if c['seg'] =~/\S+/
+ if @text_search_flag
@counter_txt_ocn+=1
- output=unless c['suffix'] =~/1/; title+index
- else %{#{title}#{c['ocn'].sort}, }
- end
+ output=title+index
end
- end
- else output=title
- end
- @counters_txt=if @counter_txt_doc > 0
- if checked_stats =~/\S/
- @@lt_t=if @counter_txt_ocn == dbi_statement.sql_limit.to_i
- over='over'
- true
- else
- over=''
- false
+ else
+ @counter_txt_ocn+=1
+ output=unless c['suffix'] =~/1/; title+index
+ else %{#{title}#{c['ocn'].sort}, }
end
- %{<hr /><font size="2" color="#666666">Found in the main body of #@counter_txt_doc documents, and at #{over} #@counter_txt_ocn locations within.</font><br />}
- else ''
end
- else ''
end
- @body_main << output #+ details
+ else output=title
end
- #text_objects_endnote
- oldtid = 0
- s_endnotes.each do |e| #% endnotes
- location=e['filename'][/(.+?)\.(?:_?sst|ssm)$/,1]
- file_suffix=e['filename'][/.+?\.(_?sst|ssm)$/,1]
- lang=if location =~ /\S+?~(\S\S\S?)$/
- l=location[/\S+?~(\S\S\S?)$/,1]
- location.gsub!(/(\S+?)~\S\S\S?/,'\1')
- l=".#{l}"
+ @counters_txt=if @counter_txt_doc > 0
+ if checked_stats =~/\S/
+ @@lt_t=if @counter_txt_ocn == dbi_statement.sql_limit.to_i
+ over='over'
+ true
+ else
+ over=''
+ false
+ end
+ %{<hr /><font size="2" color="#666666">Found in the main body of #@counter_txt_doc documents, and at #{over} #@counter_txt_ocn locations within.</font><br />}
else ''
end
+ else ''
+ end
+ @body_main << output #+ details
+ end
+ #text_objects_endnote
+ oldtid = 0
+ s_endnotes.each do |e| #% endnotes
+ location=e['filename'][/(.+?)\.(?:_?sst|ssm)$/,1]
+ file_suffix=e['filename'][/.+?\.(_?sst|ssm)$/,1]
+ lang=if location =~ /\S+?~(\S\S\S?)$/
+ l=location[/\S+?~(\S\S\S?)$/,1]
+ location.gsub!(/(\S+?)~\S\S\S?/,'\1')
+ l=".#{l}"
+ else ''
+ end
#metadata_found_endnotes
- if @text_search_flag
- if e['metadata_tid'].to_i != oldtid.to_i
- ti=if e['subtitle'] =~/\S+/; "#{e['title']} - #{e['subtitle']}"
- else e['title']
- end
- can_txt_srch=if cgi['view']=~/index/; %{<a href="#{@canned_base_url}&fns=#{e['filename']}&view=text"><img border="0" width="12" height="12" src="#@image_src/bullet_red.png" alt="red bullet"></a> }
- else %{<a href="#{@canned_base_url}&fns=#{e['filename']}&view=index"><img border="0" width="12" height="12" src="#@image_src/bullet_red.png" alt="red bullet"></a> }
- end
- title=%{<br /><hr><span style="background-color: #@color_heading"><a href="#@hosturl_files/#@stub/#{location}/toc#{lang}.html"><img border="0" width="15" height="18" src="#@image_src/b_toc.png" alt="toc html">&nbsp;#{ti}</a></span> by #{e['creator']} #{can_txt_srch}<a href="#@hosturl_files/#@stub/#{location}/toc#{lang}.html"><img border="0" width="15" height="18" src="#@image_src/b_toc.png" alt="toc html"></a> <a href="#@hosturl_files/#@stub/#{location}/portrait.pdf"><img border="0" width="15" height="18" src="#@image_src/b_pdf.png" alt="pdf portrait"></a><a href="#@hosturl_files/#@stub/#{location}/landscape.pdf"><img border="0" width="18" height="15" src="#@image_src/b_pdf.png" alt="pdf landscape"></a> <a href="#@hosturl_files/#@stub/#{location}/opendocument#{lang}.odt"><img border="0" width="15" height="15" src="#@image_src/b_odf.png" alt="odf"></a> <a href="#@hosturl_files/#@stub/#{location}/sisu_manifest#{lang}.html"><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 = ''
+ if @text_search_flag
+ if e['metadata_tid'].to_i != oldtid.to_i
+ ti=if e['subtitle'] =~/\S+/; "#{e['title']} - #{e['subtitle']}"
+ else e['title']
end
- if cgi['view']=~/text/ #% txt endnotes
- @counter_endn_ocn+=1
- matched_endnote=if (@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>})
- else e['body']
- end
- output=%{#{title}<hr><font size="2">note <b><a href="#@hosturl_files/#@stub/#{location}/endnotes.html#_#{e['nr']}">#{e['nr']}</a></b> referred to from ocn <a href="#@hosturl_files/#@stub/#{location}/doc.html##{e['ocn']}">#{e['ocn']}</a>:</font> #{matched_endnote}}
- elsif cgi['view']=~/index/ #% idx endnotes
- @counter_endn_ocn+=1
- output=%{#{title}<a href="#@hosturl_files/#@stub/#{location}/endnotes.html#_#{e['nr']}">#{e['nr']}</a> [&sect; <a href="#@hosturl_files/#@stub/#{location}/doc.html##{e['ocn']}">#{e['ocn']}</a>], }
+ can_txt_srch=if cgi['view']=~/index/; %{<a href="#{@canned_base_url}&fns=#{e['filename']}&view=text"><img border="0" width="12" height="12" src="#@image_src/bullet_red.png" alt="red bullet"></a>&nbsp;}
+ else %{<a href="#{@canned_base_url}&fns=#{e['filename']}&view=index"><img border="0" width="12" height="12" src="#@image_src/bullet_red.png" alt="red bullet"></a>&nbsp;}
+ end
+ title=%{<br /><hr><span style="background-color: #@color_heading"><a href="#@hosturl_files/#@stub/#{location}/toc#{lang}.html"><img border="0" width="15" height="18" src="#@image_src/b_toc.png" alt="toc html">&nbsp;#{ti}</a></span> by #{e['creator']} #{can_txt_srch}<a href="#@hosturl_files/#@stub/#{location}/toc#{lang}.html"><img border="0" width="15" height="18" src="#@image_src/b_toc.png" alt="toc html"></a>&nbsp;<a href="#@hosturl_files/#@stub/#{location}/portrait.pdf"><img border="0" width="15" height="18" src="#@image_src/b_pdf.png" alt="pdf portrait"></a>&nbsp;<a href="#@hosturl_files/#@stub/#{location}/landscape.pdf"><img border="0" width="18" height="15" src="#@image_src/b_pdf.png" alt="pdf landscape"></a>&nbsp;<a href="#@hosturl_files/#@stub/#{location}/opendocument#{lang}.odt"><img border="0" width="15" height="15" src="#@image_src/b_odf.png" alt="odf"></a>&nbsp;<a href="#@hosturl_files/#@stub/#{location}/sisu_manifest#{lang}.html"><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 = ''
+ end
+ if cgi['view']=~/text/ #% txt endnotes
+ @counter_endn_ocn+=1
+ matched_endnote=if (@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>})
+ else e['body']
end
- @counters_endn=if @counter_endn_doc > 0
- if checked_stats =~/\S/
+ output=%{#{title}<hr><font size="2">note <b><a href="#@hosturl_files/#@stub/#{location}/endnotes.html#_#{e['nr']}">#{e['nr']}</a></b> referred to from ocn <a href="#@hosturl_files/#@stub/#{location}/doc.html##{e['ocn']}">#{e['ocn']}</a>:</font> #{matched_endnote}}
+ elsif cgi['view']=~/index/ #% idx endnotes
+ @counter_endn_ocn+=1
+ output=%{#{title}<a href="#@hosturl_files/#@stub/#{location}/endnotes.html#_#{e['nr']}">#{e['nr']}</a> [&sect; <a href="#@hosturl_files/#@stub/#{location}/doc.html##{e['ocn']}">#{e['ocn']}</a>], }
+ end
+ @counters_endn=if @counter_endn_doc > 0
+ if checked_stats =~/\S/
@@lt_e=if @counter_endn_ocn == dbi_statement.sql_limit.to_i
over='over'
true