aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5/sysenv.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v5/sysenv.rb')
-rw-r--r--lib/sisu/v5/sysenv.rb131
1 files changed, 100 insertions, 31 deletions
diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb
index 25984397..edaec7f8 100644
--- a/lib/sisu/v5/sysenv.rb
+++ b/lib/sisu/v5/sysenv.rb
@@ -2383,7 +2383,7 @@ WOK
def po
"#{root}/po4a/po"
end
- def webserv_host_base
+ def webserv_host_base(opt=nil)
if defined? @rc['webserv']['host']
case @rc['webserv']['host']
when /https?:\/\//; @rc['webserv']['host']
@@ -2393,7 +2393,7 @@ WOK
else defaults[:webserv_host_cgi]
end
end
- def webserv_cgi #web url for local webserv (localhost, or hostname)
+ def webserv_cgi(opt=nil) #web url for local webserv (localhost, or hostname)
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
@@ -2403,25 +2403,28 @@ WOK
end
else
http=((webserv_host_base=~/https?:\/\//) ? '' : 'http://')
- if port.webserv_port_cgi
- "#{http}#{webserv_host_base}:#{port.webserv_port_cgi}/#{@stub_pwd}"
+ if port.webserv_port_cgi(opt)
+ "#{http}#{webserv_host_base}:#{port.webserv_port_cgi(opt)}/#{@stub_pwd}"
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)
- http=if defined? @rc['webserv_cgi']['host'] \
+ def webserv_base_cgi(opt=nil) #web url for local webserv (localhost, or hostname)
+ http=if opt.mod.inspect =~/--webserv-(?:cgi|db|search)[=-]["']?(\S+)["']+/
+ m=$1
+ (m=~/http\/\/:/) ? m : %{http://#{m}}
+ elsif 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
- "#{http}#{@rc['webserv_cgi']['host']}:#{port.webserv_port_cgi}"
+ if port.webserv_port_cgi(opt)
+ "#{http}#{@rc['webserv_cgi']['host']}:#{port.webserv_port_cgi(opt)}"
else "#{http}#{@rc['webserv_cgi']['host']}"
end
else
http=((webserv_host_base=~/https?:\/\//) ? '' : 'http://')
- if port.webserv_port_cgi
- "#{http}#{webserv_host_base}:#{port.webserv_port_cgi}"
+ if port.webserv_port_cgi(opt)
+ "#{http}#{webserv_host_base}:#{port.webserv_port_cgi(opt)}"
else "#{http}#{webserv_host_base}"
end
end
@@ -2469,16 +2472,39 @@ WOK
else "#{url.webrick_base}"
end
end
- def webserv_files_from_db #sort this out, messy
- if defined? @rc['webserv_cgi']['file_links']
- case @rc['webserv_cgi']['file_links']
- when /webserv_cgi/; url.webserv_base_cgi
+ def webserv_files_from_db(opt=nil) #sort this out, messy
+ if opt.mod.inspect =~/--webserv-output[=-]["']?(\S+)["']+/
+ m=$1
+ (m=~/(?:http|file\/)\/\/:/) ? m : %{http://#{m}}
+ else
+ show_output_on=if defined? @rc['webserv_cgi']['show_output_on']
+ @rc['webserv_cgi']['show_output_on']
+ elsif defined? @rc['webserv_cgi']['file_links']
+ @rc['webserv_cgi']['file_links']
+ else ''
+ end
+ m=case show_output_on
+ when /webserv_cgi/; url.webserv_base_cgi(opt)
when /webserv/; @rc['webserv']['url_root']
when /https?:\/\//; @rc['webserv_cgi']['file_links']
when /\S+/; "http://#{@rc['webserv_cgi']['file_links']}"
- else webserv_base_cgi
+ else webserv_base_cgi(opt)
end
- else webserv_base_cgi
+ end
+ end
+ def cgi_sample_search_form_name(opt=nil)
+ if opt.mod.inspect =~/--(?:cgi-)?search-form-name[=-]["']?(\S+?\.cgi)/
+ m=$1
+ elsif not (opt.mod.inspect =~/--db[=-]["']?sqlite/) \
+ and defined? @rc['search'] \
+ and defined? @rc['search']['sisu'] \
+ and defined? @rc['search']['sisu']['action'] \
+ and @rc['search']['sisu']['action'] =~/https?:\/\/\S+?\.cgi/
+ x=/(?:https?:\/\/\S+?)\/([^\/]+?\.cgi)$/.match(@rc['search']['sisu']['action'])[1]
+ else
+ (opt.mod.inspect =~/--db[=-]["']?sqlite/) \
+ ? 'sisu_sqlite.cgi' \
+ : 'sisu_pgsql.cgi'
end
end
def sample_search_form_title(organised_by=:language)
@@ -2569,24 +2595,29 @@ WOK
end
end
end
- def webserv_port_cgi
- if @md \
- and defined? @md.opt \
- and @md.opt.cmd.inspect=~/-F/ \
- and @md.opt.mod.inspect=~/port=(\d+)/
+ def webserv_port_cgi(opt=nil)
+ port=if opt \
+ and opt.cmd.inspect=~/-F/ \
+ and opt.mod.inspect=~/port=(\d+)/
$1
else
- if defined? @rc['webserv_cgi']['port']
+ port=if defined? @rc['webserv_cgi']['port']
if @rc['webserv_cgi']['port'].nil? \
- and (defined? @md.opt.mod \
- and not @md.opt.mod.nil? \
- and @md.opt.mod.inspect=~/webrick/)
+ and (defined? opt.mod \
+ and not opt.mod.nil? \
+ and opt.mod.inspect=~/webrick/)
defaults[:webserv_port_cgi]
elsif not @rc['webserv_cgi']['port'].nil?
@rc['webserv_cgi']['port']
else nil
end
- else nil
+ else
+ if (defined? opt.mod \
+ and not opt.mod.nil? \
+ and opt.mod.inspect=~/webrick/)
+ defaults[:webserv_port_cgi]
+ else nil
+ end
end
end
end
@@ -3548,6 +3579,38 @@ WOK
%x{ruby -v}.strip
end
end
+ class InfoAbout
+ def initialize(color='')
+ @color=color
+ end
+ def sisu_version
+ version=SiSU_Env::InfoVersion.instance.get_version
+ rb_ver=SiSU_Env::InfoVersion.instance.rbversion
+ if version[:version]
+ opt_cmd=if defined? @color.cmd \
+ and @color.cmd =~/[ck]/
+ @color.cmd
+ else '-v'
+ end
+ SiSU_Screen::Ansi.new(opt_cmd,version[:project],version[:version],version[:date_stamp],version[:date],rb_ver).version
+ else puts 'SiSU version information not available'
+ end
+ end
+ def sisu_about
+ puts <<-WOK
+ sisu: documents; markup, structuring, publishing in multiple standard formats, & search
+ most (not all) useful commands (are made in a directory containing a sisu markup file &) take the form:
+ sisu [action(s)] [filename(s)]
+ where filename refers to a valid sisu marked up file, e.g.:
+ cd /usr/share/doc/sisu/markup-samples/sisu_manual
+ sisu --html --verbose sisu_commands.sst
+ sisu --txt --html --epub --odt --pdf --sqlite --manpage --texinfo --concordance --qrcode --verbose sisu.ssm
+ cd -
+ See output produced, or see man pages: man sisu
+ <http://www.sisudoc.org/> <http://www.jus.uio.no/sisu/>
+ WOK
+ end
+ end
class InfoFile <InfoEnv #todo unify with FileOp
def initialize(fns)
begin
@@ -4004,11 +4067,17 @@ WOK
self
end
def psql
- def user
- ((defined? @rc['db']['postgresql']['user']) \
- && @rc['db']['postgresql']['user']=~/\S+/) \
- ? @rc['db']['postgresql']['user']
- : @env.user
+ def user(opt)
+ if opt.mod.inspect =~/--db-user[=-]["']?(\S+)["']+/
+ m=$1
+ elsif opt.mod =~/--webserv[=-]webrick/
+ @env.user
+ else
+ ((defined? @rc['db']['postgresql']['user']) \
+ && @rc['db']['postgresql']['user']=~/\S+/) \
+ ? @rc['db']['postgresql']['user']
+ : @env.user
+ end
end
def db #db_name
"#{Db[:name_prefix]}#{@pwd_stub}"