diff options
Diffstat (limited to 'lib/sisu/v0/cgi_pgsql.rb')
-rw-r--r-- | lib/sisu/v0/cgi_pgsql.rb | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/sisu/v0/cgi_pgsql.rb b/lib/sisu/v0/cgi_pgsql.rb index e5260a5f..0032a927 100644 --- a/lib/sisu/v0/cgi_pgsql.rb +++ b/lib/sisu/v0/cgi_pgsql.rb @@ -92,7 +92,7 @@ module SiSU_CGI_pgsql f2 << " end\n" if FileTest.writable?('.') output=File.open('sisu_pgsql.cgi','w') - output << header0 << header1 << header_desc << header2 << f1 << buttons1 << buttons_note << buttons2 << search_request << search_statement << search_statement_common << search_query1 << @common.pages << search_query2 << @common.tail << @common.main1 << f2 << dbi_connect << @common.main2 + output << header0 << header1 << header_desc << header2 << f1 << buttons1 << buttons2 << buttons2_pgsql << buttons3 << search_request << search_statement << search_statement_common << search_query1 << @common.pages << search_query2 << @common.tail << @common.main1 << f2 << dbi_connect << @common.main2 a=%{ generated sisu_pgsql.cgi, BASED ON ALREADY EXISTING directories that could potentially be used to populate postgresql db, (-D) } @@ -139,8 +139,8 @@ module SiSU_CGI_pgsql def search_statement <<-'WOK_SQL' class Dbi_search_string - def initialize(l,t,q) - @l,@t,@q=l,t,q + def initialize(l,t,q,cse=false) + @l,@t,@q,@c=l,t,q,cse end def string search={ :search => [],:flag => false } @@ -149,8 +149,13 @@ module SiSU_CGI_pgsql elsif @q =~/\S+/; unescaped_search=CGI.unescape(@q) end search_construct=[] - unescaped_search.gsub!(/\s*(AND|OR)\s*/,"' \) \\1 #@l~\( '") - unescaped_search.gsub!(/(.+)/,"#@l~\( '\\1' \)") + if @c + unescaped_search.gsub!(/\s*(AND|OR)\s*/,"' \) \\1 #@l~\( '") + unescaped_search.gsub!(/(.+)/,"#@l~\( '\\1' \)") + else + unescaped_search.gsub!(/\s*(AND|OR)\s*/,"' \) \\1 #@l~*\( '") + unescaped_search.gsub!(/(.+)/,"#@l~*\( '\\1' \)") + end search_construct << unescaped_search search_construct=search_construct.join(' ') search[:search] << search_construct @@ -162,9 +167,6 @@ module SiSU_CGI_pgsql end WOK_SQL end - def buttons_note - ' <font size="2" color="#666666">case sensitive</font>' - end def search_query1 <<-'WOK_SQL' @search_text,@search_endnotes=[],[] @@ -183,7 +185,7 @@ module SiSU_CGI_pgsql def sql_select_body limit ||=@@limit offset ||=@@offset - @sql_statement[:body]=%{SELECT metadata.title, metadata.creator, metadata.filename, metadata.suffix, documents.body, documents.seg, documents.ocn, metadata.tid FROM documents, metadata WHERE (#@search_text) AND documents.metadata_tid = metadata.tid ORDER BY metadata.title, documents.ocn} + @sql_statement[:body]=%{SELECT metadata.title, metadata.creator, metadata.filename, metadata.suffix, documents.body, documents.seg, documents.ocn, metadata.tid FROM documents, metadata WHERE (#@search_text) AND documents.metadata_tid = metadata.tid ORDER BY metadata.title, metadata.filename, documents.ocn} @sql_statement[:range]=%{LIMIT #{limit} OFFSET #{offset} ;} select=@sql_statement[:body] + ' ' + @sql_statement[:range] select @@ -191,7 +193,7 @@ module SiSU_CGI_pgsql def sql_select_endnotes limit ||=@@limit offset ||=@@offset - @sql_statement[:endnotes]=%{SELECT metadata.title, metadata.creator, metadata.filename, endnotes.body, endnotes.nr, endnotes.ocn, endnotes.metadata_tid FROM metadata, endnotes WHERE (#@search_endnotes) AND metadata.tid = endnotes.metadata_tid ORDER BY metadata.title, endnotes.nr} + @sql_statement[:endnotes]=%{SELECT metadata.title, metadata.creator, metadata.filename, endnotes.body, endnotes.nr, endnotes.ocn, endnotes.metadata_tid FROM metadata, endnotes WHERE (#@search_endnotes) AND metadata.tid = endnotes.metadata_tid ORDER BY metadata.title, metadata.filename, endnotes.nr} @sql_statement[:range]=%{LIMIT #{limit} OFFSET #{offset} ;} select=@sql_statement[:endnotes] + ' ' + @sql_statement[:range] select @@ -211,6 +213,12 @@ module SiSU_CGI_pgsql end WOK_SQL end + def buttons2_pgsql + <<-'WOK_SQL' + <font size="2" color="#222222"> + <input type="checkbox" name="casesense" #@checked_case> case sensitive + WOK_SQL + end def dbi_connect <<-'WOK_SQL' dbi="dbi:Pg:database=#{@db};port=#{@port}" |