aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/cgi_sql_common.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2007-07-10 15:35:44 +0100
committerRalph Amissah <ralph@amissah.com>2007-07-10 15:35:44 +0100
commit22fab950e51ba9fc551bea840925b3020ec381bc (patch)
tree2e7978ff32ec31bc740b8f33b3c4aa24743493e1 /lib/sisu/v0/cgi_sql_common.rb
parentimproved url matching, and texpdf tolerance and indentation levels set (diff)
cgi search form worked on and presentation, (an info button added and used)
* cgi, generated sample search form, rearranged presentation * editor syntax highlighting, kate, kwrite visited
Diffstat (limited to 'lib/sisu/v0/cgi_sql_common.rb')
-rw-r--r--lib/sisu/v0/cgi_sql_common.rb166
1 files changed, 72 insertions, 94 deletions
diff --git a/lib/sisu/v0/cgi_sql_common.rb b/lib/sisu/v0/cgi_sql_common.rb
index 37ca67b8..fbb627db 100644
--- a/lib/sisu/v0/cgi_sql_common.rb
+++ b/lib/sisu/v0/cgi_sql_common.rb
@@ -131,13 +131,13 @@ module SiSU_CGI_sql
@color_heading='#DDFFAA'
@color_match='#ffff48'
class Form
- def initialize(base,search_field,selected_db,checked_index,checked_text,checked_tip,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,search_note,the_can='')
+ def initialize(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='')
search_note='' if checked_searched !~/\S/
the_can='' if checked_url !~/\S/
search_field='' if checked_echo !~/\S/
- @base,@search_field,@selected_db,@checked_index,@checked_text,@checked_tip,@checked_searched,@checked_url,@checked_case,@checked_echo,@checked_sql,@checked_all,@checked_none,@checked_ignore,@search_note,@the_can=base,search_field,selected_db,checked_index,checked_text,checked_tip,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,search_note,the_can
+ @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=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
@tip=if checked_tip =~/\S/
- '<font size="2" color="#666666">text:__; keywords:__; title:__; author:__; subject:__; description:__; publisher:__; contributor:__; date:__; type:__; format:__; identifier:__; source:__; language:__; relation:__; coverage:__; rights:__; comment:__; abstract:__; filename:__;</font>'
+ '<font size="2" color="#666666">text:__; keywords:__; title:__; author:__; subject:__; description:__; publisher:__; contributor:__; date:__; type:__; format:__; identifier:__; source:__; language:__; relation:__; coverage:__; rights:__; comment:__; abstract:__; filename:__;</font><br />'
else ''
end
end
@@ -171,62 +171,53 @@ module SiSU_CGI_sql
end
def header2
<<-'WOK_SQL'
- <table cellpadding="0">
- <tr><td valign=\"top\">
- <form action="#@base" id="Test Form" method="post">
- <!input type="text" id="find" name="find" value="#@search_field" />
- <!input type="text" id="find" name="find" value="" />
- <font size="2" color="#222222">
- select which database to search
- </font>
- <br />
- <select name="db" size="1">
- #@selected_db
- WOK_SQL
- end
- def buttons1
- <<-'WOK_SQL'
- </select>
- <font size="2" color="#222222">
- <input type="radio" name="view" value="index" #@checked_index> index
- <input type="radio" name="view" value="text" #@checked_text> text / grep
- </font>
- </td></tr></table>
+ <form action="#@base" id="Test Form" method="post">
<table cellpadding="2">
<tr><td valign=\"top\">
- <textarea id="find" name="find" type="text" rows="4" cols="30" maxlength="256">#@search_field</textarea>
- <br /><input type="submit" value="SiSU search" />
- WOK_SQL
- end
- def buttons2
- <<-'WOK_SQL'
+ <textarea id="find" name="find" type="text" rows="4" cols="30" maxlength="256">#@search_field</textarea>
</td>
<td valign=\"top\">
#@tip
#@search_note
#@the_can
</td></tr></table>
- <table><tr><td>
+ <td valign=\"top\"><tr><td>
+ <!input type="text" id="find" name="find" value="#@search_field" />
+ <!input type="text" id="find" name="find" value="" />
+ <font size="2" color="#222222">
+ <b>to search:</b> select which database to search (drop-down menu below); enter your search query (in the form above); and <b>click on the search button</b> (below)
+ <br />
+ <select name="db" size="1">
+ #@selected_db
+ WOK_SQL
+ end
+ def buttons1
+ <<-'WOK_SQL'
+ </select>
+ <input type="submit" value="SiSU search" />
+ <input type="radio" name="view" value="index" #@checked_index> index
+ <input type="radio" name="view" value="text" #@checked_text> text / grep
WOK_SQL
end
- def buttons3
+ def buttons2
<<-'WOK_SQL'
- <br />
- <input type="checkbox" name="echo" #@checked_echo> echo previous search
- <input type="checkbox" name="searched" #@checked_searched> search result stats
- <input type="checkbox" name="url" #@checked_url> url for search
- <input type="checkbox" name="tip" #@checked_tip> available search fields
- <input type="checkbox" name="sql" #@checked_sql> sql statement
- <br />
- checks:
- <input type="radio" name="checks" value="check_ignore" #@checked_ignore> selected
- <input type="radio" name="checks" value="check_all" #@checked_all> all
- <input type="radio" name="checks" value="check_none" #@checked_none> none
- </font>
-
+ <br />
+ <input type="checkbox" name="echo" #@checked_echo> echo query
+ <input type="checkbox" name="stats" #@checked_stats> result stats
+ <input type="checkbox" name="url" #@checked_url> search url
+ <input type="checkbox" name="searched" #@checked_searched> searched
+ <input type="checkbox" name="tip" #@checked_tip> available fields
+ <input type="checkbox" name="sql" #@checked_sql> sql statement
+ <br />
+ checks:
+ <input type="radio" name="checks" value="check_default" #@checked_default> default
+ <input type="radio" name="checks" value="check_selected" #@checked_selected> selected
+ <input type="radio" name="checks" value="check_all" #@checked_all> all
+ <input type="radio" name="checks" value="check_none" #@checked_none> none
+ </font>
</td></tr>
</table>
- </form>
+ </form>
WOK
end
end
@@ -601,23 +592,34 @@ module SiSU_CGI_sql
@stub='sisu'
'SiSU_sisu'
end
- checked_url,checked_searched,checked_tip,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,selected_db='','','','','','','','',''
+ checked_url,checked_stats,checked_searched,checked_tip,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,selected_db='','','','','','','','',''
if cgi['view']=~/text/; checked_index,checked_text='','checked'
else checked_index,checked_text='checked',''
end
+ checked_echo='checked' if cgi['echo'] =~/\S/
+ checked_stats='checked' if cgi['stats'] =~/\S/
checked_url='checked' if cgi['url'] =~/\S/ or cgi['u'].to_i==1
checked_searched='checked' if cgi['searched'] =~/\S/
checked_tip='checked' if cgi['tip'] =~/\S/
checked_case='checked' if cgi['casesense'] =~/\S/
- checked_echo='checked' if cgi['echo'] =~/\S/
checked_sql='checked' if cgi['sql'] =~/\S/
if cgi['checks'] =~/check_all/ or cgi['check_all'] =~/\S/ or cgi['a'].to_i==1
- checked_all=checked_url=checked_searched=checked_tip=checked_echo=checked_sql='checked'
+ checked_all='checked'
+ checked_echo=checked_stats=checked_url=checked_searched=checked_tip=checked_sql='checked'
checked_none=''
- elsif cgi['checks'] =~/check_none/ #or cgi['a'].to_i==0
+ elsif cgi['checks'] =~/check_none/
checked_none='checked'
- checked_all=checked_url=checked_searched=checked_tip=checked_echo=checked_sql=''
- else checked_ignore='checked'
+ checked_all=checked_url=checked_stats=checked_searched=checked_tip=checked_echo=checked_sql=''
+ elsif cgi['checks'] =~/check_selected/
+ checked_selected='checked'
+ elsif cgi['checks'] =~/check_default/
+ checked_default='checked'
+ checked_echo=checked_stats=checked_url='checked'
+ checked_searched=checked_tip=checked_case=checked_sql=''
+ else
+ checked_selected='checked'
+ checked_echo=checked_stats=checked_url='checked'
+ checked_searched=checked_tip=checked_case=checked_sql=''
end
WOK_SQL
end
@@ -654,7 +656,7 @@ module SiSU_CGI_sql
fns='&fns=' + CGI.escape(@search_for.filename) if @search_for.filename=~/\S/
@@canned_search_url=if checked_all =~/checked/
"#@base?#{s1}#{key}#{ti}#{au}#{sj}#{dsc}#{pb}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}&a=1"
- else "#@base?#{s1}#{key}#{ti}#{au}#{sj}#{dsc}#{pb}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}&u=1&e=1"
+ else "#@base?#{s1}#{key}#{ti}#{au}#{sj}#{dsc}#{pb}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}"
end
if checked_case=~/\S/
@search[:text][1]=%{documents.clean~'#{@search_for.text1}'} #s1
@@ -663,7 +665,7 @@ module SiSU_CGI_sql
@search[:text][1]=%{documents.clean~*'#{@search_for.text1}'} #s1
@search[:endnotes][1]=%{endnotes.clean~*'#{@search_for.text1}'} #s1
end
- canned_note='previous search url:'
+ canned_note='search url:'
else
@@canned_search_url="#@base?s1=United+Nations&db=documents&view=index"
canned_note='search url example:'
@@ -684,7 +686,7 @@ module SiSU_CGI_sql
end
green=%{<font size="2" color="#004000">}
canned_search_url_txt=CGI.escapeHTML(@@canned_search_url)
- the_can=%{<font size="2" color="#666666">#{canned_note}<br /> <a href="#{@@canned_search_url}">#{canned_search_url_txt}</a></font><br />}
+ the_can=%{<font size="2" color="#666666">#{canned_note} <a href="#{@@canned_search_url}">#{canned_search_url_txt}</a></font><br />}
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_subject=p_filename=''
p_text=%{text: #{green}#{@search_for.text1}</font><br />} if @search_for.text1 =~/\S+/
p_keywords=%{keywords: #{green}#{@search_for.keywords}</font><br />} if @search_for.keywords =~/\S+/
@@ -708,15 +710,14 @@ module SiSU_CGI_sql
p_filename=%{filename: #{green}#{@search_for.filename}</font><br />} if @search_for.filename =~/\S+/
search_note=<<-WOK
<font size="2" color="#666666">
- <br /><b>previous selection</b>:<br />
- database: #{green}#@db</font>; selected view: #{green}#{cgi['view']}</font><br />
- search string: "#{green}#{analyze_format}</font>"<br />
+ <b>database:</b> #{green}#@db</font>; <b>selected view:</b> #{green}#{cgi['view']}</font>
+ <b>search string:</b> "#{green}#{analyze_format}</font>"<br />
#{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_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,search_note,the_can).submission_form #% form
+ @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)
@@ -763,7 +764,7 @@ module SiSU_CGI_sql
end
#metadata_found_body
if c['tid'].to_i != oldtid.to_i
- title=%{<span style="background-color: #@color_heading"><a href="#@hosturl_files/#@stub/#{location}/toc#{lang}.html">#{c['title']}</a></span> by #{c['creator']} <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}/sisu_manifest#{lang}.html"><img border="0" width="12" height="12" src="#@image_src/bullet_red.png" alt="manifest"><font size="2">&nbsp;?</font></a><br />} if file_suffix=~/s/ #hmm watch file_suffix
+ title=%{<span style="background-color: #@color_heading"><a href="#@hosturl_files/#@stub/#{location}/toc#{lang}.html">#{c['title']}</a></span> by #{c['creator']} <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}/sisu_manifest#{lang}.html"><img border="0" width="12" height="12" 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
@@ -796,7 +797,7 @@ module SiSU_CGI_sql
end
matched_para=if (@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/)
matched=if c['body'] =~/<a href="https?:\/\//mi; c['body']
- else (c['body'].gsub(/(#@search_regx)/,%{<span style="background-color: #@color_match">\\1</span>}))
+ else (c['body'].gsub(/(#@search_regx)/i,%{<span style="background-color: #@color_match">\\1</span>}))
end
matched
else c['body']
@@ -830,7 +831,10 @@ module SiSU_CGI_sql
else output=title
end
@counters_txt=if @counter_txt_doc > 0
- %{<font size="2" color="#666666">Found in the main body of #@counter_txt_doc documents, and at #@counter_txt_ocn locations within.</font><br />}
+ if checked_stats =~/\S/
+ %{<hr /><font size="2" color="#666666">Found in the main body of #@counter_txt_doc documents, and at #@counter_txt_ocn locations within.</font><br />}
+ else ''
+ end
else ''
end
@body_main << output #+ details
@@ -849,7 +853,7 @@ module SiSU_CGI_sql
#metadata_found_endnotes
if @text_search_flag
if e['metadata_tid'].to_i != oldtid.to_i
- title=%{<br /><hr><span style="background-color: #@color_heading"><a href="#@hosturl_files/#@stub/#{location}/toc#{lang}.html">#{e['title']}</a></span> by #{e['creator']} <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}/sisu_manifest#{lang}.html"><img border="0" width="12" height="12" src="#@image_src/bullet_red.png" alt="manifest"><font size="2">&nbsp;?</font></a><br />} if file_suffix=~/s/
+ title=%{<br /><hr><span style="background-color: #@color_heading"><a href="#@hosturl_files/#@stub/#{location}/toc#{lang}.html">#{e['title']}</a></span> by #{e['creator']} <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}/sisu_manifest#{lang}.html"><img border="0" width="12" height="12" 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 = ''
@@ -858,7 +862,7 @@ module SiSU_CGI_sql
@counter_endn_ocn+=1
matched_endnote=if (@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/)
matched=if e['body'] =~/<a href="https?:\/\//mi; e['body']
- else e['body'].gsub(/(#@search_regx)/,%{<span style="background-color: #@color_match">\\1</span>})
+ else e['body'].gsub(/(#@search_regx)/i,%{<span style="background-color: #@color_match">\\1</span>})
#e['body']
end
matched
@@ -870,7 +874,10 @@ module SiSU_CGI_sql
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
- %{<font size="2" color="#666666">Found in the endnotes of #@counter_endn_doc documents, and at #@counter_endn_ocn locations within.</font><br />}
+ if checked_stats =~/\S/
+ %{<font size="2" color="#666666">Found in the endnotes of #@counter_endn_doc documents, and at #@counter_endn_ocn locations within.</font><br />}
+ else ''
+ end
end
@endnotes << output #+ details
else @endnotes=[] #does not take out yet
@@ -896,32 +903,3 @@ module SiSU_CGI_sql
end
end
__END__
-#@counter_txt_ocn
-#@counter_endn_ocn
-
-
- if cgi['checks'] =~/check_all/ or cgi['check_all'] =~/\S/ or cgi['a'].to_i==1
- checked_all=checked_url=checked_searched=checked_tip=checked_echo=checked_sql='checked'
- checked_none=''
- #elsif cgi['checks'] =~/check_fixed/ or cgi['check_fixed'] =~/\S/
- # #checked_ignore='checked'
- # checked_fixed='checked'
- # checked_url='checked'
- # checked_searched='checked'
- # checked_echo='checked'
- # #checked_tip='checked'
- # #checked_sql='checked'
- # checked_tip=checked_sql=checked_none=''
- #elsif cgi['checks'] =~/check_ignore/ or cgi['check_ignore'] =~/\S/
- # checked_ignore='checked'
- # checked_url='checked' if cgi['url'] =~/\S/ or cgi['u'].to_i==1
- # checked_searched='checked' if cgi['searched'] =~/\S/
- # checked_tip='checked' if cgi['tip'] =~/\S/
- # checked_echo='checked' if cgi['echo'] =~/\S/
- # checked_sql='checked' if cgi['sql'] =~/\S/
- # checked_none=''
- elsif cgi['checks'] =~/check_none/ or cgi['a'].to_i==0
- checked_none='checked'
- checked_all=checked_url=checked_searched=checked_tip=checked_echo=checked_sql=''
- else checked_ignore='checked'
- end