presentations' look and feel
generated by
SiSU
version 0.50 2007w11/1 (2007-03-12)
the usual GPL (or OSS) suspects: Better - "performance, reliability, scalability, security & total cost of ownership" [not to mention flexibility & choice]
<<Way Better!>> |
|
WOK
end
WOK_SQL
end
def main1
<<-'WOK_SQL'
@tail=tail
@counter_txt_doc,@counter_txt_ocn,@counter_endn_doc,@counter_endn_ocn=0,0,0,0
@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 => [] }
q=CGI.new
@db=if cgi['db'] =~/\S+/;
@stub=/SiSU_(\S+)/.match(cgi['db'])[1]
cgi['db']
else
@stub='sisu'
'SiSU_sisu'
end
checked_url,checked_searched,checked_tip,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,selected_db='','','','','','','',''
if cgi['view']=~/text/; checked_index,checked_text='','checked'
else checked_index,checked_text='checked',''
end
checked_url='checked' if cgi['url'] =~/\S/ or cgi['u'].to_i==1
checked_searched='checked' if cgi['searched'] =~/\S/
checked_tip='checked' if cgi['tip'] =~/\S/
checked_echo='checked' if cgi['echo'] =~/\S/
checked_sql='checked' if cgi['sql'] =~/\S/
if cgi['checks'] =~/check_all/ or cgi['check_all'] =~/\S/ or cgi['a'].to_i==1
checked_all=checked_url=checked_searched=checked_tip=checked_echo=checked_sql='checked'
checked_none=''
elsif cgi['checks'] =~/check_none/ #or cgi['a'].to_i==0
checked_none='checked'
checked_all=checked_url=checked_searched=checked_tip=checked_echo=checked_sql=''
else checked_ignore='checked'
end
WOK_SQL
end
def main2
<<-'WOK_SQL'
search_field=cgi['find'] if cgi['find'] # =~/\S+/
@search_for=Search_request.new(search_field,q) #.analyze #% search_for
#% searches
#Canned_search.new(@base,@search_for.text1,cgi)
if @search_for.text1=~/\S+/ or @search_for.author=~/\S+/ #and search_field =~/\S/
s1='s1=' + CGI.escape(@search_for.text1) if @search_for.text1=~/\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/
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/
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.filename) if @search_for.filename=~/\S/
@@canned_search_url=if checked_all =~/checked/
"#@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']}&u=1&e=1"
end
@search[:text][1]=%{documents.clean~'#{@search_for.text1}'} #s1
@search[:endnotes][1]=%{endnotes.clean~'#{@search_for.text1}'} #s1
canned_note='previous search url:'
else
@@canned_search_url="#@base?s1=United+Nations&db=documents&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|au|ti|fns)=[^&]+/)
af=canned_search.join('; ')
af.gsub!(/s1=/,'text: ')
af.gsub!(/au=/,'author: ')
af.gsub!(/ti=/,'title: ')
af.gsub!(/fns=/,'filename: ')
af.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_keywords=p_title=p_author=p_subject=p_description=p_publisher=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_subject=p_filename=''
p_text=%{text: #{green}#{@search_for.text1} } if @search_for.text1 =~/\S+/
p_keywords=%{keywords: #{green}#{@search_for.keywords} } if @search_for.keywords =~/\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_subject=%{subject: #{green}#{@search_for.subject} } if @search_for.subject =~/\S+/
p_description=%{description: #{green}#{@search_for.description} } if @search_for.description =~/\S+/
p_publisher=%{publisher: #{green}#{@search_for.publisher} } if @search_for.publisher =~/\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_type=%{type: #{green}#{@search_for.type} } if @search_for.type =~/\S+/
p_format=%{format: #{green}#{@search_for.format} } if @search_for.format =~/\S+/
p_identifier=%{identifier: #{green}#{@search_for.identifier} } if @search_for.identifier =~/\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+/
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_rights=%{rights: #{green}#{@search_for.rights} } if @search_for.rights =~/\S+/
p_comment=%{comment: #{green}#{@search_for.comment} } if @search_for.comment =~/\S+/
p_abstract=%{abstract: #{green}#{@search_for.abstract} } if @search_for.abstract =~/\S+/
p_filename=%{filename: #{green}#{@search_for.filename} } if @search_for.filename =~/\S+/
search_note=<<-WOK
previous selection:
database: #{green}#@db; selected view: #{green}#{cgi['view']}
search string: "#{green}#{analyze_format}"
#{p_text} #{p_keywords} #{p_title} #{p_author} #{p_subject} #{p_description} #{p_publisher} #{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
@header=Form.new(@base,search_field,selected_db,checked_index,checked_text,checked_tip,checked_searched,checked_url,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,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=if @search_for.text1 =~/\S/
@search_for.text1
else 'Unavailable'
end
@search[:text]<<%{documents.clean~'#{CGI.unescape(s1)}'}
@search[:endnotes]<<%{endnotes.clean~'#{CGI.unescape(s1)}'}
#dbi_request
dbi_statement=Dbi_search_statement.new(@conn,@search_for,q)
@text_search_flag=false
@text_search_flag=dbi_statement.text_search_flag
s_contents=dbi_statement.contents
s_endnotes=dbi_statement.endnotes
@body_main,@endnotes=[],[]
@search_regx=nil
oldtid=0
if @text_search_flag
if checked_sql =~/\S/
sql_select_body=dbi_statement.sql_select_body_format
sql_select_endnotes=dbi_statement.sql_select_endnotes_format
else sql_select_body,sql_select_endnotes='',''
end
@body_main << '
Main Text: ' << sql_select_body
@endnotes << '
Endnotes: ' << sql_select_endnotes
else
end
#text_objects_body
s_contents.each do |c| #% text body
location=c['filename'][/(.+?)\.(?:_?sst|ssm)$/,1]
file_suffix=c['filename'][/.+?\.(_?sst|ssm)$/,1]
lang=if location =~ /\S+?~(\S\S\S?)$/
l=location[/\S+?~(\S\S\S?)$/,1]
location.gsub!(/(\S+?)~\S\S\S?/,'\1')
l=".#{l}"
else ''
end
#metadata_found_body
if c['tid'].to_i != oldtid.to_i
title=%{#{c['title']} by #{c['creator']} ? } 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
@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
else nil
end
matched_para=if (@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/)
matched=if c['body'] =~/\\1}))
end
matched
else c['body']
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
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=title+index
end
else
@counter_txt_ocn+=1
output=unless c['suffix'] =~/1/; title+index
else %{#{title}#{c['ocn'].sort}, }
end
end
end
else output=title
end
@counters_txt=if @counter_txt_doc > 0
%{Found in the main body of #@counter_txt_doc documents, and at #@counter_txt_ocn locations within. }
else ''
end
@body_main << output #+ details
end
#text_objects_endnote
oldtid = 0
s_endnotes.each do |e| #% endnotes
location=e['filename'][/(.+?)\.(?:_?sst|ssm)$/,1]
file_suffix=e['filename'][/.+?\.(_?sst|ssm)$/,1]
lang=if location =~ /\S+?~(\S\S\S?)$/
l=location[/\S+?~(\S\S\S?)$/,1]
location.gsub!(/(\S+?)~\S\S\S?/,'\1')
l=".#{l}"
else ''
end
#metadata_found_endnotes
if @text_search_flag
if e['metadata_tid'].to_i != oldtid.to_i
title=%{
#{e['title']} by #{e['creator']} ? } if file_suffix=~/s/
@counter_endn_doc+=1
oldtid=e['metadata_tid'].to_i
else title = ''
end
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
else e['body']
end
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
%{Found in the endnotes of #@counter_endn_doc documents, and at #@counter_endn_ocn locations within. }
end
@endnotes << output #+ details
else @endnotes=[] #does not take out yet
end
end
offset=dbi_statement.sql_offset.to_s
limit=dbi_statement.sql_limit.to_s
canned=dbi_statement.sql_canned_search_url.to_s
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
rescue Exception => e
s='' + CGI::escapeHTML(e.backtrace.reverse.join("\n"))
s << CGI::escapeHTML(e.message) + ' '
cgi.out{s}
next
ensure # eg. disconnect from server
@conn.disconnect if @conn
end
end
WOK_SQL
end
end
end
__END__
#@counter_txt_ocn
#@counter_endn_ocn
if cgi['checks'] =~/check_all/ or cgi['check_all'] =~/\S/ or cgi['a'].to_i==1
checked_all=checked_url=checked_searched=checked_tip=checked_echo=checked_sql='checked'
checked_none=''
#elsif cgi['checks'] =~/check_fixed/ or cgi['check_fixed'] =~/\S/
# #checked_ignore='checked'
# checked_fixed='checked'
# checked_url='checked'
# checked_searched='checked'
# checked_echo='checked'
# #checked_tip='checked'
# #checked_sql='checked'
# checked_tip=checked_sql=checked_none=''
#elsif cgi['checks'] =~/check_ignore/ or cgi['check_ignore'] =~/\S/
# checked_ignore='checked'
# checked_url='checked' if cgi['url'] =~/\S/ or cgi['u'].to_i==1
# checked_searched='checked' if cgi['searched'] =~/\S/
# checked_tip='checked' if cgi['tip'] =~/\S/
# checked_echo='checked' if cgi['echo'] =~/\S/
# checked_sql='checked' if cgi['sql'] =~/\S/
# checked_none=''
elsif cgi['checks'] =~/check_none/ or cgi['a'].to_i==0
checked_none='checked'
checked_all=checked_url=checked_searched=checked_tip=checked_echo=checked_sql=''
else checked_ignore='checked'
end
|