From 546ea64f0ab03a52b1eb67cf216c8cc4c39d74c4 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 13 Jul 2007 01:58:26 +0100 Subject: syntax hilighting (gedit), sisu rights and other info in outputs, cgi sample search improvements, see changelog --- lib/sisu/v0/cgi_sql_common.rb | 298 +++++++++++++++++++++++------------------- 1 file changed, 160 insertions(+), 138 deletions(-) (limited to 'lib/sisu/v0/cgi_sql_common.rb') 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
- + #@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$/ - %{

- pg. #{page.to_s} -   > -
} - when /^2$/ - %{

- <   - pg. #{page.to_s} -   > -
} - else - %{

- |<   - <   - pg. #{page.to_s} -   > -
} + 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$/ + %{

+ pg. #{page.to_s} +   > +
} + when /^2$/ + %{

+ <   + pg. #{page.to_s} +   > +
} + else + %{

+ |<   + <   + pg. #{page.to_s} +   > +
} + end + else '' end end WOK_SQL @@ -483,51 +486,7 @@ module SiSU_CGI_sql def tail <<-'WOK'


- - +
- -
-

- - - GPLv3 - -

-
-

- SiSU © Ralph Amissah - 1993, current 2007 - All Rights Reserved. -
- SiSU is released under - GPL v3 - or later - - http://www.gnu.org/licenses/gpl.html - -

-
-

- Developed using - - Ruby - - on - - Debian/Gnu/Linux - - software infrastructure, - & with the usual GPL (or OSS) suspects. -
- Better - "performance, reliability, scalability, security & total cost of ownership" - [not to mention flexibility & choice] -
- Get With the Future - - Way Better! - -

-
+ +

@@ -540,9 +499,16 @@ module SiSU_CGI_sql

Generated by - SiSU - - #{v[:project]} #{v[:version]} #{v[:date]} (#{v[:date_stamp]}) + #{v[:project]} #{v[:version]} #{v[:date]} (#{v[:date_stamp]}) +
+ + #{v[:project]} © Ralph Amissah + 1993, current 2007. + All Rights Reserved. +
+ + #{v[:project]} + is software for document structuring, publishing and search,
www.jus.uio.no/sisu @@ -551,7 +517,6 @@ module SiSU_CGI_sql www.sisudoc.org -

w3 since October 3 1993 @@ -560,7 +525,7 @@ module SiSU_CGI_sql

- Using: + #{v[:project]} using:
Standard SiSU markup syntax,
Standard SiSU meta-markup syntax, and the
Standard SiSU object citation numbering and system, (object/text positioning system) @@ -568,6 +533,44 @@ module SiSU_CGI_sql © Ralph Amissah 1997, current 2007. All Rights Reserved.

+
+

+ + GPLv3 + +

+
+

+ SiSU is released under + GPL v3 + or later, + + http://www.gnu.org/licenses/gpl.html + +

+
+

+ #{v[:project]}, developed using + + Ruby + + on + + Debian/Gnu/Linux + + software infrastructure, + with the usual GPL (or OSS) suspects. +
+ Better - "performance, reliability, scalability, security & total cost of ownership" + [not to mention flexibility & choice] +
+ Get With the Future + + Way Better! + +

@@ -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=%{toc html #{ti} by #{c['creator']} toc htmlpdf portraitpdf landscape odf manifest
} if file_suffix=~/s/ #hmm watch file_suffix - if @text_search_flag; title='

'+title - else title='
'+title - end - @counter_txt_doc+=1 - oldtid=c['tid'].to_i - else title='' + can_txt_srch=if cgi['view']=~/index/; %{red bullet } + else %{red bullet } 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=%{toc html #{ti} by #{c['creator']} #{can_txt_srch}toc html pdf portrait pdf landscape odf manifest
} if file_suffix=~/s/ #hmm watch file_suffix + if @text_search_flag; title='

'+title + else title='
'+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'] =~/\\1})) + @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 - %{

ocn #{c['ocn']}:

#{matched_para}} - elsif c['suffix'] =~/1/ #doc - %{#{title}

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=%{#{c['ocn']}, } if @text_search_flag - elsif c['suffix'] =~/1/ #doc - index=%{#{c['ocn']}, } + matched_para=if (@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) + matched=c['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#@search_regx)/mi,%{\\1}) + else c['body'] end - if c['seg'] =~/\S+/ - if @text_search_flag - @counter_txt_ocn+=1 - output=title+index - end - else + %{


ocn #{c['ocn']}:

#{matched_para}} + elsif c['suffix'] =~/1/ #doc + %{#{title}

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=%{#{c['ocn']}, } if @text_search_flag + elsif c['suffix'] =~/1/ #doc + index=%{#{c['ocn']}, } + 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/ - %{


Found in the main body of #@counter_txt_doc documents, and at #@counter_txt_ocn locations within.
} + @@lt_t=if @counter_txt_ocn == dbi_statement.sql_limit.to_i + over='over' + true + else + over='' + false + end + %{
Found in the main body of #@counter_txt_doc documents, and at #{over} #@counter_txt_ocn locations within.
} 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=%{

toc html #{ti} by #{e['creator']} toc html pdf portraitpdf landscape odf manifest
} if file_suffix=~/s/ + can_txt_srch=if cgi['view']=~/index/; %{red bullet } + else %{red bullet } + end + title=%{

toc html #{ti} by #{e['creator']} #{can_txt_srch}toc html pdf portraitpdf landscape odf manifest
} 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'] =~/\\1}) - #e['body'] - end - matched + matched=e['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#@search_regx)/mi,%{\\1}) else e['body'] end - output=%{#{title}
note
#{e['nr']} referred to from ocn #{e['ocn']}: #{matched_endnote}} + output=%{#{title}
note #{e['nr']} referred to from ocn #{e['ocn']}: #{matched_endnote}} elsif cgi['view']=~/index/ #% idx endnotes @counter_endn_ocn+=1 output=%{#{title}#{e['nr']}#{e['ocn']}], } end @counters_endn=if @counter_endn_doc > 0 if checked_stats =~/\S/ - %{Found in the endnotes of #@counter_endn_doc documents, and at #@counter_endn_ocn locations within.
} + @@lt_e=if @counter_endn_ocn == dbi_statement.sql_limit.to_i + over='over' + true + else + over='' + false + end + %{Found in the endnotes of #@counter_endn_doc documents, and at #{over} #@counter_endn_ocn locations within.
} 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 -- cgit v1.2.3