aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2013-05-30 23:11:23 -0400
committerRalph Amissah <ralph@amissah.com>2013-05-30 23:11:23 -0400
commit134766702ce7c3ec220e9c07cd26aa6a1bf60776 (patch)
treea621ea0776f6fa62606e890d4b7e00fc01316c8e /lib/sisu/v5
parentdebian/changelog (4.1.2-1) (diff)
parentv4 v5: cgi_pgsql, cgi helper script sample search form generator, detail (diff)
Merge tag 'sisu_4.1.3' into debian/sid
SiSU 4.1.3
Diffstat (limited to 'lib/sisu/v5')
-rw-r--r--lib/sisu/v5/cgi_pgsql.rb37
-rw-r--r--lib/sisu/v5/sysenv.rb8
2 files changed, 20 insertions, 25 deletions
diff --git a/lib/sisu/v5/cgi_pgsql.rb b/lib/sisu/v5/cgi_pgsql.rb
index 45a4aae9..9ae9d191 100644
--- a/lib/sisu/v5/cgi_pgsql.rb
+++ b/lib/sisu/v5/cgi_pgsql.rb
@@ -73,11 +73,6 @@ module SiSU_CGI_PgSQL
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
@name_of[:output_dir_structure]=if defined? @rc['output_dir_structure_by'] \
and defined? @rc['output_dir_structure_by'] =~/(language|filetype|filename)/
@rc['output_dir_structure_by']
@@ -90,20 +85,18 @@ module SiSU_CGI_PgSQL
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]=/(https?:\/\/\S+?)\/(?:[^\/]+?)\.cgi$/.match(@rc['search']['sisu']['action'])[1]
else
- @name_of[:host_url_docs]=@env.url.webserv_files_from_db(@opt)
@name_of[:db]=@env.path.stub_pwd #'sisu' #breaks if not present
- @name_of[:host_url_cgi]=@env.url.webserv_base_cgi(@opt)
false
end
+ @name_of[:host_url_cgi]="#{@env.url.webserv_base_cgi(@opt)}/cgi-bin"
+ @name_of[:host_url_docs]=@env.url.webserv_files_from_db(@opt)
@name_of[:cgi_script]=@env.url.cgi_sample_search_form_name(@opt)
+ @name_of[:user]=@db.psql.user(@opt)
@cgi_file_name="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by.to_s}_pgsql.cgi"
@cgi_link_name=@name_of[:cgi_script] #sisu_pgsql.cgi,
@image_src="#{@env.url.webserv_base_cgi(@opt)}/_sisu/image_sys"
@common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env)
- @user=@db.psql.user(@opt)
end
def pgsql
serve=[]
@@ -130,14 +123,14 @@ module SiSU_CGI_PgSQL
puts <<-WOK
generated sample search form: #{@cX.green}#{@cgi_file_name}#{@cX.off}
default database name: #{@cX.green}#{Db[:name_prefix]}#{@name_of[:db]}#{@cX.off} (#{@name_of[:db]})
- db user: #{@cX.green}#{@db.psql.user(@opt)}#{@cX.off}
- to modify use: #{@cX.brown}sisu --db-pg --db-user='#{@db.psql.user(@opt)}'#{@cX.off}
- cgi & db host on: #{@cX.blue}#{@env.url.webserv_base_cgi(@opt)}#{@cX.off}
- to modify use: #{@cX.brown}sisu --db-pg --webserv-search='#{@env.url.webserv_base_cgi(@opt)}'#{@cX.off}
- sisu output on: #{@cX.blue}#{@env.url.webserv_files_from_db(@opt)}#{@cX.off}
- to modify use: #{@cX.brown}sisu --db-pg --webserv-output='#{@env.url.webserv_files_from_db(@opt)}'#{@cX.off}
- cgi search form link name: #{@cX.green}#{@env.url.cgi_sample_search_form_name(@opt)}#{@cX.off}
- to modify use: #{@cX.brown}sisu --db-pg --cgi-search-form-name='#{@env.url.cgi_sample_search_form_name(@opt)}'#{@cX.off}
+ db user: #{@cX.green}#{@name_of[:user]}#{@cX.off}
+ to modify use: #{@cX.brown}sisu --db-pg --db-user='#{@name_of[:user]}'#{@cX.off}
+ cgi & db host on: #{@cX.blue}#{@name_of[:host_url_cgi]}#{@cX.off}
+ to modify use: #{@cX.brown}sisu --db-pg --webserv-search='#{@name_of[:host_url_cgi]}'#{@cX.off}
+ sisu output on: #{@cX.blue}#{@name_of[:host_url_docs]}#{@cX.off}
+ to modify use: #{@cX.brown}sisu --db-pg --webserv-output='#{@name_of[:host_url_docs]}'#{@cX.off}
+ cgi search form link name: #{@cX.green}#{@name_of[:cgi_script]}#{@cX.off}
+ to modify use: #{@cX.brown}sisu --db-pg --cgi-search-form-name='#{@name_of[:cgi_script]}'#{@cX.off}
#{@cX.fuschia}(settings priority: command line; sisurc.yml; else defaults)#{@cX.off}
#{@cX.fuschia}BASED ON ALREADY EXISTING databases#{@cX.off} (default database name: #{@db.psql.db})
@@ -206,13 +199,13 @@ module SiSU_CGI_PgSQL
require 'dbi'
@stub_default='#{@name_of[:db]}'
@image_src='#{@image_src}'
- @hosturl_cgi='#{@env.url.webserv_base_cgi(@opt)}/cgi-bin'
- @hosturl_files='#{@env.url.webserv_files_from_db(@opt)}'
+ @hosturl_cgi='#{@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='#{@user}' # check user name for access to pg database: e.g. www-data or '#{@env.user}'
- @base='#{@name_of[:host_url_cgi]}/cgi-bin/#{@name_of[:cgi_script]}.cgi' #fix sqlite
+ @user='#{@name_of[:user]}' # check user name for access to pg database: e.g. www-data or '#{@env.user}'
+ @base='#{@name_of[:host_url_cgi]}/#{@name_of[:cgi_script]}'
WOK_SQL
end
def search_statement
diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb
index edaec7f8..37492716 100644
--- a/lib/sisu/v5/sysenv.rb
+++ b/lib/sisu/v5/sysenv.rb
@@ -4067,10 +4067,12 @@ WOK
self
end
def psql
- def user(opt)
- if opt.mod.inspect =~/--db-user[=-]["']?(\S+)["']+/
+ def user(opt=nil)
+ x=if opt \
+ and opt.mod.inspect =~/--db-user[=-]["']?(\S+)["']+/
m=$1
- elsif opt.mod =~/--webserv[=-]webrick/
+ elsif opt \
+ and opt.mod =~/--webserv[=-]webrick/
@env.user
else
((defined? @rc['db']['postgresql']['user']) \