aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v4
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2013-03-29 21:48:25 -0400
committerRalph Amissah <ralph@amissah.com>2013-03-29 21:48:25 -0400
commit5fb1d73615bbe3839767964a4028b65e07ecdf23 (patch)
tree388bfcf8a1178870e7f8375fa0f3dc5ac6304d06 /lib/sisu/v4
parentdebian/changelog (4.0.17-1) (diff)
parentv4: version & changelog, dates touched (diff)
Merge tag 'sisu_4.0.18' into debian/sid
SiSU 4.0.18
Diffstat (limited to 'lib/sisu/v4')
-rw-r--r--lib/sisu/v4/cgi.rb8
-rw-r--r--lib/sisu/v4/cgi_pgsql.rb48
-rw-r--r--lib/sisu/v4/cgi_sql_common.rb24
-rw-r--r--lib/sisu/v4/cgi_sqlite.rb2
-rw-r--r--lib/sisu/v4/dal.rb14
-rw-r--r--lib/sisu/v4/db_import.rb1
-rw-r--r--lib/sisu/v4/screen_text_color.rb3
-rw-r--r--lib/sisu/v4/sysenv.rb15
8 files changed, 69 insertions, 46 deletions
diff --git a/lib/sisu/v4/cgi.rb b/lib/sisu/v4/cgi.rb
index 518770a5..600d7146 100644
--- a/lib/sisu/v4/cgi.rb
+++ b/lib/sisu/v4/cgi.rb
@@ -69,17 +69,9 @@ module SiSU_CGI
@opt=opt
@webserv=@opt.files[0].to_s.strip
end
- def search_info
- a=%{
- For help on sisu search, type:
- sisu --help search
- }
- SiSU_Screen::Ansi.new(@opt.cmd,a).print_grey
- end
def read
SiSU_CGI_SQLite::SearchSQLite.new(@opt,@webserv).sqlite
SiSU_CGI_PgSQL::SearchPgSQL.new(@opt,@webserv).pgsql
- search_info unless @opt.cmd =~/q/
end
end
end
diff --git a/lib/sisu/v4/cgi_pgsql.rb b/lib/sisu/v4/cgi_pgsql.rb
index 6102d585..36f9782b 100644
--- a/lib/sisu/v4/cgi_pgsql.rb
+++ b/lib/sisu/v4/cgi_pgsql.rb
@@ -68,10 +68,35 @@ module SiSU_CGI_PgSQL
@opt,@webserv=opt,webserv
@env=SiSU_Env::InfoEnv.new('',opt)
@sys=SiSU_Env::SystemCall.new
- @image_src="#{@env.url.webserv_cgi}/_sisu/image_sys"
- @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env)
@db=SiSU_Env::InfoDb.new
+ get_init=SiSU_Env::GetInit.new
+ @rc=get_init.sisu_yaml.rc
+ @name_of={}
+ if defined? @rc['webserv'] \
+ and defined? @rc['webserv']['url_root'] \
+ and defined? @rc['webserv']['url_root'] =~/\S+/
+ @name_of[:host_url_docs]=@rc['webserv']['url_root']
+ end
+ if defined? @rc['search'] \
+ and defined? @rc['search']['sisu'] \
+ and defined? @rc['search']['sisu']['action'] \
+ and @rc['search']['sisu']['action'] =~/https?:\/\/\S+?\.cgi/ \
+ and defined? @rc['search']['sisu']['db'] \
+ and @rc['search']['sisu']['db'] =~/\S+/
+ @name_of[:db]=@rc['search']['sisu']['db']
+ #@name_of[:cgi_script]=/https?:\/\/\S+?([^\/]+?)\.cgi$/.match(@rc['search']['sisu']['action'])[1]
+ @name_of[:host_url_cgi],@name_of[:cgi_script]=/(https?:\/\/\S+?)\/([^\/]+?)\.cgi$/.match(@rc['search']['sisu']['action'])[1,2]
+ else
+ @name_of[:host_url_docs]=@env.url.webserv_files_from_db
+ @name_of[:db]='sisu' #breaks if not present
+ @name_of[:host_url_cgi]=@env.url.webserv_base_cgi
+ @name_of[:cgi_script]='sisu_pgsql'
+ false
+ end
@cgi_file_name="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by.to_s}_pgsql.cgi"
+ @cgi_link_name="#{@name_of[:db]}.cgi" #sisu_pgsql.cgi,
+ @image_src="#{@name_of[:host_url_docs]}/_sisu/image_sys"
+ @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env)
end
def pgsql
serve=[]
@@ -99,7 +124,7 @@ module SiSU_CGI_PgSQL
if FileTest.writable?('.')
output=File.open(@cgi_file_name,'w')
output << header0 << header1 << header_desc << header2 << f1 << buttons1 << buttons1_pgsql << buttons2 << search_request << search_statement << search_statement_common << search_query1 << @common.pages << search_query2 << @common.tail << @common.main1 << f2 << dbi_connect << @common.main2 << @common.dir_structure << @common.main3
- a=%{ generated sisu_pgsql.cgi,
+ a=%{ generated #{@cgi_file_name},
BASED ON ALREADY EXISTING directories that could potentially be used to populate postgresql db, (-D)
}
SiSU_Screen::Ansi.new(@opt.cmd,a).print_grey
@@ -108,11 +133,11 @@ module SiSU_CGI_PgSQL
else "if necessary make the directory /usr/lib/cgi-bin :
sudo cp -vi #{Dir.pwd}/#{@cgi_file_name} /usr/lib/cgi-bin/.
sudo chmod -v 755 /usr/lib/cgi-bin/#{@cgi_file_name}
- sudo ln -s /usr/lib/cgi-bin/#{@cgi_file_name} /usr/lib/cgi-bin/sisu_pgsql.cgi
- (copy #{@cgi_file_name} to your cgi directory) set file permissions to 755, and make symbolic link to sisu_pgsql.cgi"
+ sudo ln -s /usr/lib/cgi-bin/#{@cgi_file_name} /usr/lib/cgi-bin/#{@cgi_link_name}
+ (copy #{@cgi_file_name} to your cgi directory) set file permissions to 755, and make symbolic link to #{@cgi_link_name}"
end
a=%{#{c}
- #{@env.webserv_base_cgi}/cgi-bin/sisu_pgsql.cgi
+ #{@env.webserv_base_cgi}/cgi-bin/#{@cgi_link_name}
}
SiSU_Screen::Ansi.new(@opt.cmd,a).warn
a="postgresql db used for present directory: #{@db.psql.db}"
@@ -132,13 +157,14 @@ module SiSU_CGI_PgSQL
require 'cgi'
require 'fcgi'
require 'dbi'
- @version='sisu_pgsql'
- @image_src="#{@env.url.webserv_cgi}/_sisu/image_sys"
- @hosturl_db="#{@env.url.webserv_base_cgi}"
- @hosturl_files="#{@env.url.webserv_files_from_db}"
+ @stub_default="#{@name_of[:db]}"
+ @image_src="#{@name_of[:host_url_docs]}/_sisu/image_sys"
+ @hosturl_db="#{@name_of[:host_url_cgi]}"
+ @hosturl_files="#{@name_of[:host_url_docs]}"
+ @output_dir_structure_by="#{@name_of[:output_dir_structure]}"
@port="#{@db.psql.port}"
@db_name_prefix="#{Db[:name_prefix]}"
- user='#{@env.user}' # check user name for access to pg database: '#{@env.user}'
+ user='www-data' # check user name for access to pg database: e.g. www-data or '#{@env.user}'
WOK_SQL
end
def search_statement
diff --git a/lib/sisu/v4/cgi_sql_common.rb b/lib/sisu/v4/cgi_sql_common.rb
index c3c07bdb..058d04ec 100644
--- a/lib/sisu/v4/cgi_sql_common.rb
+++ b/lib/sisu/v4/cgi_sql_common.rb
@@ -130,7 +130,7 @@ module SiSU_CGI_SQL
<<-'WOK_SQL'
#Common TOP
@@offset=0
- @base="#{@hosturl_db}/cgi-bin/#{@version}.cgi"
+ @base="#{@hosturl_db}/#{@stub_default}.cgi" #fix sqlite
@@canned_search_url=@base
@color_heading='#DDFFAA'
@color_match='#ffff48'
@@ -167,8 +167,7 @@ module SiSU_CGI_SQL
<body bgcolor="#ffffff" text="#000000" link="#003090" lang="en" xml:lang="en">
<table summary="band" border="0" cellpadding="3" cellspacing="0">
<tr><td align="left" bgcolor="#ffffff"><a href="http://www.jus.uio.no/sisu/" target="_top"><img border="0" src="#{@image_src}/sisu.png" alt="SiSU --&gt;" /></a></td><td>
-<!-- <p class="tiny"><a href="http://www.jus.uio.no/sisu/SiSU/">&nbsp;http://www.jus.uio.no/sisu/SiSU/</a></p> -->
- <label for="find"><b>#{@env.sample_search_form_title}</b></label>
+ <label for="find"><b>#{@env.sample_search_form_title(@opt.dir_structure_by)}</b></label>
</td></tr>
</table>
WOK_SQL
@@ -655,8 +654,8 @@ module SiSU_CGI_SQL
@stub=/#{@db_name_prefix}(\S+)/.match(cgi['db'])[1]
cgi['db']
else
- @stub='sisu'
- "#{@db_name_prefix}#{@stub}"
+ @stub=@stub_default
+ @db_name_prefix + @stub
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/) \
@@ -834,7 +833,6 @@ module SiSU_CGI_SQL
else
end
@hostpath="#{@hosturl_files}/#{@stub}"
- @ln='en'
WOK_SQL
end
def dir_structure
@@ -922,7 +920,7 @@ module SiSU_CGI_SQL
can_txt_srch=(cgi['view']=~/index/) \
? %{<a href="#{@canned_base_url}&fns=#{c['src_filename']}&lang=#{c['language_document_char']}&view=text"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a>&nbsp;}
: %{<a href="#{@canned_base_url}&fns=#{c['src_filename']}&lang=#{c['language_document_char']}&view=index"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a>&nbsp;}
- title=%{<span style="background-color: #{@color_heading}"><a href="#{path_toc(location,c['language_document_char'])}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html">&nbsp;#{ti}</a></span> [#{c['language_document_char']}] by #{c['creator_author']} #{can_txt_srch}<a href="#{path_toc(location,c['language_document_char'])}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"></a>&nbsp;<a href="#{path_manifest(location,c['language_document_char'])}"><img border="0" width="15" height="15" src="#{@image_src}/b_info.png" alt="manifest"></a><br />} if file_suffix=~/s/ #hmm watch file_suffix
+ title=%{<span style="background-color: #{@color_heading}"><a href="#{path_toc(location,c['language_document_char'])}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html">&nbsp;#{ti}</a></span> [#{c['language_document_char']}] by #{c['creator_author']} <a href="#{path_manifest(location,c['language_document_char'])}"><img border="0" width="15" height="15" src="#{@image_src}/b_info.png" alt="manifest"></a> #{can_txt_srch}<br />} if file_suffix=~/s/ #hmm watch file_suffix
title=@text_search_flag \
? '<br /><hr>'+title
: '<br />'+title
@@ -959,7 +957,7 @@ module SiSU_CGI_SQL
matched_para=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \
? (c['body'].gsub(/(<a\s+href="https?:\/\/[^><\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{<span style="background-color: #{@color_match}">\\1</span>}))
: c['body']
- %{<hr><p><font size="2">ocn <b><a href="#{path_filename(location,c['seg'],@ln)}##{c['ocn']}">#{c['ocn']}</a></b>:</font></p>#{matched_para}}
+ %{<hr><p><font size="2">ocn <b><a href="#{path_filename(location,c['seg'],c['language_document_char'])}##{c['ocn']}">#{c['ocn']}</a></b>:</font></p>#{matched_para}}
elsif c['suffix'] =~/1/ #doc
%{#{title}<hr><p><font size="2">ocn #{c['ocn']}:#{c['body']}}
end
@@ -967,9 +965,9 @@ module SiSU_CGI_SQL
output=title+text
else #elsif cgi['view']=~/index/ #% idx body
if c['suffix'] !~/1/ #seg
- index=%{<a href="#{path_filename(location,c['seg'],@ln)}##{c['ocn']}">#{c['ocn']}</a>, } if @text_search_flag
+ index=%{<a href="#{path_filename(location,c['seg'],c['language_document_char'])}##{c['ocn']}">#{c['ocn']}</a>, } if @text_search_flag
elsif c['suffix'] =~/1/ #doc #FIX
- index=%{<a href="#{path_html_doc(location,@ln)}##{c['ocn']}">#{c['ocn']}</a>, }
+ index=%{<a href="#{path_html_doc(location,c['language_document_char'])}##{c['ocn']}">#{c['ocn']}</a>, }
end
if c['seg'] =~/\S+/
if @text_search_flag
@@ -1015,7 +1013,7 @@ module SiSU_CGI_SQL
can_txt_srch=(cgi['view']=~/index/) \
? %{<a href="#{@canned_base_url}&fns=#{e['src_filename']}&lang=#{e['language_document_char']}&view=text"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a>&nbsp;}
: %{<a href="#{@canned_base_url}&fns=#{e['src_filename']}&lang=#{e['language_document_char']}&view=index"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a>&nbsp;}
- title=%{<br /><hr><span style="background-color: #{@color_heading}"><a href="#{path_toc(location,@ln)}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html">&nbsp;#{ti}</a></span> [#{e['language_document_char']}] by #{e['creator_author']} #{can_txt_srch}<a href="#{path_toc(location,@ln)}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"></a>&nbsp;<a href="#{path_manifest(location,@ln)}"><img border="0" width="15" height="15" src="#{@image_src}/b_info.png" alt="manifest"></a><br />} if file_suffix=~/s/
+ title=%{<br /><hr><span style="background-color: #{@color_heading}"><a href="#{path_toc(location,e['language_document_char'])}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html">&nbsp;#{ti}</a></span> [#{e['language_document_char']}] by #{e['creator_author']} #{can_txt_srch}<a href="#{path_toc(location,e['language_document_char'])}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"></a>&nbsp;<a href="#{path_manifest(location,e['language_document_char'])}"><img border="0" width="15" height="15" src="#{@image_src}/b_info.png" alt="manifest"></a><br />} if file_suffix=~/s/
@counter_endn_doc+=1
oldtid=e['metadata_tid'].to_i
else title = ''
@@ -1027,10 +1025,10 @@ module SiSU_CGI_SQL
&& @search_regx.to_s=~/\S\S+/) \
? (matched=e['body'].gsub(/(<a\s+href="https?:\/\/[^><\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{<span style="background-color: #{@color_match}">\\1</span>}))
: e['body']
- output=%{#{title}<hr><font size="2">note <b><a href="#{path_endnotes(location,@ln)}#_#{e['nr']}">#{e['nr']}</a></b> referred to from ocn <a href="#{path_html_doc(location,@ln)}##{e['ocn']}">#{e['ocn']}</a>:</font> #{matched_endnote}}
+ output=%{#{title}<hr><font size="2">note <b><a href="#{path_endnotes(location,e['language_document_char'])}#_#{e['nr']}">#{e['nr']}</a></b> referred to from ocn <a href="#{path_html_doc(location,e['language_document_char'])}##{e['ocn']}">#{e['ocn']}</a>:</font> #{matched_endnote}}
else #elsif cgi['view']=~/index/ #doc #FIX #% idx endnotes
@counter_endn_ocn+=1
- output=%{#{title}<a href="#{path_endnotes(location,@ln)}#_#{e['nr']}">#{e['nr']}</a> [&sect; <a href="#{path_html_doc(location,@ln)}##{e['ocn']}">#{e['ocn']}</a>], }
+ output=%{#{title}<a href="#{path_endnotes(location,e['language_document_char'])}#_#{e['nr']}">#{e['nr']}</a> [&sect; <a href="#{path_html_doc(location,e['language_document_char'])}##{e['ocn']}">#{e['ocn']}</a>], }
end
@counters_endn=if @counter_endn_doc > 0
if checked_stats =~/\S/
diff --git a/lib/sisu/v4/cgi_sqlite.rb b/lib/sisu/v4/cgi_sqlite.rb
index 8d15b4ee..6f8bc4cc 100644
--- a/lib/sisu/v4/cgi_sqlite.rb
+++ b/lib/sisu/v4/cgi_sqlite.rb
@@ -133,7 +133,7 @@ module SiSU_CGI_SQLite
require 'dbi'
@version='sisu_sqlite'
@image_src="#{@env.url.webserv_cgi}/_sisu/image_sys"
- @hosturl_db="#{@env.url.webserv_base_cgi}"
+ @hosturl_db="#{@env.url.webserv_base_cgi}/cgi-bin"
@hosturl_files="#{@env.url.webserv_files_from_db}"
@db_name_prefix="#{Db[:name_prefix]}"
WOK_SQL
diff --git a/lib/sisu/v4/dal.rb b/lib/sisu/v4/dal.rb
index b29bfd49..47d64ae7 100644
--- a/lib/sisu/v4/dal.rb
+++ b/lib/sisu/v4/dal.rb
@@ -95,12 +95,16 @@ module SiSU_DAL
@@fns=nil
def initialize(opt,fnx=nil)
@opt,@fnx=opt,fnx
- @@fns||@opt.fns
- @make_fns=if @fnx and @fnx =~/\.ss[tmi]$/
- SiSU_Env::InfoFile.new(@fnx)
+ @@fns ||=opt.fns
+ fn_use=if fnx \
+ and fnx =~/\.ss[tmi]$/
+ fnx
+ elsif opt.fns =~/\.ssm$/
+ opt.fns + '.sst'
else
- SiSU_Env::InfoFile.new(@opt.fns)
+ opt.fns
end
+ @make_fns=SiSU_Env::InfoFile.new(fn_use)
@fnm=@make_fns.marshal.dal_metadata
@fnc=@make_fns.marshal.dal_content
@idx_sst=@make_fns.marshal.dal_idx_sst_rel_html_seg
@@ -269,7 +273,7 @@ module SiSU_DAL
tell=(@opt.cmd=~/[vVM]/) \
? SiSU_Screen::Ansi.new(@opt.cmd,'Document Abstraction')
: SiSU_Screen::Ansi.new(@opt.cmd,'Document Abstraction',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}")
- tell.grey_title_hi
+ tell.blue_title_hi
end
fn=(@fnx && @fnx =~/\.ss[tmi]$/) \
? @fnx
diff --git a/lib/sisu/v4/db_import.rb b/lib/sisu/v4/db_import.rb
index 7a5b4fb6..199d4efa 100644
--- a/lib/sisu/v4/db_import.rb
+++ b/lib/sisu/v4/db_import.rb
@@ -84,7 +84,6 @@ module SiSU_DbImport
@md=SiSU_Param::Parameters.new(@opt).get
@md.fnb
end
- @suffix=@opt.fns[/(?:.+?)(?:\.ssm\.sst|\.-?sst)/,1]
@fnc="#{@dal}/#{@opt.fns}.content.rbm"
@@seg,@@seg_full='','' #create? consider placing field just before clean text as opposed to seg which contains seg(.html) name info seg_full would contain seg info for levels 5 & 6 where available eg seg_full may be 7.3 (level 5) and 7.3.1 (level 6) where seg is 7
@col=Hash.new('')
diff --git a/lib/sisu/v4/screen_text_color.rb b/lib/sisu/v4/screen_text_color.rb
index 06307154..86b41e6b 100644
--- a/lib/sisu/v4/screen_text_color.rb
+++ b/lib/sisu/v4/screen_text_color.rb
@@ -337,6 +337,9 @@ module SiSU_Screen
def green_hi_blue
puts %{#{@cX.green_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}}
end
+ def blue_title_hi
+ puts %{#{@cX.blue_hi}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}}
+ end
def grey_title_hi
puts %{#{@cX.grey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}}
end
diff --git a/lib/sisu/v4/sysenv.rb b/lib/sisu/v4/sysenv.rb
index 6ed94d5d..d77672a6 100644
--- a/lib/sisu/v4/sysenv.rb
+++ b/lib/sisu/v4/sysenv.rb
@@ -1668,8 +1668,6 @@ WOK
and defined? @rc['search']['sisu']['action'] \
and @rc['search']['sisu']['action'] =~/https?:\/\// \
and defined? @rc['search']['sisu']['db'] \
- and @rc['search']['sisu']['db'] =~/\S+/ \
- and defined? @rc['search']['sisu']['db'] \
and @rc['search']['sisu']['db'] =~/\S+/
flag=if defined? @vz.widget_search \
and @vz.widget_search==true
@@ -2394,7 +2392,7 @@ WOK
end
end
def webserv_cgi #web url for local webserv (localhost, or hostname)
- if defined? @rc['webserv_cgi']['host'] \
+ http=if defined? @rc['webserv_cgi']['host'] \
and @rc['webserv_cgi']['host'].is_a?(String)
http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') #check https? missing
if port.webserv_port_cgi
@@ -2408,9 +2406,10 @@ WOK
else "#{http}#{webserv_host_base}/#{@stub_pwd}"
end
end
+ http=http.strip
end
def webserv_base_cgi #web url for local webserv (localhost, or hostname)
- if defined? @rc['webserv_cgi']['host'] \
+ http=if defined? @rc['webserv_cgi']['host'] \
and @rc['webserv_cgi']['host'].is_a?(String)
http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://')
if port.webserv_port_cgi
@@ -2424,6 +2423,7 @@ WOK
else "#{http}#{webserv_host_base}"
end
end
+ http=http.strip
end
def webrick #must have a port #REMOVE
if defined? @rc['webserv_cgi']['host'] \
@@ -2479,12 +2479,13 @@ WOK
else webserv_base_cgi
end
end
- def sample_search_form_title
- if defined? @rc['search']['sisu']['title'] \
+ def sample_search_form_title(organised_by=:language)
+ title=if defined? @rc['search']['sisu']['title'] \
and @rc['search']['sisu']['title'] =~/\S+/
@rc['search']['sisu']['title']
- else %{(SiSU (generated sample) search form}
+ else %{SiSU (generated sample) search form}
end
+ title=title + " (content organised by #{organised_by})"
end
def output_tell #BROKEN Revisit 2011-02
output_type=if defined? @rc['show_output_on'] \