From 0ff37b772594b21a26b4b878a5ddbc6f1e0d1e67 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 13 Oct 2021 13:33:08 -0400 Subject: org files, tangle output, some fixes --- org/util_cgi_rb_fcgi_sqlite_search.org | 916 +++++++++++++++++---------------- 1 file changed, 469 insertions(+), 447 deletions(-) (limited to 'org/util_cgi_rb_fcgi_sqlite_search.org') diff --git a/org/util_cgi_rb_fcgi_sqlite_search.org b/org/util_cgi_rb_fcgi_sqlite_search.org index a11c9dc..7cb16f1 100644 --- a/org/util_cgi_rb_fcgi_sqlite_search.org +++ b/org/util_cgi_rb_fcgi_sqlite_search.org @@ -32,12 +32,36 @@ document home currently at /var/www/html (better placed at /var/www or srv/proje #+END_SRC *** sqlite cgi search TODO -**** head +**** tangle -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+HEADER: :tangle "../sundry/misc/util/rb/cgi/spine.search.cgi" #+HEADER: :tangle-mode (identity #o755) #+HEADER: :shebang #!/usr/bin/env ruby #+BEGIN_SRC ruby +<> +<> +<> + <> +end +<> + <> +end +<> +<> + <> +<> +<> +<> + <> + <> + <> +<> +#+END_SRC + +**** head + +#+NAME: license +#+BEGIN_SRC ruby =begin * Name: SiSU information Structuring Universe * Author: Ralph Amissah @@ -95,7 +119,7 @@ document home currently at /var/www/html (better placed at /var/www or srv/proje **** initialize -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: cgi_init #+BEGIN_SRC ruby begin require 'cgi' @@ -122,7 +146,7 @@ end **** form ***** initialize form -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_init #+BEGIN_SRC ruby class Form def initialize(base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can='') @@ -139,93 +163,92 @@ class Form ***** submission form -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_submission #+BEGIN_SRC ruby - def submission_form - search_form =<<-WOK - - - - - <meta charset="utf-8"> - <meta name="sourcefile" content="SiSU._sst" /> - SiSU search form (sample): SiSU information Structuring Universe - - - - - - - -
- - -
-
- SiSU - -
- git - -
+def submission_form + search_form =<<-WOK + + + + + <meta charset="utf-8"> + <meta name="sourcefile" content="SiSU._sst" /> + SiSU search form (sample): SiSU information Structuring Universe + + + + + + + + + +
+ + +
+
+ SiSU + +
+ git + +
+
+ +
+
+ + -
+ - + + #{@tip} + #{@search_note} + #{@the_can} +
+
+ + + + to search: select which database to search (drop-down menu below); enter your search query (in the form above); and click on the search button (below) +
+ + + index + text / grep +
+ match limit: + 1,000 + 2,500 +
+ echo query + result stats + search url + searched + available fields + sql statement +
+ checks: + default + selected + all + none +
- - - -
- - - #{@tip} - #{@search_note} - #{@the_can} -
- - - - - to search: select which database to search (drop-down menu below); enter your search query (in the form above); and click on the search button (below) -
- - - index - text / grep -
- match limit: - 1,000 - 2,500 -
- echo query - result stats - search url - searched - available fields - sql statement -
- checks: - default - selected - all - none -
- - - - WOK - end + + WOK end #+END_SRC **** search request ***** initialize request -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_search_request_init #+BEGIN_SRC ruby class SearchRequest #% search_for attr_accessor :text1,:fulltext,:keywords,:title,:author,:topic_register,:subject,:description,:publisher,:editor,:contributor,:date,:type,:format,:identifier,:source,:language,:relation,:coverage,:rights,:comment,:abstract,:owner,:date_created,:date_issued,:date_modified,:date_available,:date_valid,:src_filename_base @@ -301,33 +324,32 @@ class SearchRequest #% sea ***** text to match -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_match_text #+BEGIN_SRC ruby - def text_to_match(identifier='') - m={ - 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] - elsif @search_field =~m[:string] then m[:string].match(@search_field)[1] - else - str=m[:word].match(@search_field)[1] - str=str.gsub(/[()]/,'') - str - end - search_string=search_string.strip.gsub(/\s+/,'+') - #else - # "__" +def text_to_match(identifier='') + m={ + 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] + elsif @search_field =~m[:string] then m[:string].match(@search_field)[1] + else + str=m[:word].match(@search_field)[1] + str=str.gsub(/[()]/,'') + str end + search_string=search_string.strip.gsub(/\s+/,'+') + #else + # "__" end end #+END_SRC **** search string -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_search_string #+BEGIN_SRC ruby class DBI_SearchString def initialize(l,t,q,cse=false) @@ -356,7 +378,7 @@ end **** search statement ***** init -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_search_statement #+BEGIN_SRC ruby class DBI_SearchStatement attr_reader :text_search_flag,:sql_select_body_format,:sql_offset,:sql_limit @@ -464,95 +486,95 @@ class DBI_SearchStatement ***** misc -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_misc #+BEGIN_SRC ruby - def sql_offset - @@offset +def sql_offset + @@offset +end +def sql_match_limit + @@limit +end +def sql_canned_search + @offset_next=sql_offset.to_i + sql_match_limit.to_i + @offset_previous=sql_offset.to_i - sql_match_limit.to_i + def current + @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + sql_offset.to_s end - def sql_match_limit - @@limit + def next + @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_next.to_s end - def sql_canned_search - @offset_next=sql_offset.to_i + sql_match_limit.to_i - @offset_previous=sql_offset.to_i - sql_match_limit.to_i - def current - @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + sql_offset.to_s - end - def next - @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_next.to_s - end - def previous - @offset_previous >= 0 \ - ? (@@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_previous.to_s) - : '' - end - def start - @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + 0.to_s - end - self + def previous + @offset_previous >= 0 \ + ? (@@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_previous.to_s) + : '' end - def pre_next(beyond_limit,img) - can=sql_canned_search - page=(sql_offset.to_i + sql_match_limit.to_i)/sql_match_limit.to_i - if beyond_limit - if page.to_s =~ /^1$/ - %{
- pg. #{page.to_s} - -  >> - -
} - elsif page.to_s =~ /^2$/ - %{
- - <<  - - pg. #{page.to_s} - -  >> - -
} - else - %{
- - |<  - - - <<  - - pg. #{page.to_s} - -  >> - -
} - end + def start + @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + 0.to_s + end + self +end +def pre_next(beyond_limit,img) + can=sql_canned_search + page=(sql_offset.to_i + sql_match_limit.to_i)/sql_match_limit.to_i + if beyond_limit + if page.to_s =~ /^1$/ + %{
+ pg. #{page.to_s} + +  >> + +
} + elsif page.to_s =~ /^2$/ + %{
+ + <<  + + pg. #{page.to_s} + +  >> + +
} else - if page.to_s =~ /^1$/ then '' - elsif page.to_s =~ /^2$/ - %{
- - <<  - - pg. #{page.to_s} -
} - else - %{
- - |<  - - - <<  - - pg. #{page.to_s} -
} - end + %{
+ + |<  + + + <<  + + pg. #{page.to_s} + +  >> + +
} + end + else + if page.to_s =~ /^1$/ then '' + elsif page.to_s =~ /^2$/ + %{
+ + <<  + + pg. #{page.to_s} +
} + else + %{
+ + |<  + + + <<  + + pg. #{page.to_s} +
} end end +end #+END_SRC ***** select statement -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_select_statement #+BEGIN_SRC ruby def sql_select_body limit ||= @@limit @@ -578,7 +600,7 @@ end **** tail -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_tail #+BEGIN_SRC ruby def tail <<-'WOK' @@ -683,7 +705,7 @@ end **** fcgi each ***** init & start loop -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_loop #+BEGIN_SRC ruby @tail=tail @counter_txt_doc,@counter_txt_ocn,@counter_endn_doc,@counter_endn_ocn=0,0,0,0 @@ -759,302 +781,302 @@ FCGI.each_cgi do |cgi| ***** canned search -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_search_canned #+BEGIN_SRC ruby - #Canned_search.new(@base,@search_for.text1,cgi) - if @search_for.text1=~/\S+/ or @search_for.fulltext=~/\S+/ or @search_for.author=~/\S+/ or @search_for.topic_register=~/\S+/ #and search_field =~/\S/ - s1 = 's1=' + CGI.escape(@search_for.text1) if @search_for.text1 =~ /\S/ - ft = '&ft=' + CGI.escape(@search_for.fulltext) if @search_for.fulltext =~ /\S/ - key = 'key=' + CGI.escape(@search_for.keywords) if @search_for.keywords =~ /\S/ - ti = '&ti=' + CGI.escape(@search_for.title) if @search_for.title =~ /\S/ - au = '&au=' + CGI.escape(@search_for.author) if @search_for.author =~ /\S/ - tr = '&tr=' + CGI.escape(@search_for.topic_register) if @search_for.topic_register =~ /\S/ - sj = '&sj=' + CGI.escape(@search_for.subject) if @search_for.subject =~ /\S/ - dsc = '&dsc=' + CGI.escape(@search_for.description) if @search_for.description =~ /\S/ - pb = '&pb=' + CGI.escape(@search_for.publisher) if @search_for.publisher =~ /\S/ - edt = '&edt=' + CGI.escape(@search_for.editor) if @search_for.editor =~ /\S/ - cntr = '&cntr=' + CGI.escape(@search_for.contributor) if @search_for.contributor =~ /\S/ - dt = '&dt=' + CGI.escape(@search_for.date) if @search_for.date =~ /\S/ - ty = '&ty=' + CGI.escape(@search_for.type) if @search_for.type =~ /\S/ - id = '&id=' + CGI.escape(@search_for.identifier) if @search_for.identifier =~ /\S/ - src = '&src=' + CGI.escape(@search_for.source) if @search_for.source =~ /\S/ - lang = '&lang=' + CGI.escape(@search_for.language) if @search_for.language =~ /\S/ - rel = '&rel=' + CGI.escape(@search_for.relation) if @search_for.relation =~ /\S/ - cov = '&cov=' + CGI.escape(@search_for.coverage) if @search_for.coverage =~ /\S/ - cr = '&cr=' + CGI.escape(@search_for.rights) if @search_for.rights =~ /\S/ - co = '&co=' + CGI.escape(@search_for.comment) if @search_for.comment =~ /\S/ - ab = '&ab=' + CGI.escape(@search_for.abstract) if @search_for.abstract =~ /\S/ - dtc = '&dtc=' + CGI.escape(@search_for.date_created) if @search_for.date_created =~ /\S/ - dti = '&dti=' + CGI.escape(@search_for.date_issued) if @search_for.date_issued =~ /\S/ - dtm = '&dtm=' + CGI.escape(@search_for.date_modified) if @search_for.date_modified =~ /\S/ - dta = '&dta=' + CGI.escape(@search_for.date_available) if @search_for.date_available =~ /\S/ - dtv = '&dtv=' + CGI.escape(@search_for.date_valid) if @search_for.date_valid =~ /\S/ - fns = '&fns=' + CGI.escape(@search_for.src_filename_base) if @search_for.src_filename_base =~ /\S/ - @@canned_search_url=(checked_all =~/checked/) \ - ? "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{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" - : "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}" - mod=ft=~/\S+/ ? (ft.gsub(/ft/,'s1')) : s1 - @canned_base_url="#{@base}?#{mod}&db=#{cgi['db']}" - if checked_case=~/\S/ - @search[:text][1]=%{doc_objects.clean~'#{@search_for.text1}'} #s1 - else - @search[:text][1]=%{doc_objects.clean~*'#{@search_for.text1}'} #s1 - end - canned_note='search url:' - else - @@canned_search_url="#{@base}?db=#{@db}&view=index" - canned_note='search url example:' - end - if search_field =~/\S+/ - analyze_format=search_field.gsub(/\s*\n/,'; ') - elsif checked_all =~/checked/ or checked_url =~/checked/ - canned_search=@@canned_search_url.scan(/(?:s1|ft|au|ti|fns|tr)=[^&]+/) - af=canned_search.join('; ') - af=af.gsub(/s1=/,'text: '). - gsub(/ft=/,'fulltxt: '). - gsub(/au=/,'author: '). - gsub(/ti=/,'title: '). - gsub(/fns=/,'src_filename_base: '). - gsub(/tr=/,'topic_register: '). - gsub(/%2B/,' ') - analyze_format=af - st=af.split(/\s*;\s*/) - search_field=st.join("\n") - end - green=%{} - canned_search_url_txt=CGI.escapeHTML(@@canned_search_url) - the_can=%{#{canned_note} #{canned_search_url_txt}
} - p_text=p_fulltext=p_keywords=p_title=p_author=p_topic_register=p_subject=p_description=p_publisher=p_editor=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='' - p_filename = %{src_filename_base: #{green}#{@search_for.src_filename_base}

} if @search_for.src_filename_base =~ /\S+/ - p_text = %{text: #{green}#{@search_for.text1}
} if @search_for.text1 =~ /\S+/ - p_fulltext = %{fulltxt: #{green}#{@search_for.fulltext}
} if @search_for.fulltext =~ /\S+/ - p_title = %{title: #{green}#{@search_for.title}
} if @search_for.title =~ /\S+/ - p_author = %{author: #{green}#{@search_for.author}
} if @search_for.author =~ /\S+/ - p_editor = %{editor: #{green}#{@search_for.editor}
} if @search_for.editor =~ /\S+/ - p_contributor = %{contributor: #{green}#{@search_for.contributor}
} if @search_for.contributor =~ /\S+/ - p_date = %{date: #{green}#{@search_for.date}
} if @search_for.date =~ /\S+/ - p_rights = %{rights: #{green}#{@search_for.rights}
} if @search_for.rights =~ /\S+/ - p_topic_register = %{topic_register: #{green}#{@search_for.topic_register}
} if @search_for.topic_register =~ /\S+/ - p_subject = %{subject: #{green}#{@search_for.subject}
} if @search_for.subject =~ /\S+/ - p_keywords = %{keywords: #{green}#{@search_for.keywords}
} if @search_for.keywords =~ /\S+/ - p_identifier = %{identifier: #{green}#{@search_for.identifier}
} if @search_for.identifier =~ /\S+/ - p_type = %{type: #{green}#{@search_for.type}
} if @search_for.type =~ /\S+/ - p_format = %{format: #{green}#{@search_for.format}
} if @search_for.format =~ /\S+/ - p_relation = %{relation: #{green}#{@search_for.relation}
} if @search_for.relation =~ /\S+/ - p_coverage = %{coverage: #{green}#{@search_for.coverage}
} if @search_for.coverage =~ /\S+/ - p_description = %{description: #{green}#{@search_for.description}
} if @search_for.description =~ /\S+/ - p_abstract = %{abstract: #{green}#{@search_for.abstract}
} if @search_for.abstract =~ /\S+/ - p_comment = %{comment: #{green}#{@search_for.comment}
} if @search_for.comment =~ /\S+/ - p_publisher = %{publisher: #{green}#{@search_for.publisher}
} if @search_for.publisher =~ /\S+/ - p_source = %{source: #{green}#{@search_for.source}
} if @search_for.source =~ /\S+/ - p_language = %{language: #{green}#{@search_for.language}
} if @search_for.language =~ /\S+/ - search_note=<<-WOK - - database: #{green}#{@db}; selected view: #{green}#{cgi['view']} - search string: "#{green}#{analyze_format}"
- #{p_text} #{p_fulltext} #{p_keywords} #{p_title} #{p_author} #{p_topic_register} #{p_subject} #{p_description} #{p_publisher} #{p_editor} #{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} - - WOK - #eg = %{canned search e.g.:
#{url}
find: #{analyze}
database: #{database}} - #% dbi_canning +#Canned_search.new(@base,@search_for.text1,cgi) +if @search_for.text1=~/\S+/ or @search_for.fulltext=~/\S+/ or @search_for.author=~/\S+/ or @search_for.topic_register=~/\S+/ #and search_field =~/\S/ + s1 = 's1=' + CGI.escape(@search_for.text1) if @search_for.text1 =~ /\S/ + ft = '&ft=' + CGI.escape(@search_for.fulltext) if @search_for.fulltext =~ /\S/ + key = 'key=' + CGI.escape(@search_for.keywords) if @search_for.keywords =~ /\S/ + ti = '&ti=' + CGI.escape(@search_for.title) if @search_for.title =~ /\S/ + au = '&au=' + CGI.escape(@search_for.author) if @search_for.author =~ /\S/ + tr = '&tr=' + CGI.escape(@search_for.topic_register) if @search_for.topic_register =~ /\S/ + sj = '&sj=' + CGI.escape(@search_for.subject) if @search_for.subject =~ /\S/ + dsc = '&dsc=' + CGI.escape(@search_for.description) if @search_for.description =~ /\S/ + pb = '&pb=' + CGI.escape(@search_for.publisher) if @search_for.publisher =~ /\S/ + edt = '&edt=' + CGI.escape(@search_for.editor) if @search_for.editor =~ /\S/ + cntr = '&cntr=' + CGI.escape(@search_for.contributor) if @search_for.contributor =~ /\S/ + dt = '&dt=' + CGI.escape(@search_for.date) if @search_for.date =~ /\S/ + ty = '&ty=' + CGI.escape(@search_for.type) if @search_for.type =~ /\S/ + id = '&id=' + CGI.escape(@search_for.identifier) if @search_for.identifier =~ /\S/ + src = '&src=' + CGI.escape(@search_for.source) if @search_for.source =~ /\S/ + lang = '&lang=' + CGI.escape(@search_for.language) if @search_for.language =~ /\S/ + rel = '&rel=' + CGI.escape(@search_for.relation) if @search_for.relation =~ /\S/ + cov = '&cov=' + CGI.escape(@search_for.coverage) if @search_for.coverage =~ /\S/ + cr = '&cr=' + CGI.escape(@search_for.rights) if @search_for.rights =~ /\S/ + co = '&co=' + CGI.escape(@search_for.comment) if @search_for.comment =~ /\S/ + ab = '&ab=' + CGI.escape(@search_for.abstract) if @search_for.abstract =~ /\S/ + dtc = '&dtc=' + CGI.escape(@search_for.date_created) if @search_for.date_created =~ /\S/ + dti = '&dti=' + CGI.escape(@search_for.date_issued) if @search_for.date_issued =~ /\S/ + dtm = '&dtm=' + CGI.escape(@search_for.date_modified) if @search_for.date_modified =~ /\S/ + dta = '&dta=' + CGI.escape(@search_for.date_available) if @search_for.date_available =~ /\S/ + dtv = '&dtv=' + CGI.escape(@search_for.date_valid) if @search_for.date_valid =~ /\S/ + fns = '&fns=' + CGI.escape(@search_for.src_filename_base) if @search_for.src_filename_base =~ /\S/ + @@canned_search_url=(checked_all =~/checked/) \ + ? "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{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" + : "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}" + mod=ft=~/\S+/ ? (ft.gsub(/ft/,'s1')) : s1 + @canned_base_url="#{@base}?#{mod}&db=#{cgi['db']}" + if checked_case=~/\S/ + @search[:text][1]=%{doc_objects.clean~'#{@search_for.text1}'} #s1 + else + @search[:text][1]=%{doc_objects.clean~*'#{@search_for.text1}'} #s1 + end + canned_note='search url:' +else + @@canned_search_url="#{@base}?db=#{@db}&view=index" + canned_note='search url example:' +end +if search_field =~/\S+/ + analyze_format=search_field.gsub(/\s*\n/,'; ') +elsif checked_all =~/checked/ or checked_url =~/checked/ + canned_search=@@canned_search_url.scan(/(?:s1|ft|au|ti|fns|tr)=[^&]+/) + af=canned_search.join('; ') + af=af.gsub(/s1=/,'text: '). + gsub(/ft=/,'fulltxt: '). + gsub(/au=/,'author: '). + gsub(/ti=/,'title: '). + gsub(/fns=/,'src_filename_base: '). + gsub(/tr=/,'topic_register: '). + gsub(/%2B/,' ') + analyze_format=af + st=af.split(/\s*;\s*/) + search_field=st.join("\n") +end +green=%{} +canned_search_url_txt=CGI.escapeHTML(@@canned_search_url) +the_can=%{#{canned_note} #{canned_search_url_txt}
} +p_text=p_fulltext=p_keywords=p_title=p_author=p_topic_register=p_subject=p_description=p_publisher=p_editor=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='' +p_filename = %{src_filename_base: #{green}#{@search_for.src_filename_base}

} if @search_for.src_filename_base =~ /\S+/ +p_text = %{text: #{green}#{@search_for.text1}
} if @search_for.text1 =~ /\S+/ +p_fulltext = %{fulltxt: #{green}#{@search_for.fulltext}
} if @search_for.fulltext =~ /\S+/ +p_title = %{title: #{green}#{@search_for.title}
} if @search_for.title =~ /\S+/ +p_author = %{author: #{green}#{@search_for.author}
} if @search_for.author =~ /\S+/ +p_editor = %{editor: #{green}#{@search_for.editor}
} if @search_for.editor =~ /\S+/ +p_contributor = %{contributor: #{green}#{@search_for.contributor}
} if @search_for.contributor =~ /\S+/ +p_date = %{date: #{green}#{@search_for.date}
} if @search_for.date =~ /\S+/ +p_rights = %{rights: #{green}#{@search_for.rights}
} if @search_for.rights =~ /\S+/ +p_topic_register = %{topic_register: #{green}#{@search_for.topic_register}
} if @search_for.topic_register =~ /\S+/ +p_subject = %{subject: #{green}#{@search_for.subject}
} if @search_for.subject =~ /\S+/ +p_keywords = %{keywords: #{green}#{@search_for.keywords}
} if @search_for.keywords =~ /\S+/ +p_identifier = %{identifier: #{green}#{@search_for.identifier}
} if @search_for.identifier =~ /\S+/ +p_type = %{type: #{green}#{@search_for.type}
} if @search_for.type =~ /\S+/ +p_format = %{format: #{green}#{@search_for.format}
} if @search_for.format =~ /\S+/ +p_relation = %{relation: #{green}#{@search_for.relation}
} if @search_for.relation =~ /\S+/ +p_coverage = %{coverage: #{green}#{@search_for.coverage}
} if @search_for.coverage =~ /\S+/ +p_description = %{description: #{green}#{@search_for.description}
} if @search_for.description =~ /\S+/ +p_abstract = %{abstract: #{green}#{@search_for.abstract}
} if @search_for.abstract =~ /\S+/ +p_comment = %{comment: #{green}#{@search_for.comment}
} if @search_for.comment =~ /\S+/ +p_publisher = %{publisher: #{green}#{@search_for.publisher}
} if @search_for.publisher =~ /\S+/ +p_source = %{source: #{green}#{@search_for.source}
} if @search_for.source =~ /\S+/ +p_language = %{language: #{green}#{@search_for.language}
} if @search_for.language =~ /\S+/ +search_note=<<-WOK + + database: #{green}#{@db}; selected view: #{green}#{cgi['view']} + search string: "#{green}#{analyze_format}"
+ #{p_text} #{p_fulltext} #{p_keywords} #{p_title} #{p_author} #{p_topic_register} #{p_subject} #{p_description} #{p_publisher} #{p_editor} #{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} + +WOK +#eg = %{canned search e.g.:
#{url}
find: #{analyze}
database: #{database}} +#% dbi_canning #+END_SRC ***** submission form -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_submit #+BEGIN_SRC ruby - @header = Form.new(@base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can).submission_form #% form - unless q['s1'] =~/\S/ or q['au'] =~/\S/ or @search[:text][1] =~/\S/ - print "Content-type: text/html\n\n" - puts (@header+@tail) - else #% searches - s1=(@search_for.text1 =~/\S/) \ - ? @search_for.text1 - : 'Unavailable' - if checked_case=~/\S/ - @search[:text]<<%{doc_objects.clean~'#{CGI.unescape(s1)}'} - else - @search[:text]<<%{doc_objects.clean~*'#{CGI.unescape(s1)}'} +@header = Form.new(@base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can).submission_form #% form +unless q['s1'] =~/\S/ or q['au'] =~/\S/ or @search[:text][1] =~/\S/ + print "Content-type: text/html\n\n" + puts (@header+@tail) +else #% searches + s1=(@search_for.text1 =~/\S/) \ + ? @search_for.text1 + : 'Unavailable' + if checked_case=~/\S/ + @search[:text]<<%{doc_objects.clean~'#{CGI.unescape(s1)}'} + else + @search[:text]<<%{doc_objects.clean~*'#{CGI.unescape(s1)}'} + end + #% dbi_request + dbi_statement=DBI_SearchStatement.new(@conn,@search_for,q,checked_case) + @text_search_flag=false + @text_search_flag=dbi_statement.text_search_flag + s_contents=dbi_statement.contents + @body_main='' + @search_regx=nil + olduid="" + if @text_search_flag + if checked_sql =~/\S/ + sql_select_body=dbi_statement.sql_select_body_format + else sql_select_body='' end - #% dbi_request - dbi_statement=DBI_SearchStatement.new(@conn,@search_for,q,checked_case) - @text_search_flag=false - @text_search_flag=dbi_statement.text_search_flag - s_contents=dbi_statement.contents - @body_main='' - @search_regx=nil - olduid="" - if @text_search_flag - if checked_sql =~/\S/ - sql_select_body=dbi_statement.sql_select_body_format - else sql_select_body='' - end - @body_main << sql_select_body - #@body_main << '



Main Text:
' << sql_select_body + @body_main << sql_select_body + #@body_main << '



Main Text:
' << sql_select_body + else + end + @hostpath = "#{@hosturl_files}" + #@hostpath="#{@hosturl_files}/#{@stub}" + def path_manifest(fn,ln=nil) + case @output_dir_structure_by + when 'filename' + @lingual =='mono' \ + ? "#{@hostpath}/#{fn}/sisu_manifest.html" + : "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html" + when 'filetype' + @lingual =='mono' \ + ? "#{@hostpath}/manifest/#{fn}.html" + : "#{@hostpath}/manifest/#{fn}.#{ln}.html" else + "#{@hostpath}/#{ln}/manifest/#{fn}.html" end - @hostpath = "#{@hosturl_files}" - #@hostpath="#{@hosturl_files}/#{@stub}" - def path_manifest(fn,ln=nil) - case @output_dir_structure_by - when 'filename' - @lingual =='mono' \ - ? "#{@hostpath}/#{fn}/sisu_manifest.html" - : "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html" - when 'filetype' - @lingual =='mono' \ - ? "#{@hostpath}/manifest/#{fn}.html" - : "#{@hostpath}/manifest/#{fn}.#{ln}.html" - else - "#{@hostpath}/#{ln}/manifest/#{fn}.html" - end - end - def path_html_seg(fn,ln=nil) - case @output_dir_structure_by - when 'filename' - "#{@hostpath}/#{fn}" - when 'filetype' - "#{@hostpath}/html/#{fn}" - else - "#{@hostpath}/#{ln}/html/#{fn}" - end + end + def path_html_seg(fn,ln=nil) + case @output_dir_structure_by + when 'filename' + "#{@hostpath}/#{fn}" + when 'filetype' + "#{@hostpath}/html/#{fn}" + else + "#{@hostpath}/#{ln}/html/#{fn}" end - def path_toc(fn,ln=nil) - if @output_dir_structure_by =='filename' \ - or @output_dir_structure_by =='filetype' - @lingual =='mono' \ - ? "#{path_html_seg(fn,ln)}/toc.html" - : "#{path_html_seg(fn,ln)}/toc.#{ln}.html" - else - "#{path_html_seg(fn,ln)}/toc.html" - end + end + def path_toc(fn,ln=nil) + if @output_dir_structure_by =='filename' \ + or @output_dir_structure_by =='filetype' + @lingual =='mono' \ + ? "#{path_html_seg(fn,ln)}/toc.html" + : "#{path_html_seg(fn,ln)}/toc.#{ln}.html" + else + "#{path_html_seg(fn,ln)}/toc.html" end - def path_filename(fn,seg_name,ln=nil) - if @output_dir_structure_by =='filename' \ - or @output_dir_structure_by =='filetype' - @lingual =='mono' \ - ? "#{path_html_seg(fn,ln)}/#{seg_name}.html" - : "#{path_html_seg(fn,ln)}/#{seg_name}.#{ln}.html" - else - "#{path_html_seg(fn,ln)}/#{seg_name}.html" - end + end + def path_filename(fn,seg_name,ln=nil) + if @output_dir_structure_by =='filename' \ + or @output_dir_structure_by =='filetype' + @lingual =='mono' \ + ? "#{path_html_seg(fn,ln)}/#{seg_name}.html" + : "#{path_html_seg(fn,ln)}/#{seg_name}.#{ln}.html" + else + "#{path_html_seg(fn,ln)}/#{seg_name}.html" end - def path_html_doc(fn,ln=nil) - case @output_dir_structure_by - when 'filename' - @lingual =='mono' \ - ? "#{path_html_seg(fn,ln)}/scroll.html" - : "#{path_html_seg(fn,ln)}/scroll.#{ln}.html" - when 'filetype' - @lingual =='mono' \ - ? "#{@hostpath}/html/#{fn}.html" - : "#{@hostpath}/html/#{fn}.#{ln}.html" - else - "#{@hostpath}/#{ln}/html/#{fn}.html" - end + end + def path_html_doc(fn,ln=nil) + case @output_dir_structure_by + when 'filename' + @lingual =='mono' \ + ? "#{path_html_seg(fn,ln)}/scroll.html" + : "#{path_html_seg(fn,ln)}/scroll.#{ln}.html" + when 'filetype' + @lingual =='mono' \ + ? "#{@hostpath}/html/#{fn}.html" + : "#{@hostpath}/html/#{fn}.#{ln}.html" + else + "#{@hostpath}/#{ln}/html/#{fn}.html" end + end #+END_SRC ***** contents each, text body -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_contents_each_text #+BEGIN_SRC ruby - #% text_objects_body - s_contents.each do |c| #% text body - location=c['src_filename_base'][/(.+?)\.(?:ssm\.sst|sst)$/,1] - file_suffix=c['src_filename_base'][/.+?\.(ssm\.sst|sst)$/,1] - lang=if location =~ /\S+?~(\S\S\S?)$/ - l=location[/\S+?~(\S\S\S?)$/,1] - location=location.gsub(/(\S+?)~\S\S\S?/,'\1') - l=".#{l}" - else '' - end - #% metadata_found_body - if c['uid'] != olduid - ti=c['title'] - can_txt_srch=(cgi['view']=~/index/) \ - ? %{search } - : %{search } - title = %{ #{ti} [#{c['language_document_char']}] by #{c['creator_author']} #{can_txt_srch}
} - title=@text_search_flag \ - ? '

'+title - : '
'+title - @counter_txt_doc+=1 - olduid=c['uid'] - else title='' - end - if @text_search_flag - if cgi['view']=~/text/ \ - or (cgi['view']!~/index/ and cgi['search'] !~/search db/) #% 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| - (g.to_s =~/(AND|OR)/) \ - ? (search_regex << '|') - : (search_regex << %{#{g.to_s}}) - end - search_regex=search_regex.join(' ') - search_regex=search_regex.gsub(/\s*\|\s*/,'|') - Regexp.new(search_regex, Regexp::IGNORECASE) - else nil - end - else nil - end - matched_para=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \ - ? (c['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1})) - : c['body'] - %{

ocn #{c['ocn']}:

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

ocn #{c['ocn']}:#{c['body']}} - end - @counter_txt_ocn+=1 - output=title+text - else #elsif cgi['view']=~/index/ #% idx body - if c['suffix'] !~/1/ #seg - index=%{#{c['ocn']}, } if @text_search_flag - elsif c['suffix'] =~/1/ #doc #FIX - index=%{#{c['ocn']}, } + #% text_objects_body +s_contents.each do |c| #% text body + location=c['src_filename_base'][/(.+?)\.(?:ssm\.sst|sst)$/,1] + file_suffix=c['src_filename_base'][/.+?\.(ssm\.sst|sst)$/,1] + lang=if location =~ /\S+?~(\S\S\S?)$/ + l=location[/\S+?~(\S\S\S?)$/,1] + location=location.gsub(/(\S+?)~\S\S\S?/,'\1') + l=".#{l}" + else '' + end +#% metadata_found_body + if c['uid'] != olduid + ti=c['title'] + can_txt_srch=(cgi['view']=~/index/) \ + ? %{search } + : %{search } + title = %{ #{ti} [#{c['language_document_char']}] by #{c['creator_author']} #{can_txt_srch}
} + title=@text_search_flag \ + ? '


'+title + : '
'+title + @counter_txt_doc+=1 + olduid=c['uid'] + else title='' + end + if @text_search_flag + if cgi['view']=~/text/ \ + or (cgi['view']!~/index/ and cgi['search'] !~/search db/) #% 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 - if c['seg_name'] =~/\S+/ - if @text_search_flag - @counter_txt_ocn+=1 - output=title+index + @search_regx=if unescaped_search #check + search_regex=[] + build=unescaped_search.scan(/\S+/).each do |g| + (g.to_s =~/(AND|OR)/) \ + ? (search_regex << '|') + : (search_regex << %{#{g.to_s}}) end - else - @counter_txt_ocn+=1 - output=c['suffix'] !~/1/ \ - ? title+index - : %{#{title}#{c['ocn'].sort}, } + search_regex=search_regex.join(' ') + search_regex=search_regex.gsub(/\s*\|\s*/,'|') + Regexp.new(search_regex, Regexp::IGNORECASE) + else nil end + else nil end - else output=title + matched_para=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \ + ? (c['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1})) + : c['body'] + %{

ocn #{c['ocn']}:

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

ocn #{c['ocn']}:#{c['body']}} end - @counters_txt=if @counter_txt_doc > 0 - if checked_stats =~/\S/ - @@lt_t=(@counter_txt_ocn==dbi_statement.sql_match_limit.to_i) ? true : false - start=(@@offset.to_i+1).to_s - range=(@@offset.to_i+@counter_txt_ocn.to_i).to_s - %{


Found #{@counter_txt_ocn} times in the main body of #{@counter_txt_doc} documents [ matches #{start} to #{range} ]
} - else '' + @counter_txt_ocn+=1 + output=title+text + else #elsif cgi['view']=~/index/ #% idx body + if c['suffix'] !~/1/ #seg + index=%{#{c['ocn']}, } if @text_search_flag + elsif c['suffix'] =~/1/ #doc #FIX + index=%{#{c['ocn']}, } + end + if c['seg_name'] =~/\S+/ + if @text_search_flag + @counter_txt_ocn+=1 + output=title+index end - else '' + else + @counter_txt_ocn+=1 + output=c['suffix'] !~/1/ \ + ? title+index + : %{#{title}#{c['ocn'].sort}, } end - @body_main << output #+ details end + else output=title + end + @counters_txt=if @counter_txt_doc > 0 + if checked_stats =~/\S/ + @@lt_t=(@counter_txt_ocn==dbi_statement.sql_match_limit.to_i) ? true : false + start=(@@offset.to_i+1).to_s + range=(@@offset.to_i+@counter_txt_ocn.to_i).to_s + %{
Found #{@counter_txt_ocn} times in the main body of #{@counter_txt_doc} documents [ matches #{start} to #{range} ]
} + else '' + end + else '' + end + @body_main << output #+ details +end #+END_SRC ***** after -#+HEADER: :tangle "../sundry/util/rb/cgi/spine.search.cgi" +#+NAME: form_contents_after #+BEGIN_SRC ruby olduid = "" offset=dbi_statement.sql_offset.to_s -- cgit v1.2.3