diff options
| author | Ralph Amissah <ralph@amissah.com> | 2009-12-19 16:51:14 -0500 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2009-12-19 16:51:14 -0500 | 
| commit | cbd35cfd8366f2fc9e854d2fca5654467974a547 (patch) | |
| tree | 77f13e8d253c02fd759d324c30982b1ea673f5b7 | |
| parent | manpage, fix (diff) | |
cgi_sql_common, minor style related, (mostly enclosing of used variables in curly braces)
| -rw-r--r-- | lib/sisu/v1/cgi_sql_common.rb | 93 | 
1 files changed, 47 insertions, 46 deletions
| diff --git a/lib/sisu/v1/cgi_sql_common.rb b/lib/sisu/v1/cgi_sql_common.rb index bd0b38a5..5138e311 100644 --- a/lib/sisu/v1/cgi_sql_common.rb +++ b/lib/sisu/v1/cgi_sql_common.rb @@ -129,7 +129,7 @@ module SiSU_CGI_sql        <<-'WOK_SQL'  #Common TOP        @@limit,@@offset=1000,0 -      @base="#@hosturl_db/cgi-bin/#@version.cgi" +      @base="#{@hosturl_db}/cgi-bin/#{@version}.cgi"        @@canned_search_url=@base        @color_heading='#DDFFAA'        @color_match='#ffff48' @@ -160,12 +160,12 @@ module SiSU_CGI_sql      <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />      <meta name="sourcefile" content="SiSU._sst" />      <link rel="generator" href="http://www.jus.uio.no/sisu" /> -    <link rel="shortcut icon" href="#@image_src/rb7.ico" /> +    <link rel="shortcut icon" href="#{@image_src}/rb7.ico" />      <link rel="stylesheet" href="../_sisu/css/html.css" type="text/css" />      </head>      <body bgcolor="#ffffff" text="#000000" link="#003090" lang="en" xml:lang="en">      <table summary="band" border="0" cellpadding="3" cellspacing="0"> -    <tr><td align="left" bgcolor="#ffffff"><a href="http://www.jus.uio.no/sisu/" target="_top"><img border="0" src="#@image_src/sisu.png" alt="SiSU -->" /></a></td><td> +    <tr><td align="left" bgcolor="#ffffff"><a href="http://www.jus.uio.no/sisu/" target="_top"><img border="0" src="#{@image_src}/sisu.png" alt="SiSU -->" /></a></td><td>  <!--    <p class="tiny"><a href="http://www.jus.uio.no/sisu/SiSU/"> http://www.jus.uio.no/sisu/SiSU/</a></p> -->        <label for="find"><b>#{@env.sample_search_form_title}</b></label>      </td></tr> @@ -174,49 +174,49 @@ module SiSU_CGI_sql      end      def header2        <<-'WOK_SQL' -    <form action="#@base" id="Test Form" method="post"> +    <form action="#{@base}" id="Test Form" method="post">        <table cellpadding="2">        <tr><td valign=\"top\"> -          <textarea id="find" name="find" type="text" rows="6" cols="40" 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 -        #@search_note -        #@the_can +        #{@tip} +        #{@search_note} +        #{@the_can}        </td></tr></table>        <td valign=\"top\"><tr><td> -        <!input type="text" id="find" name="find" value="#@search_field" /> +        <!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 +          #{@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 +        <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 buttons2        <<-'WOK_SQL'          <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 +          <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 +          <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> @@ -285,8 +285,9 @@ module SiSU_CGI_sql              @date_modified=q['dtm'] if q['dtm']=~/\S/              @date_available=q['dta'] if q['dta']=~/\S/              @date_valid=q['dtv'] if q['dtv']=~/\S/ -            @filename=q['fns'] if q['fns']=~/\S/ -            @filename=q['doc'] if q['search'] !~/search db/ +            @filename=if q['doc'] and q['search'] !~/search db/; q['doc'] +            elsif q['fns']=~/\S/; q['fns']ยท +            end               @@limit=q['ltd'] if q['ltd']=~/\d+/  # 1000              @@offset=q['off'] if q['off']=~/\d+/ # 0            end @@ -525,7 +526,7 @@ module SiSU_CGI_sql  <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" /> +      <img border="0" src="#{@image_src}/sisu.png" alt="SiSU" width="120" height="39" />      </a>    </font></p>  </td><td valign="top" width="45%"> @@ -572,7 +573,7 @@ module SiSU_CGI_sql  <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" /> +      <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%"> @@ -692,10 +693,10 @@ module SiSU_CGI_sql              dtv='&dtv=' + CGI.escape(@search_for.date_valid) if @search_for.date_valid=~/\S/              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']}" +              "#{@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']}" +            @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 @@ -705,7 +706,7 @@ module SiSU_CGI_sql              end              canned_note='search url:'            else -            @@canned_search_url="#@base?db=#{@db}&view=index" +            @@canned_search_url="#{@base}?db=#{@db}&view=index"              canned_note='search url example:'            end            if search_field =~/\S+/ @@ -748,7 +749,7 @@ 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"> -      <b>database:</b> #{green}#@db</font>; <b>selected view:</b> #{green}#{cgi['view']}</font> +      <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> @@ -805,10 +806,10 @@ module SiSU_CGI_sql                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> } +              can_txt_srch=if cgi['view']=~/index/; %{<a href="#{@canned_base_url}&fns=#{c['filename']}&view=text"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a> } +              else %{<a href="#{@canned_base_url}&fns=#{c['filename']}&view=index"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></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"> #{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 +              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 @@ -844,10 +845,10 @@ module SiSU_CGI_sql                    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>}) +                    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 -                  %{<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}} +                  %{<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 @@ -857,9 +858,9 @@ module SiSU_CGI_sql                  end                else #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 +                  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>, } +                  index=%{<a href="#{@hosturl_files}/#{@stub}/#{location}/doc#{lang}.html##{c['ocn']}">#{c['ocn']}</a>, }                  end                  if c['seg'] =~/\S+/                    if @text_search_flag @@ -884,7 +885,7 @@ module SiSU_CGI_sql                    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 />} +                %{<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 '' @@ -908,10 +909,10 @@ module SiSU_CGI_sql                  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> } +                can_txt_srch=if cgi['view']=~/index/; %{<a href="#{@canned_base_url}&fns=#{e['filename']}&view=text"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a> } +                else %{<a href="#{@canned_base_url}&fns=#{e['filename']}&view=index"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></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/ +                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 = '' @@ -920,13 +921,13 @@ module SiSU_CGI_sql                or (cgi['view']!~/index/ and cgi['search'] !~/search db/)      #% 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>}) +                  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}}                else #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>], } +                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/ @@ -937,7 +938,7 @@ module SiSU_CGI_sql                      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 />} +                    %{<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 | 
