aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2012-10-01 16:39:32 -0400
committerRalph Amissah <ralph@amissah.com>2012-10-01 16:39:32 -0400
commit610573c495420ebf3661e9e1829405179d8e6aa3 (patch)
tree27edb7591eced09f4b373acef68c20033bb9bfea
parentv3: db, book_idx field & minor re-arrangement (diff)
v3: cgi search script, minor
-rw-r--r--data/doc/sisu/CHANGELOG_v32
-rw-r--r--lib/sisu/v3/cgi_pgsql.rb12
-rw-r--r--lib/sisu/v3/cgi_sql_common.rb22
-rw-r--r--lib/sisu/v3/cgi_sqlite.rb12
4 files changed, 23 insertions, 25 deletions
diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3
index 5168fdc7..ad0e7d08 100644
--- a/data/doc/sisu/CHANGELOG_v3
+++ b/data/doc/sisu/CHANGELOG_v3
@@ -86,6 +86,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.3.3.orig.tar.xz
* introduce book_idx
* minor re-arranging
+* v3: cgi search script, minor
+
* v3: vim syntax sisu.vim, =\\= page new & -\\- page break
* v3: vim ftplugin sisu.vim
diff --git a/lib/sisu/v3/cgi_pgsql.rb b/lib/sisu/v3/cgi_pgsql.rb
index 83a1cecf..1264d922 100644
--- a/lib/sisu/v3/cgi_pgsql.rb
+++ b/lib/sisu/v3/cgi_pgsql.rb
@@ -144,7 +144,7 @@ module SiSU_CGI_PgSQL
@l,@t,@q,@c=l,t,q,cse
end
def string
- search={ :search => [], :flag => false }
+ search={ search: [], flag: false }
if @t =~/\S+/ or @q =~/\S+/
if @t =~/\S+/ then unescaped_search=CGI.unescape(@t)
elsif @q =~/\S+/ then unescaped_search=CGI.unescape(@q)
@@ -171,12 +171,10 @@ module SiSU_CGI_PgSQL
def search_query1
<<-'WOK_SQL'
@search_text,@search_endnotes='',''
- search[:text].flatten.each {|x| @search_text << "#{x} AND " }
- @search_text=@search_text.gsub(/AND\s+$/m,''). #watch
- gsub(/(doc_objects\.clean~[*]?\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean~[*]?\(\s*'[^']+'\s*\))+)/,'(\1)')
- search[:endnotes].flatten.each {|x| @search_endnotes << "#{x} AND " }
- @search_endnotes=@search_endnotes.gsub(/AND\s+$/m,''). #watch
- gsub(/(endnotes\.clean~\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean~\(\s*'[^']+'\s*\))+)/,'(\1)')
+ @search_text=search[:text].flatten.join(' AND ')
+ @search_text=@search_text.gsub(/(doc_objects\.clean~[*]?\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean~[*]?\(\s*'[^']+'\s*\))+)/,'(\1)')
+ @search_endnotes=search[:endnotes].flatten.join(' AND ')
+ @search_endnotes=@search_endnotes.gsub(/(endnotes\.clean~\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean~\(\s*'[^']+'\s*\))+)/,'(\1)')
end
WOK_SQL
end
diff --git a/lib/sisu/v3/cgi_sql_common.rb b/lib/sisu/v3/cgi_sql_common.rb
index 94026ce7..18e1ab1e 100644
--- a/lib/sisu/v3/cgi_sql_common.rb
+++ b/lib/sisu/v3/cgi_sql_common.rb
@@ -301,9 +301,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] then m[:braces].match(@search_field)[1]
@@ -313,7 +313,7 @@ module SiSU_CGI_SQL
str=str.gsub(/[()]/,'')
str
end
- search_string=search_string.strip.search_string.gsub(/\s+/,'+')
+ search_string=search_string.strip.gsub(/\s+/,'+')
#else
# "__"
end
@@ -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_SearchString.new('doc_objects.clean',search_for.text1,q['s1'],cse).string
se=DBI_SearchString.new('endnotes.clean',search_for.text1,q['s1'],cse).string
@@ -650,7 +650,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]
@@ -661,13 +661,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 a9f9d277..78ae0f9a 100644
--- a/lib/sisu/v3/cgi_sqlite.rb
+++ b/lib/sisu/v3/cgi_sqlite.rb
@@ -141,7 +141,7 @@ module SiSU_CGI_SQLite
@l,@t,@q=l,t,q
end
def string
- search={ :search => [], :flag => false }
+ search={ search: [], flag: false }
if @t =~/\S+/ or @q =~/\S+/
if @t =~/\S+/ then unescaped_search=CGI.unescape(@t)
elsif @q =~/\S+/ then unescaped_search=CGI.unescape(@q)
@@ -163,12 +163,10 @@ module SiSU_CGI_SQLite
def search_query1
<<-'WOK_SQL'
@search_text,@search_endnotes='',''
- search[:text].flatten.each {|x| @search_text << "#{x} AND " }
- @search_text=@search_text.gsub(/AND\s+$/m,'').
- gsub(/(doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)')
- search[:endnotes].flatten.each {|x| @search_endnotes << "#{x} AND " }
- @search_endnotes=@search_endnotes.gsub(/AND\s+$/m,'').
- gsub(/(endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+endnotes\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)')
+ @search_text=search[:text].flatten.join(' AND ')
+ @search_text=@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=search[:endnotes].flatten.join(' AND ')
+ @search_endnotes=@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