From 5b647bdb5c8b3f1144911b08aa9c461f57f71ef5 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 19 Apr 2011 21:26:30 -0400 Subject: v2 v3: cgi, sample-search-form * results still not right, (ruby1.9.2 libraries? double check script) * not yet done variable directory path fixing for result links --- data/doc/sisu/CHANGELOG_v2 | 4 ++++ data/doc/sisu/CHANGELOG_v3 | 4 ++++ lib/sisu/v2/cgi_pgsql.rb | 8 ++++---- lib/sisu/v2/cgi_sqlite.rb | 10 +++++----- lib/sisu/v3/cgi_pgsql.rb | 10 +++++----- lib/sisu/v3/cgi_sql_common.rb | 20 ++++++++++---------- lib/sisu/v3/cgi_sqlite.rb | 12 ++++++------ 7 files changed, 38 insertions(+), 30 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v2 b/data/doc/sisu/CHANGELOG_v2 index e1ad8af5..2426158a 100644 --- a/data/doc/sisu/CHANGELOG_v2 +++ b/data/doc/sisu/CHANGELOG_v2 @@ -15,6 +15,10 @@ Reverse Chronological: %% 2.9.2.orig.tar.gz (2011-04-19:16/2) [see 3.0.7] http://git.sisudoc.org/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/3.0.7-1 + * cgi, sample-search-form + * results still not right, (ruby1.9.2 libraries? double check script) + * not yet done variable directory path fixing for result links + * vim colors colorscheme Slate reviewed, cterm 8 colors, & frugal added * Slate, review conflicting group colors * 8, cterm colors to work with diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 39ad8855..feb9a6cb 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -22,6 +22,10 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.0.7.orig.tar.gz * urls, share/reuse code, fix show all urls -U + * cgi, sample-search-form + * results still not right, (ruby1.9.2 libraries? double check script) + * not yet done variable directory path fixing for result links + * vim colors colorscheme Slate reviewed, cterm 8 colors, & frugal added * Slate, review conflicting group colors * 8, cterm colors to work with diff --git a/lib/sisu/v2/cgi_pgsql.rb b/lib/sisu/v2/cgi_pgsql.rb index 416a7d88..2cac69f6 100644 --- a/lib/sisu/v2/cgi_pgsql.rb +++ b/lib/sisu/v2/cgi_pgsql.rb @@ -172,11 +172,11 @@ module SiSU_CGI_pgsql def search_query1 <<-'WOK_SQL' @search_text,@search_endnotes=[],[] - search[:text].each{|x| @search_text << "#{x} AND " } - @search_text=@search_text.join.gsub!(/AND\s+$/,'') #watch + search[:text].flatten.each {|x| @search_text << "#{x} AND " } + @search_text=@search_text.join.gsub!(/AND\s+$/m,'') #watch @search_text.gsub!(/(doc_objects\.clean~[*]?\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean~[*]?\(\s*'[^']+'\s*\))+)/,'(\1)') - search[:endnotes].each{|x| @search_endnotes << "#{x} AND " } - @search_endnotes=@search_endnotes.join.gsub!(/AND\s+$/,'') #watch + search[:endnotes].flatten.each{|x| @search_endnotes << "#{x} AND " } + @search_endnotes=@search_endnotes.join.gsub!(/AND\s+$/m,'') #watch @search_endnotes.gsub!(/(endnotes\.clean~\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean~\(\s*'[^']+'\s*\))+)/,'(\1)') end WOK_SQL diff --git a/lib/sisu/v2/cgi_sqlite.rb b/lib/sisu/v2/cgi_sqlite.rb index d7e131d3..8ef65015 100644 --- a/lib/sisu/v2/cgi_sqlite.rb +++ b/lib/sisu/v2/cgi_sqlite.rb @@ -163,12 +163,12 @@ module SiSU_CGI_sqlite def search_query1 <<-'WOK_SQL' @search_text,@search_endnotes=[],[] - search[:text].each{|x| @search_text << "#{x} AND " } - @search_text=@search_text.join.gsub!(/AND\s+$/,'') + search[:text].flatten.each{|x| @search_text << "#{x} AND " } + @search_text=@search_text.join.gsub!(/AND\s+$/m,'') @search_text.gsub!(/(doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') - search[:endnotes].each{|x| @search_endnotes << "#{x} AND " } - @search_endnotes=@search_endnotes.join.gsub!(/AND\s+$/,'') - @search_text.gsub!(/(endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') + search[:endnotes].flatten.each{|x| @search_endnotes << "#{x} AND " } + @search_endnotes=@search_endnotes.join.gsub!(/AND\s+$/m,'') + @search_endnotes.gsub!(/(endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') end WOK_SQL end diff --git a/lib/sisu/v3/cgi_pgsql.rb b/lib/sisu/v3/cgi_pgsql.rb index 3821f402..48211068 100644 --- a/lib/sisu/v3/cgi_pgsql.rb +++ b/lib/sisu/v3/cgi_pgsql.rb @@ -171,12 +171,12 @@ module SiSU_CGI_pgsql end def search_query1 <<-'WOK_SQL' - @search_text,@search_endnotes=[],[] - search[:text].each {|x| @search_text << "#{x} AND " } - @search_text=@search_text.join.gsub!(/AND\s+$/,'') #watch + @search_text,@search_endnotes='','' + search[:text].flatten.each {|x| @search_text << "#{x} AND " } + @search_text=@search_text.gsub!(/AND\s+$/m,'') #watch @search_text.gsub!(/(doc_objects\.clean~[*]?\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean~[*]?\(\s*'[^']+'\s*\))+)/,'(\1)') - search[:endnotes].each {|x| @search_endnotes << "#{x} AND " } - @search_endnotes=@search_endnotes.join.gsub!(/AND\s+$/,'') #watch + search[:endnotes].flatten.each {|x| @search_endnotes << "#{x} AND " } + @search_endnotes=@search_endnotes.gsub!(/AND\s+$/m,'') #watch @search_endnotes.gsub!(/(endnotes\.clean~\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean~\(\s*'[^']+'\s*\))+)/,'(\1)') end WOK_SQL diff --git a/lib/sisu/v3/cgi_sql_common.rb b/lib/sisu/v3/cgi_sql_common.rb index 0ca9dca2..924b1533 100644 --- a/lib/sisu/v3/cgi_sql_common.rb +++ b/lib/sisu/v3/cgi_sql_common.rb @@ -299,9 +299,9 @@ module SiSU_CGI_sql end def text_to_match(identifier='') m={ - :string => /#{identifier}\s*(.+?)/, - :string => /#{identifier}\s*(.+?)(?:;|\n|\r|$)/, - :word => /#{identifier}[\s(]*(\S+)/ + string: /#{identifier}\s*(.+?)/, + string: /#{identifier}\s*(.+?)(?:;|\n|\r|$)/, + word: /#{identifier}[\s(]*(\S+)/ } search_string=if @search_field =~m[:word] search_string=if @search_field =~m[:braces]; m[:braces].match(@search_field)[1] @@ -328,10 +328,10 @@ module SiSU_CGI_sql def initialize(conn,search_for,q,c) @conn=conn @text_search_flag=false - @sql_statement={ :body=>'',:endnotes=>'',:range=>'' } + @sql_statement={ body: '', endnotes: '',range: '' } #@offset||=@@offset #@offset+=@@limit - search={ :text => [],:endnotes => [] } + search={ text: [], endnotes: [] } cse=(c =~/\S/) ? true : false st=Dbi_search_string.new('doc_objects.clean',search_for.text1,q['s1'],cse).string se=Dbi_search_string.new('endnotes.clean',search_for.text1,q['s1'],cse).string @@ -645,7 +645,7 @@ module SiSU_CGI_sql @counters_txt,@counters_endn,@sql_select_body,@sql_select_endnotes='','','','' FCGI.each_cgi do |cgi| begin # all code goes in begin section - @search={ :text => [],:endnotes => [] } + @search={ text: [], endnotes: [] } q=CGI.new @db=if cgi['db'] =~/\S+/; @stub=/#{@db_name_prefix}(\S+)/.match(cgi['db'])[1] @@ -656,13 +656,13 @@ module SiSU_CGI_sql end checked_url,checked_stats,checked_searched,checked_tip,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,selected_db='','','','','','','','','' result_type=(cgi['view']=~/text/) \ - ? result_type={:index=>'',:text=>'checked'} \ - : result_type={:index=>'checked',:text=>''} + ? result_type={ index: '', text: 'checked'} \ + : result_type={ index: 'checked', text: ''} @@limit=if cgi['sql_match_limit'].to_s=~/2500/ - checked_sql_limit={:l1000=>'',:l2500=>'checked'} + checked_sql_limit={ l1000: '', l2500: 'checked'} '2500' else - checked_sql_limit={:l1000=>'checked',:l2500=>''} + checked_sql_limit={ l1000: 'checked', l2500: ''} '1000' end checked_echo='checked' if cgi['echo'] =~/\S/ diff --git a/lib/sisu/v3/cgi_sqlite.rb b/lib/sisu/v3/cgi_sqlite.rb index 7251c81a..5a415b0d 100644 --- a/lib/sisu/v3/cgi_sqlite.rb +++ b/lib/sisu/v3/cgi_sqlite.rb @@ -162,13 +162,13 @@ module SiSU_CGI_sqlite end def search_query1 <<-'WOK_SQL' - @search_text,@search_endnotes=[],[] - search[:text].each {|x| @search_text << "#{x} AND " } - @search_text=@search_text.join.gsub!(/AND\s+$/,'') + @search_text,@search_endnotes='','' + search[:text].flatten.each {|x| @search_text << "#{x} AND " } + @search_text=@search_text.gsub!(/AND\s+$/m,'') @search_text.gsub!(/(doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') - search[:endnotes].each {|x| @search_endnotes << "#{x} AND " } - @search_endnotes=@search_endnotes.join.gsub!(/AND\s+$/,'') - @search_text.gsub!(/(endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') + search[:endnotes].flatten.each {|x| @search_endnotes << "#{x} AND " } + @search_endnotes=@search_endnotes.gsub!(/AND\s+$/m,'') + @search_endnotes.gsub!(/(endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') end WOK_SQL end -- cgit v1.2.3