diff options
author | Ralph Amissah <ralph@amissah.com> | 2007-07-13 01:58:26 +0100 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2007-07-13 01:58:26 +0100 |
commit | 546ea64f0ab03a52b1eb67cf216c8cc4c39d74c4 (patch) | |
tree | 5d1ca60f11cc40a4ba210ddd2a20eb5af078d531 /lib/sisu/v0/cgi_sql_common.rb | |
parent | various fixes: cgi search for, manifest, concordance, diakonos syntax highlgh... (diff) |
syntax hilighting (gedit), sisu rights and other info in outputs, cgi sample search improvements, see changelog
Diffstat (limited to 'lib/sisu/v0/cgi_sql_common.rb')
-rw-r--r-- | lib/sisu/v0/cgi_sql_common.rb | 298 |
1 files changed, 160 insertions, 138 deletions
diff --git a/lib/sisu/v0/cgi_sql_common.rb b/lib/sisu/v0/cgi_sql_common.rb index 762632dc..6239b6bf 100644 --- a/lib/sisu/v0/cgi_sql_common.rb +++ b/lib/sisu/v0/cgi_sql_common.rb @@ -174,7 +174,7 @@ module SiSU_CGI_sql <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> + <textarea id="find" name="find" type="text" rows="6" cols="40" maxlength="256">#@search_field</textarea> </td> <td valign=\"top\"> #@tip @@ -451,28 +451,31 @@ module SiSU_CGI_sql end self end - def sql_canned_search_url - can=sql_canned_search - page=(sql_offset.to_i + sql_limit.to_i)/sql_limit.to_i - case page.to_s - when /^1$/ - %{<hr /><br /><center> - pg. #{page.to_s} - <a href="#{can.next}"> ></a> - </center>} - when /^2$/ - %{<hr /><br /><center> - <a href="#{can.previous}">< </a> - pg. #{page.to_s} - <a href="#{can.next}"> ></a> - </center>} - else - %{<hr /><br /><center> - <a href="#{can.start}">|< </a> - <a href="#{can.previous}">< </a> - pg. #{page.to_s} - <a href="#{can.next}"> ></a> - </center>} + def sql_canned_search_url(ok) + if ok + can=sql_canned_search + page=(sql_offset.to_i + sql_limit.to_i)/sql_limit.to_i + case page.to_s + when /^1$/ + %{<hr /><br /><center> + pg. #{page.to_s} + <a href="#{can.next}"> ></a> + </center>} + when /^2$/ + %{<hr /><br /><center> + <a href="#{can.previous}">< </a> + pg. #{page.to_s} + <a href="#{can.next}"> ></a> + </center>} + else + %{<hr /><br /><center> + <a href="#{can.start}">|< </a> + <a href="#{can.previous}">< </a> + pg. #{page.to_s} + <a href="#{can.next}"> ></a> + </center>} + end + else '' end end WOK_SQL @@ -483,51 +486,7 @@ module SiSU_CGI_sql def tail <<-'WOK' <br /><hr /><br /> -<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>©</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, - & with the usual GPL (or OSS) suspects. - <br /> - Better - "performance, reliability, scalability, security & total cost of ownership" - [not to mention flexibility & choice] - <br /> - Get With the Future - <a href="http://www.jus.uio.no/sisu/"> - Way Better! - </a> - </font></p> -</td></tr> +<table summary="SiSU summary" bgcolor="#ffffff" cellpadding="2" border="0"> <!-- widget sisu --> <tr><td valign="top" width="10%"> <p class="tiny_left"><font color="#666666" size="2"> @@ -540,9 +499,16 @@ module SiSU_CGI_sql <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]}) + #{v[:project]}</a> #{v[:version]} #{v[:date]} (#{v[:date_stamp]}) + <br /> + <a href="http://www.jus.uio.no/sisu" > + <b>#{v[:project]}</b></a> <sup>©</sup> Ralph Amissah + 1993, current 2007. + All Rights Reserved. + <br /> + <a href="http://www.jus.uio.no/sisu" > + #{v[:project]}</a> + is software for document structuring, publishing and search, <br /> <a href="http://www.jus.uio.no/sisu" > www.jus.uio.no/sisu @@ -552,7 +518,6 @@ module SiSU_CGI_sql www.sisudoc.org </a> <br /> - <br /> <i>w3 since October 3 1993</i> <a href="mailto://ralph@amissah.com" > ralph@amissah.com @@ -560,7 +525,7 @@ module SiSU_CGI_sql </font></p> </td><td valign="top" width="45%"> <p class="tiny_left"><font color="#666666" size="2"> - Using: + #{v[:project]} 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) @@ -569,6 +534,44 @@ module SiSU_CGI_sql All Rights Reserved. </font></p> </td></tr> + <!-- 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"> + SiSU is released under + <a href="http://www.gnu.org/licenses/gpl.html">GPL v3</a> + or later, + <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"> + #{v[:project]}, 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, + with the usual GPL (or OSS) suspects. + <br /> + Better - "performance, reliability, scalability, security & total cost of ownership" + [not to mention flexibility & choice] + <br /> + Get With the Future + <a href="http://www.jus.uio.no/sisu/"> + Way Better! + </a> + </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> @@ -658,6 +661,7 @@ 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']}" end + @canned_base_url="#@base?#{s1}&db=#{cgi['db']}" if checked_case=~/\S/ @search[:text][1]=%{documents.clean~'#{@search_for.text1}'} #s1 @search[:endnotes][1]=%{endnotes.clean~'#{@search_for.text1}'} #s1 @@ -767,75 +771,82 @@ module SiSU_CGI_sql ti=if c['subtitle'] =~/\S+/; "#{c['title']} - #{c['subtitle']}" else c['title'] 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"> #{ti}</a></span> by #{c['creator']} <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='' + 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 - 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*/,'|') - search_regex.to_s - else nil - 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"> #{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='' + 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=if c['body'] =~/<a href="https?:\/\//mi; c['body'] - else (c['body'].gsub(/(#@search_regx)/i,%{<span style="background-color: #@color_match">\\1</span>})) + @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 - matched - else c['body'] + 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']}} - end - @counter_txt_ocn+=1 - output=if c['seg'] =~/\S+/; title+text - else text + else nil 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 + else + @counter_txt_ocn+=1 + output=unless c['suffix'] =~/1/; title+index + else %{#{title}#{c['ocn'].sort}, } end end - else output=title end + else output=title + end @counters_txt=if @counter_txt_doc > 0 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 />} + @@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 '' @@ -859,7 +870,10 @@ module SiSU_CGI_sql ti=if e['subtitle'] =~/\S+/; "#{e['title']} - #{e['subtitle']}" else e['title'] 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"> #{ti}</a></span> by #{e['creator']} <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/ + 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"> #{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 = '' @@ -867,21 +881,24 @@ module SiSU_CGI_sql 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=if e['body'] =~/<a href="https?:\/\//mi; e['body'] - else e['body'].gsub(/(#@search_regx)/i,%{<span style="background-color: #@color_match">\\1</span>}) - #e['body'] - end - matched + 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}} + 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> [§ <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/ - %{<font size="2" color="#666666">Found in the endnotes of #@counter_endn_doc documents, and at #@counter_endn_ocn locations within.</font><br />} + @@lt_e=if @counter_endn_ocn == dbi_statement.sql_limit.to_i + over='over' + true + else + over='' + false + end + %{<font size="2" color="#666666">Found in the endnotes of #@counter_endn_doc documents, and at #{over} #@counter_endn_ocn locations within.</font><br />} else '' end end @@ -891,7 +908,12 @@ module SiSU_CGI_sql end offset=dbi_statement.sql_offset.to_s limit=dbi_statement.sql_limit.to_s - canned=dbi_statement.sql_canned_search_url.to_s + @@lt_t ||=false; @@lt_e ||=false + canned=if (@@lt_t or @@lt_e) + dbi_statement.sql_canned_search_url(true).to_s + else + dbi_statement.sql_canned_search_url(false).to_s + end limit=dbi_statement.sql_limit.to_s cgi.out{@header + @counters_txt + @counters_endn + @body_main.join + @endnotes.join + canned + @tail} #% print cgi_output_header+counters+body+endnotes end |