aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/cgi_sql_common.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2007-07-07 09:21:47 +0100
committerRalph Amissah <ralph@amissah.com>2007-07-07 09:21:47 +0100
commit52f8b9c0b1e1606a4260ef2e0df4d525497691b1 (patch)
treecfb189e2c1dce1af31fc4eb9c414b3bbc6128202 /lib/sisu/v0/cgi_sql_common.rb
parent0.55.1 sync (diff)
cgi-sample search form; texinfo fix; xml scaffold; help, man pages etc. visited; screen output, color set to true; docbook entries removed
* cgi generated sample search form * order results on files of the same title, in multiple files (with different filenames) * postgresql, character case sensitivity, control, on/off * tail decoration, gplv3 & sisu info * texinfo/info (pinfo) module starts to do something vaguely useful again [not a much used module, testing required] * print XML rendition of document structure to screen -T * sisurc.yml default, color set to true [apologies if this causes anyone any inconvenience, it is configurable in sisurc.yml] * help, man pages, README (man(8) related and env, 'sisu -V') * docbook entries removed for the present time * sisu-install (install ruby rant script renamed) and permissions set to executable
Diffstat (limited to 'lib/sisu/v0/cgi_sql_common.rb')
-rw-r--r--lib/sisu/v0/cgi_sql_common.rb196
1 files changed, 141 insertions, 55 deletions
diff --git a/lib/sisu/v0/cgi_sql_common.rb b/lib/sisu/v0/cgi_sql_common.rb
index 6045bf10..37ca67b8 100644
--- a/lib/sisu/v0/cgi_sql_common.rb
+++ b/lib/sisu/v0/cgi_sql_common.rb
@@ -131,11 +131,11 @@ 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_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_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,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_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_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_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,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>'
else ''
@@ -205,8 +205,13 @@ module SiSU_CGI_sql
#@tip
#@search_note
#@the_can
- </td></tr></table><table><tr><td>
- <font size="2" color="#222222">
+ </td></tr></table>
+ <table><tr><td>
+ WOK_SQL
+ end
+ def buttons3
+ <<-'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
@@ -319,106 +324,109 @@ module SiSU_CGI_sql
<<-'WOK_SQL'
class Dbi_search_statement
attr_reader :text_search_flag,:sql_select_body_format,:sql_select_endnotes_format,:sql_offset,:sql_limit
- def initialize(conn,search_for,q)
+ def initialize(conn,search_for,q,c)
@conn=conn
@text_search_flag=false
@sql_statement={ :body=>'',:endnotes=>'',:range=>'' }
#@offset||=@@offset
#@offset+=@@limit
search={ :text => [],:endnotes => [] }
- st=Dbi_search_string.new('documents.clean',search_for.text1,q['s1']).string
- se=Dbi_search_string.new('endnotes.clean',search_for.text1,q['s1']).string
+ cse=if c =~/\S/; true
+ else false
+ end
+ st=Dbi_search_string.new('documents.clean',search_for.text1,q['s1'],cse).string
+ se=Dbi_search_string.new('endnotes.clean',search_for.text1,q['s1'],cse).string
@text_search_flag=st[:flag]
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << se[:search]
end
- st=Dbi_search_string.new('metadata.keywords',search_for.keywords,q['key']).string
+ st=Dbi_search_string.new('metadata.keywords',search_for.keywords,q['key'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.title',search_for.title,q['ti']).string
+ st=Dbi_search_string.new('metadata.title',search_for.title,q['ti'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.creator',search_for.author,q['au']).string
+ st=Dbi_search_string.new('metadata.creator',search_for.author,q['au'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.subject',search_for.subject,q['sj']).string
+ st=Dbi_search_string.new('metadata.subject',search_for.subject,q['sj'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.description',search_for.description,q['dsc']).string
+ st=Dbi_search_string.new('metadata.description',search_for.description,q['dsc'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.publisher',search_for.publisher,q['pb']).string
+ st=Dbi_search_string.new('metadata.publisher',search_for.publisher,q['pb'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.contributor',search_for.contributor,q['cntr']).string
+ st=Dbi_search_string.new('metadata.contributor',search_for.contributor,q['cntr'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.date',search_for.date,q['dt']).string
+ st=Dbi_search_string.new('metadata.date',search_for.date,q['dt'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.type',search_for.type,q['ty']).string
+ st=Dbi_search_string.new('metadata.type',search_for.type,q['ty'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.identifier',search_for.identifier,q['id']).string
+ st=Dbi_search_string.new('metadata.identifier',search_for.identifier,q['id'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.source',search_for.source,q['src']).string
+ st=Dbi_search_string.new('metadata.source',search_for.source,q['src'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.language',search_for.language,q['lang']).string
+ st=Dbi_search_string.new('metadata.language',search_for.language,q['lang'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.relation',search_for.relation,q['rel']).string
+ st=Dbi_search_string.new('metadata.relation',search_for.relation,q['rel'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.coverage',search_for.coverage,q['cov']).string
+ st=Dbi_search_string.new('metadata.coverage',search_for.coverage,q['cov'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.rights',search_for.rights,q['cr']).string
+ st=Dbi_search_string.new('metadata.rights',search_for.rights,q['cr'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.comment',search_for.comment,q['co']).string
+ st=Dbi_search_string.new('metadata.comment',search_for.comment,q['co'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.abstract',search_for.abstract,q['ab']).string
+ st=Dbi_search_string.new('metadata.abstract',search_for.abstract,q['ab'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
end
- st=Dbi_search_string.new('metadata.filename',search_for.filename,q['fns']).string
+ st=Dbi_search_string.new('metadata.filename',search_for.filename,q['fns'],cse).string
if st[:flag]
search[:text] << st[:search]
search[:endnotes] << st[:search]
@@ -479,32 +487,99 @@ module SiSU_CGI_sql
WOK_SQL
end
def tail
+ v=SiSU_Env::Info_version.new.get_version
<<-WOK_SQL
def tail
<<-'WOK'
<br /><hr /><br />
- <center><table align="center"bgcolor="#ffffff"><tr><td><font color="#666666"><table summary="" bgcolor="#ffffff" cellpadding="4" border="0" align="center">
-
- <tr align="center">
- <td align="center"><p class="center"><font color="#666666" size="2">
- presentations' look and feel<br />
- generated by<br />
- <a href="http://www.jus.uio.no/sisu" ><img border="0" src="#@image_src/sisu.png" alt="SiSU in Ruby with the usual GPL (or OSS) suspects - Way Better!" width="120" height="38"></a><br />
- <a href="http://www.jus.uio.no/sisu" >SiSU</a><br />
- version 0.50<br />2007w11/1 (2007-03-12)<br />
-
- <table summary="SiSU rights" bgcolor="#ffffff" cellpadding="4" border="0" align="center" width="40%">
- <sup>&copy;</sup> Ralph Amissah<br />
- 1993, current 2007<br />
- GPL 3<br />
- <i>w3 since October 3 1993</i><br />
- <a href="mailto://ralph@amissah.com" >ralph@amissah.com</a><br />
- </font></p>
- </td></tr></table>
-
- <p><center><font color="#666666" size="2">the usual GPL (or OSS) suspects:<br />Better - "performance, reliability, scalability, security<br />& total cost of ownership"<br /><i>[not to mention flexibility &amp; choice]</i><br /><br />&lt;&lt;<a href="http://www.jus.uio.no/sisu/">Way Better!</a>&gt;&gt;</font></center></p><tr align="center"><td align="center">
-
- </font></center></td></tr></table></center> <a name="bottom" id="bottom"></a><a name="down" id="down"></a><a name="end" id="end"></a><a name="finish" id="finish"></a><a name="stop" id="stop"></a><a name="credits" id="credits"></a>
+<table summary="SiSU summary" bgcolor="#ffffff" cellpadding="4" border="0">
+<tr><td>
+ <!-- widget way better -->
+<tr><td valign="top" width="10%">
+ <p class="tiny_left"><font color="#666666" size="2">
+
+ <a href="http://www.gnu.org/licenses/gpl.html">
+ <img border="0" src="#@image_src/gplv3_free_software.png" alt="GPLv3" width="127" height="51" />
+ </a>
+ </font></p>
+</td><td valign="top" width="45%">
+ <p class="tiny_left"><font color="#666666" size="2">
+ <b>SiSU</b> <sup>&copy;</sup> Ralph Amissah
+ 1993, current 2007
+ All Rights Reserved.
+ <br />
+ <b>SiSU is released under
+ <a href="http://www.gnu.org/licenses/gpl.html">GPL v3</a>
+ or later</b>
+ <a href="http://www.gnu.org/licenses/gpl.html">
+ http://www.gnu.org/licenses/gpl.html
+ </a>
+ </font></p>
+</td><td valign="top" width="45%">
+ <p class="tiny_left"><font color="#666666" size="2">
+ Developed using
+ <a href="http://www.ruby-lang.org/en/">
+ Ruby
+ </a>
+ on
+ <a href="http://www.debian.org/">
+ Debian/Gnu/Linux
+ </a>
+ software infrastructure,
+ &amp; with the usual GPL (or OSS) suspects.
+ <br />
+ Better - "performance, reliability, scalability, security &amp; total cost of ownership"
+ [not to mention flexibility &amp; choice]
+ <br />
+ Get With the Future
+ <a href="http://www.jus.uio.no/sisu/">
+ Way Better!
+ </a>
+ </font></p>
+</td></tr>
+ <!-- widget sisu -->
+<tr><td valign="top" width="10%">
+ <p class="tiny_left"><font color="#666666" size="2">
+ <a href="http://www.jus.uio.no/sisu" >
+ <img border="0" src="#@image_src/sisu.png" alt="SiSU" width="120" height="39" />
+ </a>
+ </font></p>
+</td><td valign="top" width="45%">
+<!-- SiSU Rights -->
+ <p class="tiny_left"><font color="#666666" size="2">
+ Generated by
+ <a href="http://www.jus.uio.no/sisu" >
+ SiSU
+ </a>
+ #{v[:project]} #{v[:version]} #{v[:date]} (#{v[:date_stamp]})
+ <br />
+ <a href="http://www.jus.uio.no/sisu" >
+ www.jus.uio.no/sisu
+ </a>
+ and
+ <a href="http://www.sisudoc.org" >
+ www.sisudoc.org
+ </a>
+ <br />
+ <br />
+ <i>w3 since October 3 1993</i>
+ <a href="mailto://ralph@amissah.com" >
+ ralph@amissah.com
+ </a>
+ </font></p>
+</td><td valign="top" width="45%">
+ <p class="tiny_left"><font color="#666666" size="2">
+ Using:
+ <br />Standard SiSU markup syntax,
+ <br />Standard SiSU meta-markup syntax, and the
+ <br />Standard SiSU <u>object citation numbering</u> and system, (object/text positioning system)
+ <br />
+ <sup>&copy;</sup> Ralph Amissah 1997, current 2007.
+ All Rights Reserved.
+ </font></p>
+</td></tr>
+</table>
+ <a name="bottom" id="bottom"></a><a name="down" id="down"></a><a name="end" id="end"></a><a name="finish" id="finish"></a><a name="stop" id="stop"></a><a name="credits" id="credits"></a>
</body></html>
WOK
end
@@ -526,13 +601,14 @@ module SiSU_CGI_sql
@stub='sisu'
'SiSU_sisu'
end
- checked_url,checked_searched,checked_tip,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,selected_db='','','','','','','',''
+ checked_url,checked_searched,checked_tip,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,selected_db='','','','','','','','',''
if cgi['view']=~/text/; checked_index,checked_text='','checked'
else checked_index,checked_text='checked',''
end
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
@@ -580,8 +656,13 @@ module SiSU_CGI_sql
"#@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"
end
- @search[:text][1]=%{documents.clean~'#{@search_for.text1}'} #s1
- @search[:endnotes][1]=%{endnotes.clean~'#{@search_for.text1}'} #s1
+ if checked_case=~/\S/
+ @search[:text][1]=%{documents.clean~'#{@search_for.text1}'} #s1
+ @search[:endnotes][1]=%{endnotes.clean~'#{@search_for.text1}'} #s1
+ else
+ @search[:text][1]=%{documents.clean~*'#{@search_for.text1}'} #s1
+ @search[:endnotes][1]=%{endnotes.clean~*'#{@search_for.text1}'} #s1
+ end
canned_note='previous search url:'
else
@@canned_search_url="#@base?s1=United+Nations&db=documents&view=index"
@@ -635,7 +716,7 @@ module SiSU_CGI_sql
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_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_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,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)
@@ -644,10 +725,15 @@ module SiSU_CGI_sql
@search_for.text1
else 'Unavailable'
end
- @search[:text]<<%{documents.clean~'#{CGI.unescape(s1)}'}
- @search[:endnotes]<<%{endnotes.clean~'#{CGI.unescape(s1)}'}
+ 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)
+ 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
@@ -710,7 +796,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)/,%{<span style="background-color: #@color_match">\\1</span>}))
end
matched
else c['body']