aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/sysenv.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3/sysenv.rb')
-rw-r--r--lib/sisu/v3/sysenv.rb1318
1 files changed, 940 insertions, 378 deletions
diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb
index 16dabd36..4383a893 100644
--- a/lib/sisu/v3/sysenv.rb
+++ b/lib/sisu/v3/sysenv.rb
@@ -65,7 +65,7 @@ module SiSU_Env
include FileUtils::Verbose
require 'singleton'
@@noyaml=false
- class Info_date
+ class InfoDate
require 'date'
attr_accessor :dt,:t
def initialize
@@ -91,7 +91,7 @@ module SiSU_Env
'2012'
end
end
- class Info_system
+ class InfoSystem
require 'rbconfig'
include Singleton
@@user,@@home,@@hostname,@@pwd,@@sisu_etc,@@host,@@arch,@@rbver,@@dir_arch,@@dir_sitearch,@@dir_bin,@@locale,@@rc,@@sisurc_path,@@ad=ENV['USER'],ENV['HOME'],ENV['HOSTNAME'],ENV['PWD'],Config::CONFIG['sysconfdir'] + '/sisu',Config::CONFIG['host'],Config::CONFIG['arch'],%x{ruby -v}.strip,Config::CONFIG['archdir'],Config::CONFIG['sitearchdir'],Config::CONFIG['bindir'],%x{locale charmap}.strip,nil,nil,{} # %x{ruby -v}.strip # Config::CONFIG['rb_ver']
@@ -241,7 +241,7 @@ module SiSU_Env
def initialize
@user,@home,@hostname,@pwd,@sisu_etc,@host,@arch,@rbver,@dir_arch,@dir_sitearch,@dir_bin,@locale,@default_dir,@rc_path,@yamlrc_path,@ad_path=\
@@user,@@home,@@hostname,@@pwd,@@sisu_etc,@@host,@@arch,@@rbver,@@dir_arch,@@dir_sitearch,@@dir_bin,@@locale,@@default_dir,@@rc_path,@@yamlrc_path,@@ad_path
- #note rbver is duplicated in Info_version
+ #note rbver is duplicated in InfoVersion
end
end
class Load
@@ -280,7 +280,7 @@ module SiSU_Env
load_prog
end
end
- class Get_init < Info_system
+ class GetInit < InfoSystem
include Singleton
@@noyaml=false
@@rc,@@sisurc_path,@@vz,@@tx=nil,nil,nil,nil
@@ -373,16 +373,16 @@ module SiSU_Env
@@ad
end
end
- class Env_call
+ class EnvCall
@@rc,@@fns,@@fnn,@@fnb,@@fnt,@@flv,@@fnz=nil,nil,nil,nil,nil,nil,nil
@@ad={}
attr_accessor :rc,:fnn,:fnb,:fnt,:fnv,:fnz,:ad
def initialize(fns='')
super()
@fns=fns
- @sys=Info_system.instance
- @rc=Get_init.instance.sisu_yaml.rc
- @ad=Get_init.instance.ads
+ @sys=InfoSystem.instance
+ @rc=GetInit.instance.sisu_yaml.rc
+ @ad=GetInit.instance.ads
if @fns \
and @fns != '' \
and @fns !=@@fns
@@ -405,56 +405,62 @@ module SiSU_Env
@fnn,@fnb,@fnt,@flv,@fnz=@@fnn,@@fnb,@@fnt,@@flv,@@fnz
end
def output_dir_structure
- def by_language_code?
- x=if defined? @rc['output_dir_structure_by'] \
- and @rc['output_dir_structure_by'] =~/language/
- true
- elsif defined? @rc['output_structure']['by_language'] \
- and @rc['output_structure']['by_language'] ==true
- true
- else false
+ def by?
+ output_structure=:filename #set default output structure
+ output_structure=if defined? @rc['output_dir_structure_by']
+ output_structure=if (@rc['output_dir_structure_by'] =~/dump/) \
+ or ((defined? @rc['output_structure']['dump']) \
+ && @rc['output_structure']['dump'] ==true)
+ :dump
+ elsif (@rc['output_dir_structure_by'] =~/redirect/) \
+ or ((defined? @rc['output_structure']['redirect']) \
+ && @rc['output_structure']['redirect'] ==true)
+ :redirect
+ elsif (@rc['output_dir_structure_by'] =~/language/) \
+ or ((defined? @rc['output_structure']['by_language']) \
+ && @rc['output_structure']['by_language'] ==true)
+ :language
+ elsif (@rc['output_dir_structure_by'] =~/filetype/) \
+ or ((defined? @rc['output_structure']['by_filetype']) \
+ && @rc['output_structure']['by_filetype'] ==true)
+ :filetype
+ elsif (@rc['output_dir_structure_by'] =~/filename/) \
+ or ((defined? @rc['output_structure']['by_filename']) \
+ && @rc['output_structure']['by_filename'] ==true)
+ :filename
+ else #recheck current default
+ :language
+ end
end
end
+ def dump?
+ ((by?) ==:dump) \
+ ? true
+ : false
+ end
+ def redirect?
+ ((by?) ==:redirect) \
+ ? true
+ : false
+ end
+ def by_language_code?
+ ((by?) ==:language) \
+ ? true
+ : false
+ end
def by_filetype?
- x=if by_language_code?
- false
- elsif defined? @rc['output_dir_structure_by'] \
- and @rc['output_dir_structure_by'] =~/filetype/
- true
- elsif defined? @rc['output_structure']['by_filetype'] \
- and @rc['output_structure']['by_filetype'] ==true
- true
- else false
- end
+ ((by?) ==:filetype) \
+ ? true
+ : false
end
def by_filename?
- x=if by_language_code?
- false
- elsif by_filetype?
- false
- elsif defined? @rc['output_dir_structure_by'] \
- and @rc['output_dir_structure_by'] =~/filename/
- true
- elsif defined? @rc['output_structure']['by_filename'] \
- and @rc['output_structure']['by_filename'] ==true
- true
- else true
- end
+ ((by?) ==:filename) \
+ ? true
+ : false
end
def multilingual?
by_language_code?
end
- def by?
- by=if by_language_code?
- 'language'
- elsif by_filetype?
- 'filetype'
- elsif by_filename?
- 'filename'
- else
- 'filename'
- end
- end
self
end
def document_language_versions_found #REVISIT
@@ -472,8 +478,8 @@ module SiSU_Env
@fn[:t]=filename[m,2]
end
end
- lng_base=Info_env.new.language_default_set
- lang=SiSU_Env::Standardise_language.new
+ lng_base=SiSU_Env::InfoEnv.new.language_default_set
+ lang=SiSU_Env::StandardiseLanguage.new
langs=lang.codes
x=[]
if FileTest.file?("#{@fn[:m]}.#{@fn[:t]}")
@@ -483,7 +489,7 @@ module SiSU_Env
end
#x << { f: "#{@fns}", l: lng_base }
langs.each do |l|
- lng=SiSU_Env::Standardise_language.new(l)
+ lng=SiSU_Env::StandardiseLanguage.new(l)
if FileTest.file?("#{@fn[:m]}~#{lng.code}.#{@fn[:t]}")
x << { f: "#{@fn[:m]}~#{lng.code}.#{@fn[:t]}", l: lng.code }
elsif FileTest.file?("#{@fn[:m]}~#{lng.name}.#{@fn[:t]}")
@@ -521,34 +527,33 @@ module SiSU_Env
@fn[:t]=@fns[m,2]
end
end
- lang=SiSU_Env::Standardise_language.new
+ lang=SiSU_Env::StandardiseLanguage.new
langs=lang.codes
x=[]
if FileTest.file?("#{@fn[:m]}.#{@fn[:t]}"); x << "#{@fn[:m]}.#{@fn[:t]}"
end
- dir=SiSU_Env::Info_env.new(@fns)
+ dir=SiSU_Env::InfoEnv.new(@fns)
@m << { m: 'sisu_manifest.html', l: 'English' } #fix later, default language
langs.each do |l|
- lng=SiSU_Env::Standardise_language.new(l)
+ lng=SiSU_Env::StandardiseLanguage.new(l)
fns_c="#{@fn[:m]}~#{lng.code}.#{@fn[:t]}"
fns_l="#{@fn[:m]}~#{lng.name}.#{@fn[:t]}"
if FileTest.file?(fns_c)
- fn_set_lang=SiSU_Env::Standardise_language.new.file_to_language(fns_c) #reconsider file_to_language
+ fn_set_lang=SiSU_Env::StandardiseLanguage.new.file_to_language(fns_c) #reconsider file_to_language
lng=fn_set_lang[:n]
- fn=SiSU_Env::Env_call.new(fns_c).lang(fn_set_lang[:c])
+ fn=SiSU_Env::EnvCall.new(fns_c).lang(fn_set_lang[:c])
@m << { m: fn[:manifest], l: lng }
elsif FileTest.file?(fns_l)
- fn_set_lang=SiSU_Env::Standardise_language.new.file_to_language(fns_l) #reconsider file_to_language
+ fn_set_lang=SiSU_Env::StandardiseLanguage.new.file_to_language(fns_l) #reconsider file_to_language
@fnl=dir.i18n.lang_filename(fn_set_lang[:c])
- fn=SiSU_Env::Env_call.new(fns_l).lang(fn_set_lang[:c])
+ fn=SiSU_Env::EnvCall.new(fns_l).lang(fn_set_lang[:c])
@m << { m: fn[:manifest], l: lng }
end
end
- @m.uniq!
- @m
+ @m=@m.uniq
end
def filename(code,name,suffix)
- #d=SiSU_Env::Info_env.new(@fns)
+ #d=SiSU_Env::InfoEnv.new(@fns)
#fnl=d.i18n.lang_filename(code)
"#{name}#{suffix}"
#if code
@@ -604,15 +609,15 @@ module SiSU_Env
@fn
end
end
- class System_call
+ class SystemCall
@@locale_flag=false
def initialize(input='',output='',cmd='')
@input,@output,@cmd=input,output,cmd
- @prog=SiSU_Env::Info_program.new
- @sys=Info_system.instance
+ @prog=SiSU_Env::InfoProgram.new
+ @sys=InfoSystem.instance
end
def program_found?(program)
- found=`whereis #{program}`
+ found=`which #{program}` #`whereis #{program}`
(found =~/bin\/#{program}\b/) ? true : false
end
def locale #locales utf8 or other
@@ -623,10 +628,10 @@ module SiSU_Env
end
def file_encoding(filename,cmd='') #file encoding
program='file'
- fnsp=Info_env.new(filename).source_file_with_path
+ fnsp=SiSU_Env::InfoEnv.new(filename).source_file_with_path
if program_found?(program)
encoding=%x{file -L #{fnsp}}.strip
- encoding.gsub!(/#{fnsp}:(\s+|$)/,'')
+ encoding=encoding.gsub(/#{fnsp}:(\s+|$)/,'')
encoding=if encoding \
and not encoding.empty?
encoding
@@ -799,9 +804,10 @@ module SiSU_Env
end
def makeinfo #texinfo
program='makeinfo'
+ options='' #'--force' #''
program_ref="\n\t\tsee http://www.gnu.org/software/texinfo/"
(program_found?(program)) \
- ? system("#{program} #{@input}\n")
+ ? system("#{program} #{options} #{@input}\n")
: (puts "\tWARN: #{program} is not installed #{program_ref}")
end
def scp
@@ -846,11 +852,11 @@ module SiSU_Env
end
end
end
- class Standardise_language
+ class StandardiseLanguage
require_relative 'i18n' # i18n.rb
def initialize(l='')
@language=(l.nil? || l.empty?) \
- ? Info_env.new.language_default_set
+ ? SiSU_Env::InfoEnv.new.language_default_set
: l
@r=%{(?:#{Px[:lng_lst].join('|')})}
@lang_info=SiSU_i18n::Languages.new
@@ -962,7 +968,7 @@ module SiSU_Env
Px[:lng_lst] # constants.rb
end
end
- class Info_env < Env_call
+ class InfoEnv < EnvCall
require 'pathname'
require 'fileutils'
include FileUtils
@@ -972,7 +978,7 @@ module SiSU_Env
def initialize(fns='',md=nil)
super() #you may not want to re-execute this static info so frequently!
@fns,@md=fns,md
- @env=Env_call.new(fns) if fns
+ @env=SiSU_Env::EnvCall.new(fns) if fns
fnb=if @md \
and defined? @md.fnb
@md.fnb
@@ -986,7 +992,7 @@ module SiSU_Env
end
if fnb; @@fb ||=fnb
end
- @sys=Info_system.instance
+ @sys=InfoSystem.instance
@fnb ||=@@fb #clean up this... used primarily for zap which is not passed normal parameters
@fixed_websev_root='' # @home
@pwd=@@pwd=Dir.pwd
@@ -1116,10 +1122,9 @@ module SiSU_Env
FileUtils::rm_rf(spp)
end
paths=[]
- flv=Env_call.new(opt.fns).document_language_versions_found
+ flv=SiSU_Env::EnvCall.new(opt.fns).document_language_versions_found
flv[:f].each {|l| lng_dirs << l[:l] }
- lng_dirs.uniq!
- lng_dirs.each do |lng|
+ lng_dirs.uniq.each do |lng|
paths << "#{spp}/doc/#{lng}"
end
paths \
@@ -1189,12 +1194,174 @@ module SiSU_Env
end
end
def manifest_minitoc?
- flag=if defined? @rc['manifest']['minitoc'] \
- and not @rc['manifest']['minitoc'].nil?
+ flag=if (defined? @rc['manifest']['minitoc'] \
+ and not @rc['manifest']['minitoc'].nil?)
@rc['manifest']['minitoc']
else false
end
end
+ def build
+ def omit_list
+ @off_list ||=if (defined? @rc['omit_list'] \
+ and not @rc['omit_list'].nil?)
+ @rc['omit_list']
+ elsif (defined? @rc['omit']['list'] \
+ and not @rc['omit']['list'].nil?)
+ @rc['omit']['list']
+ else
+ nil
+ end
+ end
+ def listed?(test) #fix
+ listed=if omit_list
+ x=(omit_list.scan(/\b#{test}\b/)).join
+ test==x \
+ ? true
+ : false
+ else
+ false
+ end
+ listed
+ end
+ def ocn?
+ if (defined? @rc['omit']['ocn'] \
+ and not @rc['omit']['ocn'].nil?) \
+ or listed?('ocn')
+ :off
+ else
+ :na
+ end
+ end
+ def toc?
+ if (defined? @rc['omit']['toc'] \
+ and not @rc['omit']['toc'].nil?) \
+ or listed?('toc')
+ :off
+ else
+ :na
+ end
+ end
+ def manifest?
+ if (defined? @rc['omit']['manifest'] \
+ and not @rc['omit']['manifest'].nil?) \
+ or listed?('manifest')
+ :off
+ else
+ :na
+ end
+ end
+ def links_to_manifest?
+ flag=if (defined? @rc['omit']['links_to_manifest'] \
+ and not @rc['omit']['links_to_manifest'].nil?) \
+ or (listed?('links_to_manifest') \
+ || listed?('manifest_links'))
+ :off
+ else
+ :na
+ end
+ end
+ def metadata?
+ if (defined? @rc['omit']['metadata'] \
+ and not @rc['omit']['metadata'].nil?) \
+ or listed?('metadata')
+ :off
+ else
+ :na
+ end
+ end
+ def minitoc?
+ flag=if (defined? @rc['omit']['minitoc'] \
+ and not @rc['omit']['minitoc'].nil?) \
+ or (listed?('minitoc'))
+ :off
+ else
+ :na
+ end
+ end
+ def manifest_minitoc?
+ flag=if (defined? @rc['omit']['manifest_minitoc'] \
+ and not @rc['omit']['manifest_minitoc'].nil?) \
+ or listed?('manifest_minitoc')
+ :off
+ else
+ :na
+ end
+ end
+ def html_minitoc?
+ flag=if (defined? @rc['omit']['html_minitoc'] \
+ and not @rc['omit']['html_minitoc'].nil?) \
+ or (listed?('html_minitoc') \
+ || listed?('minitoc'))
+ :off
+ else
+ :na
+ end
+ end
+ def html_navigation?
+ flag=if (defined? @rc['omit']['html_navigation'] \
+ and not @rc['omit']['html_navigation'].nil?) \
+ or listed?('html_navigation')
+ :off
+ else
+ :na
+ end
+ end
+ def html_navigation_bar?
+ flag=if (defined? @rc['omit']['html_navigation_bar'] \
+ and not @rc['omit']['html_navigation_bar'].nil?) \
+ or listed?('html_navigation_bar')
+ :off
+ else
+ :na
+ end
+ end
+ def segsubtoc?
+ flag=if (defined? @rc['omit']['segsubtoc'] \
+ and not @rc['omit']['segsubtoc'].nil?) \
+ or listed?('segsubtoc')
+ :off
+ else
+ :na
+ end
+ end
+ def html_right_pane?
+ flag=if (defined? @rc['omit']['html_right_pane'] \
+ and not @rc['omit']['html_right_pane'].nil?) \
+ or listed?('html_right_pane')
+ :off
+ else
+ :na
+ end
+ end
+ def html_top_band?
+ flag=if (defined? @rc['omit']['html_top_band'] \
+ and not @rc['omit']['html_top_band'].nil?) \
+ or listed?('html_top_band')
+ :off
+ else
+ :na
+ end
+ end
+ def search_form? #decide later, as is configured here (in sisurc) and can be turned off on command line
+ flag=if (defined? @rc['omit']['search_form'] \
+ and not @rc['omit']['search_form'].nil?) \
+ or listed?('search_form')
+ :off
+ else
+ :na
+ end
+ end
+ def html_search_form? #decide later, as is configured here (in sisurc) and can be turned off on command line
+ flag=if (defined? @rc['omit']['html_search_form'] \
+ and not @rc['omit']['html_search_form'].nil?) \
+ or listed?('html_search_form')
+ :off
+ else
+ :na
+ end
+ end
+ self
+ end
def odt_ocn?
((defined? @rc['odt']['ocn']) \
&& @rc['odt']['ocn']==true) \
@@ -1208,9 +1375,9 @@ module SiSU_Env
: false
end
def widget #needs (md) #move
- @rc=SiSU_Env::Get_init.instance.sisu_yaml.rc
- @ad=SiSU_Env::Get_init.instance.ads
- @vz=SiSU_Env::Get_init.instance.skin
+ @rc=SiSU_Env::GetInit.instance.sisu_yaml.rc
+ @ad=SiSU_Env::GetInit.instance.ads
+ @vz=SiSU_Env::GetInit.instance.skin
@flag={ ad: false, md: false, sk: false, rc: false }
def promo?
@flag[:ad]=if @md.flag_promo && @ad[:flag_promo]
@@ -1283,7 +1450,7 @@ module SiSU_Env
end
end
def search_form(type='sisusearch',action=nil,db=nil,table=false)
- rc=SiSU_Env::Get_init.instance.sisu_yaml.rc
+ rc=SiSU_Env::GetInit.instance.sisu_yaml.rc
create_form_sisu=if action \
and db \
and action =~/https?:\/\// \
@@ -1339,7 +1506,7 @@ WOK
form
end
def search_form_static(action=nil,db=nil)
- rc=SiSU_Env::Get_init.instance.sisu_yaml.rc
+ rc=SiSU_Env::GetInit.instance.sisu_yaml.rc
create_form=if rc['search']['sisu']['flag']==true \
and action \
and db \
@@ -1387,8 +1554,8 @@ WOK
self
end
def widget_static
- @rc=SiSU_Env::Get_init.instance.sisu_yaml.rc
- @vz=SiSU_Env::Get_init.instance.skin
+ @rc=SiSU_Env::GetInit.instance.sisu_yaml.rc
+ @vz=SiSU_Env::GetInit.instance.skin
@flag={ ad: false, md: false, sk: false, rc: false }
def search?
flag=if defined? @rc['search'] \
@@ -1435,7 +1602,7 @@ WOK
end
end
def search_form(action=nil,db=nil)
- rc=SiSU_Env::Get_init.instance.sisu_yaml.rc
+ rc=SiSU_Env::GetInit.instance.sisu_yaml.rc
create_form=if defined? rc['search']['sisu']['flag'] \
and rc['search']['sisu']['flag']==true \
and action \
@@ -1584,7 +1751,12 @@ WOK
end
end
def default_output_css
- if @env.output_dir_structure.by_language_code?
+ if (@md.opt.opt_act[:dump][:bool] \
+ && @md.opt.opt_act[:dump][:inst]) \
+ || (@md.opt.opt_act[:redirect][:bool] \
+ && @md.opt.opt_act[:redirect][:inst])
+ './'
+ elsif @env.output_dir_structure.by_language_code?
'../../'
elsif @env.output_dir_structure.by_filetype?
'../'
@@ -1626,7 +1798,7 @@ WOK
@sys.home
end
def sisurc_path
- Get_init.instance.sisu_yaml.rc_path
+ GetInit.instance.sisu_yaml.rc_path
end
def pwd
@sys.pwd
@@ -1680,7 +1852,14 @@ WOK
defaults[:sisu_share]
end
def style
- defaults[:stylesheet_stub]
+ if (@md.opt.opt_act[:dump][:bool] \
+ && @md.opt.opt_act[:dump][:inst]) \
+ || (@md.opt.opt_act[:redirect][:bool] \
+ && @md.opt.opt_act[:redirect][:inst])
+ 'css'
+ else
+ defaults[:stylesheet_stub]
+ end
end
def sample_data #sample data repository source directory
defaults[:sample_data_path]
@@ -1689,7 +1868,7 @@ WOK
@sys.rc_path
end
def yamlrc
- Get_init.instance.sisu_yaml.rc_path
+ GetInit.instance.sisu_yaml.rc_path
end
def man #check use
(defined? @rc['webserv']['man']) \
@@ -2437,7 +2616,7 @@ WOK
elsif conf; @rc['default']['language'] #3 config: from sisurc.yaml
else defaults[:language] #4 sisu: program default
end #1 document: param gets
- SiSU_Env::Standardise_language.new(l)
+ SiSU_Env::StandardiseLanguage.new(l)
end
#def multilingual
# x=(defined? @rc['output_structure']['multilingual'] \
@@ -2511,7 +2690,7 @@ WOK
end
if f_pod \
&& FileTest.file?(f_pod)
- tree=(SiSU_Env::System_call.new.program_found?('tree')) \
+ tree=(SiSU_Env::SystemCall.new.program_found?('tree')) \
? "tree #{processing_path.processing}/sisupod"
: ''
if FileTest.directory?(processing_path.processing)
@@ -2541,10 +2720,10 @@ WOK
sisupod_processing_path
end
end
- class Info_processing_flag
+ class InfoProcessingFlag
attr_accessor :color,:cf_0,:cf_1,:cf_2,:cf_3,:cf_4,:cf_5
def initialize
- @rc=Get_init.instance.sisu_yaml.rc
+ @rc=GetInit.instance.sisu_yaml.rc
end
def color #processing flag shortcuts
(defined? @rc['flag']['color']) ? @rc['flag']['color'] : false
@@ -2554,7 +2733,7 @@ WOK
and not (@rc['flag']['default'].nil? \
or @rc['flag']['default'].empty?)
@rc['flag']['default']
- else '-NQhewpotbxXyYv'
+ else '-NQhewpotbxXdyYv'
end
end
def cf_1 #processing flag shortcuts
@@ -2570,7 +2749,7 @@ WOK
and not (@rc['flag']['ii'].nil? \
or @rc['flag']['ii'].empty?)
@rc['flag']['ii']
- else '-NQhewpotbxXy'
+ else '-NQhewpotbxXdy'
end
end
def cf_3 #processing flag shortcuts
@@ -2578,7 +2757,7 @@ WOK
and not (@rc['flag']['iii'].nil? \
or @rc['flag']['iii'].empty?)
@rc['flag']['iii']
- else '-NQhewpotbxXyY'
+ else '-NQhewpotbxXdyY'
end
end
def cf_4 #processing flag shortcuts
@@ -2586,7 +2765,7 @@ WOK
and not (@rc['flag']['iv'].nil? \
or @rc['flag']['iv'].empty?)
@rc['flag']['iv']
- else '-NQhewpotbxXDyY --update'
+ else '-NQhewpotbxXdDyY --update'
end
end
def cf_5 #processing flag shortcuts
@@ -2594,11 +2773,11 @@ WOK
and not (@rc['flag']['v'].nil? \
or @rc['flag']['v'].empty?)
@rc['flag']['v']
- else '-NQhewpotbxXDyYv --update'
+ else '-NQhewpotbxXdDyYv --update'
end
end
end
- class Info_settings < Info_env
+ class InfoSettings < InfoEnv
def permission?(prog) #program defaults
(defined? @rc['permission_set'][prog]) \
? @rc['permission_set'][prog]
@@ -2610,14 +2789,14 @@ WOK
: false
end
end
- class File_map < Info_env
+ class FileMap < InfoEnv
attr_accessor :local_sisu_source
def initialize(opt='') #watch / REVIEW
super()
@opt=opt #,opt.fns,opt.cmd
@env=(@opt.fns && !(@opt.fns.empty?) \
- ? (SiSU_Env::Info_env.new(@opt.fns))
- : (SiSU_Env::Info_env.new('dummy.sst')))
+ ? (SiSU_Env::InfoEnv.new(@opt.fns))
+ : (SiSU_Env::InfoEnv.new('dummy.sst')))
if @opt.cmd =~/m/; @md=SiSU_Param::Parameters.new(@opt).get
end
ft=[]
@@ -2735,19 +2914,21 @@ WOK
: @source_path
end
end
- class Clean_output
+ class CleanOutput
require 'fileutils'
include FileUtils::Verbose
def initialize(opt)
@opt=opt
- z=File_map.new(@opt)
+ z=SiSU_Env::FileMap.new(@opt)
@zap=z.local_sisu_source
if @opt.cmd =~ /[hH]/
@zap=Dir.glob(@zap).join(' ')
- if @opt.cmd !~ /w/; @zap.gsub!(/#{@source_path}\/concordance.html/,'')
+ @zap=if @opt.cmd !~ /w/
+ @zap.gsub(/#{@source_path}\/concordance.html/,'')
+ else @zap
end
end
- @env=SiSU_Env::Info_env.new
+ @env=SiSU_Env::InfoEnv.new
end
def zap
def main_output
@@ -2781,11 +2962,11 @@ WOK
self
end
end
- class Info_remote_host
+ class InfoRemoteHost
def initialize
- @rc=Get_init.instance.sisu_yaml.rc
+ @rc=GetInit.instance.sisu_yaml.rc
end
- def remote_host #see Info_remote remote_host_base_general
+ def remote_host #see InfoRemote remote_host_base_general
r=[]
r=if (defined? @rc['remote'] \
and @rc['remote'].class==Array)
@@ -2829,48 +3010,48 @@ WOK
end
def rhost
def r1
- (defined? SiSU_Env::Info_remote_host.new.remote_host[0][:name]) \
- ? (SiSU_Env::Info_remote_host.new.remote_host[0][:name])
+ (defined? SiSU_Env::InfoRemoteHost.new.remote_host[0][:name]) \
+ ? (SiSU_Env::InfoRemoteHost.new.remote_host[0][:name])
: nil
end
def r2
- (defined? SiSU_Env::Info_remote_host.new.remote_host[1][:name]) \
- ? (SiSU_Env::Info_remote_host.new.remote_host[1][:name])
+ (defined? SiSU_Env::InfoRemoteHost.new.remote_host[1][:name]) \
+ ? (SiSU_Env::InfoRemoteHost.new.remote_host[1][:name])
: nil
end
def r3
- (defined? SiSU_Env::Info_remote_host.new.remote_host[2][:name]) \
- ? (SiSU_Env::Info_remote_host.new.remote_host[2][:name])
+ (defined? SiSU_Env::InfoRemoteHost.new.remote_host[2][:name]) \
+ ? (SiSU_Env::InfoRemoteHost.new.remote_host[2][:name])
: nil
end
def r4
- (defined? SiSU_Env::Info_remote_host.new.remote_host[3][:name]) \
- ? (SiSU_Env::Info_remote_host.new.remote_host[3][:name])
+ (defined? SiSU_Env::InfoRemoteHost.new.remote_host[3][:name]) \
+ ? (SiSU_Env::InfoRemoteHost.new.remote_host[3][:name])
: nil
end
def r5
- (defined? SiSU_Env::Info_remote_host.new.remote_host[4][:name]) \
- ? (SiSU_Env::Info_remote_host.new.remote_host[4][:name])
+ (defined? SiSU_Env::InfoRemoteHost.new.remote_host[4][:name]) \
+ ? (SiSU_Env::InfoRemoteHost.new.remote_host[4][:name])
: nil
end
def r6
- (defined? SiSU_Env::Info_remote_host.new.remote_host[5][:name]) \
- ? (@ls + SiSU_Env::Info_remote_host.new.remote_host[5][:name])
+ (defined? SiSU_Env::InfoRemoteHost.new.remote_host[5][:name]) \
+ ? (@ls + SiSU_Env::InfoRemoteHost.new.remote_host[5][:name])
: nil
end
self
end
end
- class Info_remote < File_map
+ class InfoRemote < FileMap
@@flag_remote=false
require 'socket'
def initialize(opt)
super(opt) #
@opt=opt
- @rc=Get_init.instance.sisu_yaml.rc
+ @rc=GetInit.instance.sisu_yaml.rc
end
def remote_host_base_general
- SiSU_Env::Info_remote_host.new.remote_host
+ SiSU_Env::InfoRemoteHost.new.remote_host
end
def remote_host_base
remote_host_base_general.each do |remote_conn|
@@ -2901,15 +3082,15 @@ WOK
and remote_gen !~/\/\//) \
and @@flag_remote==true \
and @opt.cmd !~/U/
- System_call.new(local_gen,remote_gen).scp
+ SiSU_Env::SystemCall.new(local_gen,remote_gen).scp
if FileTest.file?("#{local_src}/#{src_txt}")
- System_call.new("#{local_src}/#{src_txt}",remote_src).scp
+ SiSU_Env::SystemCall.new("#{local_src}/#{src_txt}",remote_src).scp
end
if FileTest.file?("#{local_pod}/#{src_pod}")
- System_call.new("#{local_src}/#{src_pod}",remote_pod).scp
+ SiSU_Env::SystemCall.new("#{local_src}/#{src_pod}",remote_pod).scp
end
if FileTest.file?("#{local_epub}/#{@opt.fnb}.epub")
- System_call.new("#{local_epub}/#{@opt.fnb}.epub",remote_epub,@opt.cmd).scp
+ SiSU_Env::SystemCall.new("#{local_epub}/#{@opt.fnb}.epub",remote_epub,@opt.cmd).scp
end
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
@@ -2936,7 +3117,7 @@ WOK
and @@flag_remote==true \
and @opt.cmd !~/U/
puts "begin scp_base: #{local} -> #{remote}"
- System_call.new("#{local}/#{@env.path.style}/",remote).scp
+ SiSU_Env::SystemCall.new("#{local}/#{@env.path.style}/",remote).scp
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
puts "begin scp_base: #{local} -> #{remote}"
@@ -2954,9 +3135,9 @@ WOK
and @@flag_remote==true \
and @opt.cmd !~/U/
puts "begin scp_base_all: #{local} -> #{remote}"
- System_call.new("#{local}/_sisu/image_sys/",remote).scp
- System_call.new("#{local}/_sisu/image/",remote).scp
- System_call.new("#{local}/#{@env.path.style}/",remote).scp
+ SiSU_Env::SystemCall.new("#{local}/_sisu/image_sys/",remote).scp
+ SiSU_Env::SystemCall.new("#{local}/_sisu/image/",remote).scp
+ SiSU_Env::SystemCall.new("#{local}/#{@env.path.style}/",remote).scp
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
puts "scp_base_all: #{local} -> #{remote}"
@@ -2970,7 +3151,7 @@ WOK
self
end
def images_from_skin
- skin=Info_skin.new(@md).select
+ skin=SiSU_Env::InfoSkin.new(@md).select
skin_array=nil
skin_images_array=[]
if skin
@@ -2986,7 +3167,7 @@ WOK
skin_images_array
end
def rsync
- @f=SiSU_Env::SiSU_file.new(@md)
+ @f=SiSU_Env::FileOp.new(@md)
def document
self.remote_host_base.each do |remote_conn|
local_gen=@source_path
@@ -3001,7 +3182,7 @@ WOK
and remote_gen !~/\/\//) \
and @@flag_remote==true \
and @opt.cmd !~/U/
-# System_call.new("#{local_src}/#{src_txt}",remote_src,@opt.cmd).rsync
+# SiSU_Env::SystemCall.new("#{local_src}/#{src_txt}",remote_src,@opt.cmd).rsync
delete_extra_files='--delete' # '--delete-after'
inp=[]
if (@opt.cmd =~/h/ \
@@ -3108,13 +3289,13 @@ WOK
##create file structure without copying files?:
##rsync -av -f"+ */" -f"- *" @f.output_path.base.dir remote:./path/.
#local_dirs=%{-f"+ */" -f"- *" #{@f.output_path.base.dir}/*}
- #System_call.new(local_dirs,remote_gen,@opt.cmd).rsync
+ #SiSU_Env::SystemCall.new(local_dirs,remote_gen,@opt.cmd).rsync
local=local_gen + ' ' + images + ' ' + images_skin + ' ' + images_system + ' ' + local_css
- System_call.new(local,remote_rel,@opt.cmd).rsync('--relative',@f.output_path.base.dir)
+ SiSU_Env::SystemCall.new(local,remote_rel,@opt.cmd).rsync('--relative',@f.output_path.base.dir)
rescue
p __LINE__.to_s + ':' + __FILE__
local_dirs=%{--include='*/' --exclude='*' #{@f.output_path.base.dir}}
- System_call.new(local_dirs,remote_gen,@opt.cmd).rsync
+ SiSU_Env::SystemCall.new(local_dirs,remote_gen,@opt.cmd).rsync
end
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
@@ -3141,9 +3322,9 @@ WOK
and @rc['permission_set']['remote_base_site'] \
and @@flag_remote==true \
and @opt.cmd !~/U/
- System_call.new("#{image_sys}","#{remote_conf}").rsync
- System_call.new("#{images}","#{remote_conf}").rsync
- System_call.new("#{ldest}","#{remote}").rsync
+ SiSU_Env::SystemCall.new("#{image_sys}","#{remote_conf}").rsync
+ SiSU_Env::SystemCall.new("#{images}","#{remote_conf}").rsync
+ SiSU_Env::SystemCall.new("#{ldest}","#{remote}").rsync
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
puts "rsync_base: #{local} -> #{remote}"
@@ -3164,9 +3345,9 @@ WOK
and @opt.cmd !~/U/
delete_extra_files='--delete' # '--delete-after'
puts "begin rsync_base_sync: #{local} -> #{remote}"
- System_call.new("#{local}/_sisu/image_sys/",remote).rsync(delete_extra_files)
- System_call.new("#{local}/_sisu/image/",remote).rsync(delete_extra_files)
- System_call.new("#{local}/#{@env.path.style}/",remote).rsync(delete_extra_files)
+ SiSU_Env::SystemCall.new("#{local}/_sisu/image_sys/",remote).rsync(delete_extra_files)
+ SiSU_Env::SystemCall.new("#{local}/_sisu/image/",remote).rsync(delete_extra_files)
+ SiSU_Env::SystemCall.new("#{local}/#{@env.path.style}/",remote).rsync(delete_extra_files)
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
puts "rsync_base_sync: #{local} -> #{remote}"
@@ -3185,7 +3366,7 @@ WOK
remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/."
if @@flag_remote
delete_extra_files='--delete' # '--delete-after'
- System_call.new(local,remote).rsync(delete_extra_files)
+ SiSU_Env::SystemCall.new(local,remote).rsync(delete_extra_files)
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
puts "rsync_sitemaps: #{local} -> #{remote}"
@@ -3199,7 +3380,7 @@ WOK
remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/."
if @@flag_remote
delete_extra_files='--delete' # '--delete-after'
- System_call.new(local,remote).rsync(delete_extra_files)
+ SiSU_Env::SystemCall.new(local,remote).rsync(delete_extra_files)
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
puts "rsync_sitemaps: #{local} -> #{remote}"
@@ -3208,7 +3389,7 @@ WOK
end
end
end
- class Info_version <Info_env
+ class InfoVersion <InfoEnv
include Singleton
require 'rbconfig'
@@lib_path=nil
@@ -3226,11 +3407,11 @@ WOK
%x{ruby -v}.strip
end
end
- class Create_system_link #revisit problems created 2004w41
+ class CreateSystemLink #revisit problems created 2004w41
require 'fileutils'
include FileUtils::Verbose
def initialize
- @env=SiSU_Env::Info_env.new
+ @env=SiSU_Env::InfoEnv.new
end
def images
unless FileTest.directory?("#{@env.path.output}/_sisu")
@@ -3248,12 +3429,12 @@ WOK
#File.symlink("../../man/form", "#{@env.path.output}/man/pdf") unless File.symlink?("#{@env.path.output}/man/pdf")==true
end
end
- class Info_file <Info_env #todo unify with SiSU_file
+ class InfoFile <InfoEnv #todo unify with FileOp
def initialize(fns)
begin
super(fns)
@fns=fns
- @env=SiSU_Env::Info_env.new(@fns)
+ @env=SiSU_Env::InfoEnv.new(@fns)
m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm)$/ #watch added match for sss
@fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3]
rescue; STDERR.puts SiSU_Screen::Ansi.new(@fns,$!,$@).rescue
@@ -3314,7 +3495,7 @@ WOK
end
self
end
- def mkdir #check moved from SiSU_file, existing mkdir
+ def mkdir #check moved from FileOp, existing mkdir
def processing
def dal
FileUtils::mkdir_p(@env.processing_path.dal) unless FileTest.directory?(@env.processing_path.dal)
@@ -3326,31 +3507,434 @@ WOK
end
end
end
- class SiSU_file <Info_file #todo unify with Create_file
- def initialize(md,fno='')
- begin
- @md,@fno=md,fno
- @env=SiSU_Env::Info_env.new(@md.fns)
- rescue; STDERR.puts SiSU_Screen::Ansi.new(@cmd,$!,$@).rescue
- ensure
+ class ProcessingSettings
+ def initialize(md)
+ @md=md
+ end
+ def cnf_rc #sisurc.yml
+ @rc=SiSU_Env::GetInit.instance.sisu_yaml.rc
+ end
+ def env_rc #env rc (including sisurc.yml)
+ @env_rc ||=SiSU_Env::InfoEnv.new(@md.fns)
+ end
+ def doc_rc #document rc, make instructions
+ @md.make
+ end
+ def cmd_rc #command-line rc
+ @cmd_rc=@md.opt.opt_act
+ end
+ def build
+ def ocn?
+ if cmd_rc[:ocn][:set]==:on
+ true
+ elsif cmd_rc[:ocn][:set]==:off
+ false
+ elsif @md.make.ocn? ==:off
+ false
+ elsif env_rc.build.ocn? ==:off
+ false
+ else
+ true
+ end
+ end
+ def toc?
+ if cmd_rc[:toc][:set]==:on
+ true
+ elsif cmd_rc[:toc][:set]==:off
+ false
+ elsif @md.make.toc? ==:off
+ false
+ elsif env_rc.build.toc? ==:off
+ false
+ else
+ true
+ end
+ end
+ def manifest?
+ if cmd_rc[:manifest][:set]==:on
+ true
+ elsif cmd_rc[:manifest][:set]==:off
+ false
+ elsif @md.make.manifest? ==:off
+ false
+ elsif env_rc.build.manifest? ==:off
+ false
+ else
+ true
+ end
+ end
+ def links_to_manifest?
+ if cmd_rc[:links_to_manifest][:set]==:on
+ true
+ elsif cmd_rc[:links_to_manifest][:set]==:off
+ false
+ elsif @md.make.links_to_manifest? ==:off
+ false
+ elsif env_rc.build.links_to_manifest? ==:off
+ false
+ else
+ true
+ end
+ end
+ def metadata?
+ if cmd_rc[:metadata][:set]==:on
+ true
+ elsif cmd_rc[:metadata][:set]==:off
+ false
+ elsif @md.make.metadata? ==:off
+ false
+ elsif env_rc.build.metadata? ==:off
+ false
+ else
+ true
+ end
+ end
+ def minitoc?
+ if html_top_band? == false #one form of navigation necessary
+ true
+ elsif cmd_rc[:minitoc][:set]==:on
+ true
+ elsif cmd_rc[:minitoc][:set]==:off
+ false
+ elsif @md.make.minitoc? ==:off
+ false
+ elsif env_rc.build.minitoc? ==:off
+ false
+ else
+ true
+ end
+ end
+ def manifest_minitoc?
+ if html_top_band? == false #one form of navigation necessary
+ true
+ elsif cmd_rc[:manifest_minitoc][:set]==:on \
+ || cmd_rc[:minitoc][:set]==:on
+ true
+ elsif cmd_rc[:manifest_minitoc][:set]==:off \
+ || cmd_rc[:minitoc][:set]==:off
+ false
+ elsif @md.make.manifest_minitoc? ==:off \
+ || @md.make.minitoc? ==:off
+ false
+ elsif env_rc.build.manifest_minitoc? ==:off \
+ || env_rc.build.minitoc? ==:off
+ false
+ elsif minitoc? == false
+ false
+ else
+ true
+ end
+ end
+ def html_minitoc?
+ if html_top_band? == false #one form of navigation necessary
+ true
+ elsif cmd_rc[:html_minitoc][:set]==:on \
+ || cmd_rc[:minitoc][:set]==:on
+ true
+ elsif cmd_rc[:html_minitoc][:set]==:off \
+ || cmd_rc[:minitoc][:set]==:off
+ false
+ elsif @md.make.html_minitoc? ==:off \
+ || @md.make.minitoc? ==:off
+ false
+ elsif env_rc.build.html_minitoc? ==:off \
+ || env_rc.build.minitoc? ==:off
+ false
+ elsif minitoc? == false
+ false
+ else
+ true
+ end
+ end
+ def html_top_band?
+ if cmd_rc[:html_top_band][:set]==:on
+ true
+ elsif cmd_rc[:html_top_band][:set]==:off
+ false
+ elsif @md.make.html_top_band? ==:off
+ false
+ elsif env_rc.build.html_top_band? ==:off
+ false
+ else
+ true
+ end
end
+ def html_navigation?
+ if cmd_rc[:html_navigation][:set]==:on
+ true
+ elsif cmd_rc[:html_navigation][:set]==:off
+ false
+ elsif @md.make.html_navigation? ==:off
+ false
+ elsif env_rc.build.html_navigation? ==:off
+ false
+ else
+ true
+ end
+ end
+ def html_navigation_bar?
+ if cmd_rc[:html_navigation_bar][:set]==:on
+ true
+ elsif cmd_rc[:html_navigation_bar][:set]==:off
+ false
+ elsif @md.make.html_navigation_bar? ==:off
+ false
+ elsif env_rc.build.html_navigation_bar? ==:off
+ false
+ else
+ true
+ end
+ end
+ def search_form?
+ if cmd_rc[:search_form][:set]==:on
+ true
+ elsif cmd_rc[:search_form][:set]==:off
+ false
+ elsif @md.make.search_form? ==:off
+ false
+ elsif env_rc.build.search_form? ==:off
+ false
+ else
+ true
+ end
+ end
+ def html_search_form?
+ if cmd_rc[:html_search_form][:set]==:on \
+ || cmd_rc[:search_form][:set]==:on
+ true
+ elsif cmd_rc[:html_search_form][:set]==:off \
+ || cmd_rc[:search_form][:set]==:off
+ false
+ elsif @md.make.html_search_form? ==:off \
+ || @md.make.search_form? ==:off
+ false
+ elsif env_rc.build.html_search_form? ==:off \
+ || env_rc.build.search_form? ==:off
+ false
+ elsif search_form? == false
+ false
+ else
+ true
+ end
+ end
+ def html_right_pane?
+ if cmd_rc[:html_right_pane][:set]==:on
+ true
+ elsif cmd_rc[:html_right_pane][:set]==:off
+ false
+ elsif @md.make.html_right_pane? ==:off
+ false
+ elsif env_rc.build.html_right_pane? ==:off
+ false
+ else
+ true
+ end
+ end
+ def segsubtoc?
+ if cmd_rc[:segsubtoc][:set]==:on
+ true
+ elsif cmd_rc[:segsubtoc][:set]==:off
+ false
+ elsif @md.make.segsubtoc? ==:off
+ false
+ elsif env_rc.build.segsubtoc? ==:off
+ false
+ else
+ true
+ end
+ end
+ self
end
def output_dir_structure
def by_language_code?
- @env.output_dir_structure.by_language_code?
+ env_rc.output_dir_structure.by_language_code?
end
def by_filetype?
- @env.output_dir_structure.by_filetype?
+ env_rc.output_dir_structure.by_filetype?
end
def by_filename?
- @env.output_dir_structure.by_filename?
+ env_rc.output_dir_structure.by_filename?
end
def multilingual?
- @env.output_dir_structure.by_language_code?
- #by_language_code?
+ by_language_code?
+ end
+ def dump?
+ ((cmd_rc[:dump][:bool] \
+ && cmd_rc[:dump][:inst]) \
+ || (env_rc.output_dir_structure.dump?)) \
+ ? true
+ : false
+ end
+ def redirect?
+ ((cmd_rc[:redirect][:bool] \
+ && cmd_rc[:redirect][:inst]) \
+ || (env_rc.output_dir_structure.redirect?)) \
+ ? true
+ : false
+ end
+ def dump_or_redirect?
+ ((dump?) || (redirect?)) \
+ ? true
+ : false
+ end
+ def by?
+ if dump?
+ :dump
+ elsif redirect?
+ :redirect
+ elsif by_language_code?
+ :language
+ elsif by_filetype?
+ :filetype
+ elsif by_filename?
+ :filename
+ else #recheck current default
+ :language
+ end
end
self
end
+ end
+ class InfoDb < InfoEnv
+ @@rc=nil
+ def initialize
+ @@pwd ||=Dir.pwd
+ @pwd=Dir.pwd
+ @env=SiSU_Env::InfoEnv.new
+ pt=Pathname.new(@pwd)
+ r=Px[:lng_lst].join('|')
+ u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/
+ @pwd_stub=pt.realpath.to_s[u,1]
+ @rc=@@rc ||=GetInit.instance.sisu_yaml.rc
+ @defaults=SiSU_Env::InfoEnv.new.defaults
+ end
+ def share_source?
+ ((defined? @rc['db']['share_source']) \
+ && @rc['db']['share_source']==true) \
+ ? @rc['db']['share_source']
+ : false
+ end
+ def engine
+ def default
+ ((defined? @rc['db']['engine']['default']) \
+ && @rc['db']['engine']['default']=~/postgresql|sqlite/) \
+ ? @rc['db']['engine']['default']
+ : 'sqlite'
+ end
+ self
+ end
+ def psql
+ def user
+ ((defined? @rc['db']['postgresql']['user']) \
+ && @rc['db']['postgresql']['user']=~/\S+/) \
+ ? @rc['db']['postgresql']['user']
+ : @env.user
+ end
+ def db #db_name
+ "#{Db[:name_prefix]}#{@pwd_stub}"
+ end
+ def port #PGPORT
+ ((defined? @rc['db']['postgresql']['port']) \
+ && ( @rc['db']['postgresql']['port'] =~/\d+/ \
+ || @rc['db']['postgresql']['port'].class==Fixnum)) \
+ ? @rc['db']['postgresql']['port']
+ : (@defaults[:postgresql_port])
+ end
+ def password
+ ((defined? @rc['db']['postgresql']['password']) \
+ && @rc['db']['postgresql']['password']=~/\S+/) \
+ ? @rc['db']['postgresql']['password']
+ : ''
+ end
+ def host
+ ((defined? @rc['db']['postgresql']['host']) \
+ && @rc['db']['postgresql']['host']=~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \
+ ? @rc['db']['postgresql']['host']
+ : ''
+ end
+ def dbi
+ (psql.host =~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \
+ ? "DBI:Pg:database=#{psql.db};host=#{psql.host};port=#{psql.port}"
+ : "DBI:Pg:database=#{psql.db};port=#{psql.port}"
+ end
+ def conn_dbi
+ DBI.connect(psql.dbi,psql.user,psql.db)
+ end
+ self
+ end
+ def mysql
+ def db
+ #"#{Db[:name_prefix]}#{@pwd_stub}"
+ end
+ def port
+ '**'
+ end
+ def dbi
+ "dbi:Mysql:database=#{mysql.db};port=#{mysql.port}"
+ end
+ self
+ end
+ def sqlite
+ def db
+ "#{@env.path.webserv}/#{@pwd_stub}/sisu_sqlite.db"
+ end
+ def db_discreet(md)
+ # "#{@env.path.webserv}/#{@pwd_stub}/sisu_sqlite.db"
+ end
+ def dbi
+ "DBI:SQLite3:#{sqlite.db}" #sqlite3 ?
+ end
+ def sqlite3
+ sqlite.db #sqlite3 ?
+ end
+ def conn_dbi
+ DBI.connect(sqlite.dbi)
+ end
+ def conn_sqlite3
+ SQLite3::Database.new(sqlite.sqlite3)
+ end
+ self
+ end
+ end
+ class DbOp <InfoDb
+ def initialize(md)
+ begin
+ @md=md
+ rescue; STDERR.puts SiSU_Screen::Ansi.new(@cmd,$!,$@).rescue
+ ensure
+ end
+ end
+ def sqlite_discreet
+ def db
+ "#{@md.file.output_path.sqlite_discreet.dir}/#{@md.file.base_filename.sqlite_discreet}"
+ end
+ def dbi
+ "DBI:SQLite3:#{sqlite_discreet.db}"
+ end
+ def sqlite3
+ sqlite_discreet.db
+ end
+ def conn_dbi
+ DBI.connect(sqlite_discreet.dbi)
+ end
+ def conn_sqlite3
+ SQLite3::Database.new(sqlite_discreet.sqlite3)
+ end
+ self
+ end
+ end
+ class FileOp <InfoFile #todo unify with CreateFile
+ def initialize(md,fno='')
+ begin
+ @md,@fno=md,fno
+ @env=SiSU_Env::InfoEnv.new(@md.fns)
+ rescue; STDERR.puts SiSU_Screen::Ansi.new(@cmd,$!,$@).rescue
+ ensure
+ end
+ end
+ def output_dir_structure
+ ProcessingSettings.new(@md).output_dir_structure
+ end
def mkdir_initialize # not used but consider using
FileUtils::mkdir_p(output_path.base.dir) unless FileTest.directory?(output_path.base.dir)
FileUtils::mkdir_p("#{output_path.base.dir}/#{@md.fnb}") unless FileTest.directory?("#{output_path.base.dir}/#{@md.fnb}")
@@ -3400,7 +3984,8 @@ WOK
@@filename_html_scroll=File.new(p_fn,'w+')
end
def html_seg_index
- pth=(by_filename?) \
+ pth=((by_filename?) \
+ || (output_dir_structure.dump?)) \
? "#{output_path.html.dir}"
: "#{output_path.html.dir}/#{@md.fnb}"
fn=base_filename.html_seg_index
@@ -3409,7 +3994,8 @@ WOK
@@filename_html_index=File.new(p_fn,'w+')
end
def html_segtoc
- pth=(by_filename?) \
+ pth=((by_filename?) \
+ || (output_dir_structure.dump?)) \
? "#{output_path.html.dir}"
: "#{output_path.html.dir}/#{@md.fnb}"
fn=base_filename.html_segtoc
@@ -3597,6 +4183,15 @@ WOK
end
self
end
+ def sqlite_discreet
+ def dir
+ output_path.sqlite_discreet.dir + '/' + base_filename.sqlite_discreet
+ end
+ def rel
+ output_path.sqlite_discreet.rel + '/' + base_filename.sqlite_discreet
+ end
+ self
+ end
def hash_digest
def dir
output_path.hash_digest.dir + '/' + base_filename.hash_digest
@@ -3719,9 +4314,9 @@ WOK
def base_filename
def txt
ft='.txt'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + ft
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
@md.fnb + @md.lang_code_insert + ft
else
'plain' + @md.lang_code_insert + ft
@@ -3729,9 +4324,9 @@ WOK
end
def html_scroll
ft='.html'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + ft
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
@md.fnb + @md.lang_code_insert + ft
else
'scroll' + @md.lang_code_insert + ft
@@ -3739,7 +4334,7 @@ WOK
end
def html_seg_index
ft='.html'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
'index' + ft
else
'index' + @md.lang_code_insert + ft
@@ -3747,7 +4342,9 @@ WOK
end
def html_segtoc
ft='.html'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.dump_or_redirect?
+ @md.fnb + '.toc' + ft
+ elsif output_dir_structure.by_language_code?
'toc' + ft
else
'toc' + @md.lang_code_insert + ft
@@ -3755,7 +4352,7 @@ WOK
end
def html_book_index
ft='.html'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
'book_index' + ft
else
'book_index' + @md.lang_code_insert + ft
@@ -3763,7 +4360,9 @@ WOK
end
def html_concordance
ft='.html'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.dump_or_redirect?
+ @md.fnb + '.concordance' + ft
+ elsif output_dir_structure.by_language_code?
'concordance' + ft
else
'concordance' + @md.lang_code_insert + ft
@@ -3771,9 +4370,9 @@ WOK
end
def xhtml
ft= '.xhtml'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + ft
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
@md.fnb + @md.lang_code_insert + ft
else
'scroll' + @md.lang_code_insert + ft
@@ -3781,7 +4380,7 @@ WOK
end
def epub
ft='.epub'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + ft
else
@md.fnb + @md.lang_code_insert + ft
@@ -3789,9 +4388,9 @@ WOK
end
def odt
ft='.odt'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + ft
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
@md.fnb + @md.lang_code_insert + ft
else
'opendocument' + @md.lang_code_insert + ft
@@ -3799,9 +4398,9 @@ WOK
end
def xml_sax
ft='.sax.xml'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + ft
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
@md.fnb + @md.lang_code_insert + ft
else
'scroll' + @md.lang_code_insert + ft
@@ -3809,22 +4408,22 @@ WOK
end
def xml_dom
ft='.dom.xml'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + ft
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
@md.fnb + @md.lang_code_insert + ft
else
'scroll' + @md.lang_code_insert + ft
end
end
def pdf_p
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + '.portrait.'
else 'portrait' + @md.lang_code_insert + '.'
end
end
def pdf_l
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + '.landscape.'
else 'landscape' + @md.lang_code_insert + '.'
end
@@ -3861,7 +4460,7 @@ WOK
end
def manpage
ft='1'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + '.' + ft
else
@md.fnb + '.' + @md.opt.f_pth[:lng_is] + '.' + ft
@@ -3869,7 +4468,7 @@ WOK
end
def info
ft='info'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + '.' + ft
else
@md.fnb + '.' + @md.opt.f_pth[:lng_is] + '.' + ft
@@ -3877,17 +4476,25 @@ WOK
end
def texinfo
ft='texinfo'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + '.' + ft
else
@md.fnb + '.' + @md.opt.f_pth[:lng_is] + '.' + ft
end
end
+ def sqlite_discreet
+ ft='.sql.db'
+ if output_dir_structure.by_language_code?
+ @md.fnb + ft
+ else
+ @md.fnb + @md.lang_code_insert + ft
+ end
+ end
def hash_digest
ft='.txt'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + '.hash_digest' + ft
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
@md.fnb + @md.lang_code_insert + ft
else
'digest' + @md.lang_code_insert + ft
@@ -3895,9 +4502,9 @@ WOK
end
def sitemap
ft='.xml'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + '.sitemap' + ft
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
@md.fnb + @md.lang_code_insert + ft
else
'sitemap' + @md.lang_code_insert + ft
@@ -3905,9 +4512,9 @@ WOK
end
def qrcode_title
ft='.title.png'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + ft
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
@md.fnb + @md.lang_code_insert + ft
else #fix
'sisu_manifest' + @md.lang_code_insert + ft
@@ -3915,9 +4522,9 @@ WOK
end
def qrcode_md
ft='.md.png'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + ft
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
@md.fnb + @md.lang_code_insert + ft
else #fix
'sisu_manifest' + @md.lang_code_insert + ft
@@ -3925,9 +4532,9 @@ WOK
end
def manifest_txt
ft='.txt'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
@md.fnb + ft
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
@md.fnb + @md.lang_code_insert + ft
else #fix
'sisu_manifest' + @md.lang_code_insert + ft
@@ -3935,9 +4542,11 @@ WOK
end
def manifest
ft='.html'
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.dump_or_redirect?
+ @md.fnb + '.manifest' + ft
+ elsif output_dir_structure.by_language_code?
@md.fnb + ft
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
@md.fnb + @md.lang_code_insert + ft
else #fix
'sisu_manifest' + @md.lang_code_insert + ft
@@ -3967,52 +4576,70 @@ WOK
@ft=ft
def dir
def abc
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.redirect?
+ "#{@md.opt.opt_act[:redirect][:inst]}/#{@md.fnb}"
+ elsif output_dir_structure.dump?
+ @md.opt.opt_act[:dump][:inst]
+ elsif output_dir_structure.by_language_code?
"#{output_path.base.dir}/#{@md.opt.lng}/#{@ft}"
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
"#{output_path.base.dir}/#{@ft}"
else
"#{output_path.base.dir}/#{@md.fnb}"
end
end
def ab
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.redirect?
+ "#{@md.opt.opt_act[:redirect][:inst]}/#{@md.fnb}"
+ elsif output_dir_structure.dump?
+ @md.opt.opt_act[:dump][:inst]
+ elsif output_dir_structure.by_language_code?
"#{output_path.base.dir}/#{@md.opt.lng}/#{@ft}"
else
"#{output_path.base.dir}/#{@ft}"
end
end
def ab_src
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.redirect?
+ "#{@md.opt.opt_act[:redirect][:inst]}/#{@md.fnb}"
+ elsif output_dir_structure.dump?
+ @md.opt.opt_act[:dump][:inst]
+ elsif output_dir_structure.by_language_code?
"#{output_path.base.dir}/#{@ft}/#{@md.opt.lng}"
else
"#{output_path.base.dir}/#{@ft}"
end
end
def ab_pod
- "#{output_path.base.dir}/#{@ft}"
+ if output_dir_structure.redirect?
+ "#{@md.opt.opt_act[:redirect][:inst]}/#{@md.fnb}"
+ elsif output_dir_structure.dump?
+ @md.opt.opt_act[:dump][:inst]
+ else
+ "#{output_path.base.dir}/#{@ft}"
+ end
end
self
end
def url
def abc
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
"#{output_path.base.url}/#{@md.opt.lng}/#{@ft}"
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
"#{output_path.base.url}/#{@ft}"
else
"#{output_path.base.url}/#{@md.fnb}"
end
end
def ab
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
"#{output_path.base.url}/#{@md.opt.lng}/#{@ft}"
else
"#{output_path.base.url}/#{@ft}"
end
end
def ab_src
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
"#{output_path.base.url}/#{@ft}/#{@md.opt.lng}"
else
"#{output_path.base.url}/#{@ft}"
@@ -4025,30 +4652,32 @@ WOK
end
def rel
def abc
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
"#{@md.opt.lng}/#{@ft}"
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
"#{@ft}"
else
"#{@md.fnb}"
end
end
def ab
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
"#{@md.opt.lng}/#{@ft}"
else
"#{@ft}"
end
end
def ab_src
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.dump_or_redirect?
+ "."
+ elsif output_dir_structure.by_language_code?
"#{@ft}/#{@md.opt.lng}"
else
"#{@ft}"
end
end
def ab_pod
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
"#{@ft}"
else
"#{@ft}"
@@ -4058,30 +4687,36 @@ WOK
end
def rel_sm
def abc
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
"#{@md.opt.lng}/#{@ft}"
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
"#{@ft}"
else
"#{@md.fnb}"
end
end
def ab
- if @env.output_dir_structure.by_language_code?
- "#{@md.opt.lng}/#{@ft}"
- else
- "#{@ft}"
+ if output_dir_structure.dump_or_redirect?
+ '.'
+ elsif output_dir_structure.by_language_code? \
+ or output_dir_structure.by_filetype?
+ '../' + @ft
+ else '.'
end
end
def ab_src
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.dump_or_redirect?
+ '.'
+ elsif output_dir_structure.by_language_code?
"#{@ft}/#{@md.opt.lng}"
else
"#{@ft}"
end
end
def ab_pod
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.dump_or_redirect?
+ '.'
+ elsif output_dir_structure.by_language_code?
"../../#{@ft}/#{@md.opt.lng}"
else
"../#{@ft}"
@@ -4091,16 +4726,16 @@ WOK
end
def rcp
def abc
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
"#{output_path.stub.rcp}/#{@md.opt.lng}/#{@ft}"
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
"#{output_path.stub.rcp}/#{@ft}"
else
"#{output_path.stub.rcp}/#{@md.fnb}"
end
end
def ab
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
"#{output_path.stub.rcp}/#{@md.opt.lng}/#{@ft}"
else
"#{output_path.stub.rcp}/#{@ft}"
@@ -4108,16 +4743,6 @@ WOK
end
self
end
- def rel_sm
- def ab
- if @env.output_dir_structure.by_language_code? \
- or @env.output_dir_structure.by_filetype?
- '../' + @ft
- else '.'
- end
- end
- self
- end
self
end
def output_path
@@ -4151,9 +4776,18 @@ WOK
end
self
end
+ def webserver_path
+ if output_dir_structure.dump?
+ @md.opt.opt_act[:dump][:inst]
+ elsif output_dir_structure.redirect?
+ @md.opt.opt_act[:redirect][:inst]
+ else
+ "#{@env.path.webserv}"
+ end
+ end
def base
def dir
- "#{@env.path.webserv}/#{@md.opt.f_pth[:pth_stub]}"
+ "#{webserver_path}/#{@md.opt.f_pth[:pth_stub]}"
end
def url
"#{@env.url.webserv}/#{@md.opt.f_pth[:pth_stub]}"
@@ -4313,9 +4947,11 @@ WOK
set_path(ft).rel_sm.ab
end
def rel_image
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.dump_or_redirect?
+ './image'
+ elsif output_dir_structure.by_language_code?
'../../_sisu/image'
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
'../_sisu/image'
else
'../_sisu/image'
@@ -4343,9 +4979,11 @@ WOK
set_path(ft).rel_sm.ab
end
def rel_image
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.dump_or_redirect?
+ './image'
+ elsif output_dir_structure.by_language_code?
'../../../_sisu/image'
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
'../../_sisu/image'
else
'../_sisu/image'
@@ -4377,9 +5015,9 @@ WOK
set_path(ft).rel_sm.ab
end
def rel_image
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
'../../_sisu/image'
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
'../_sisu/image'
else
'../_sisu/image'
@@ -4509,6 +5147,27 @@ WOK
end
self
end
+ def sqlite_discreet
+ def ft
+ 'sql'
+ end
+ def dir
+ set_path(ft).dir.ab
+ end
+ def url
+ set_path(ft).url.ab
+ end
+ def rel
+ set_path(ft).rel.ab
+ end
+ def rcp
+ set_path(ft).rcp.ab
+ end
+ def rel_sm
+ set_path(ft).rel_sm.ab
+ end
+ self
+ end
def hash_digest
def ft
'hashes'
@@ -4564,6 +5223,9 @@ WOK
def rcp
set_path(ft).rcp.abc
end
+ def rel_sm
+ set_path(ft).rel_sm.ab
+ end
self
end
def harvest
@@ -4583,9 +5245,9 @@ WOK
set_path(ft).rcp.ab
end
def rel_sm
- if @env.output_dir_structure.by_language_code?
+ if output_dir_structure.by_language_code?
''
- elsif @env.output_dir_structure.by_filetype?
+ elsif output_dir_structure.by_filetype?
''
else
''
@@ -4726,11 +5388,11 @@ WOK
self
end
end
- class Create_file <Info_env #todo unify with SiSU_file
+ class CreateFile <InfoEnv #todo unify with FileOp
def initialize(fns)
begin
super(fns)
- @env=SiSU_Env::Info_env.new(fns)
+ @env=SiSU_Env::InfoEnv.new(fns)
rescue; STDERR.puts SiSU_Screen::Ansi.new(@fns,$!,$@).rescue
ensure
end
@@ -4808,13 +5470,13 @@ WOK
File.new("#{@env.processing_path.texinfo}/#{@fnb}.texinfo",'w+')
end
end
- class Clear <Info_env #todo unify with SiSU_file
+ class Clear <InfoEnv #todo unify with FileOp
def initialize(cmd,fns,operation='')
@cmd=cmd
begin
super(fns)
- @env=SiSU_Env::Info_env.new(fns)
- ver=Info_version.instance
+ @env=SiSU_Env::InfoEnv.new(fns)
+ ver=InfoVersion.instance
if operation.class.inspect =~/SiSU_Param/
@md=operation
end
@@ -4838,127 +5500,27 @@ WOK
end
def param_instantiate
@cX||=SiSU_Screen::Ansi.new(@cmd)
- @@date=Info_date.new
+ @@date=SiSU_Env::InfoDate.new
@@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=@@yaml=@@yamladdr=nil
@@publisher='SiSU scribe'
end
end
- class Info_db < Info_env
- @@rc=nil
- def initialize
- @@pwd ||=Dir.pwd
- @pwd=Dir.pwd
- @env=SiSU_Env::Info_env.new
- #m=/.+\/(?:src\/)?(\S+)/m # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m
- #@pwd_stub=@pwd[m,1]
- pt=Pathname.new(@pwd)
- r=Px[:lng_lst].join('|')
- u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/
- @pwd_stub=pt.realpath.to_s[u,1]
- @rc=@@rc ||=Get_init.instance.sisu_yaml.rc
- @defaults=Info_env.new.defaults
- end
- def share_source?
- ((defined? @rc['db']['share_source']) \
- && @rc['db']['share_source']==true) \
- ? @rc['db']['share_source']
- : false
- end
- def engine
- def default
- ((defined? @rc['db']['engine']['default']) \
- && @rc['db']['engine']['default']=~/postgresql|sqlite/) \
- ? @rc['db']['engine']['default']
- : 'sqlite'
- end
- self
- end
- def psql
- def user
- ((defined? @rc['db']['postgresql']['user']) \
- && @rc['db']['postgresql']['user']=~/\S+/) \
- ? @rc['db']['postgresql']['user']
- : @env.user
- end
- def db #db_name
- "#{Db[:name_prefix]}#{@pwd_stub}"
- end
- def port #PGPORT
- ((defined? @rc['db']['postgresql']['port']) \
- && ( @rc['db']['postgresql']['port'] =~/\d+/ \
- || @rc['db']['postgresql']['port'].class==Fixnum)) \
- ? @rc['db']['postgresql']['port']
- : (@defaults[:postgresql_port])
- end
- def password
- ((defined? @rc['db']['postgresql']['password']) \
- && @rc['db']['postgresql']['password']=~/\S+/) \
- ? @rc['db']['postgresql']['password']
- : ''
- end
- def host
- ((defined? @rc['db']['postgresql']['host']) \
- && @rc['db']['postgresql']['host']=~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \
- ? @rc['db']['postgresql']['host']
- : ''
- end
- def dbi
- (psql.host =~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \
- ? "DBI:Pg:database=#{psql.db};host=#{psql.host};port=#{psql.port}"
- : "DBI:Pg:database=#{psql.db};port=#{psql.port}"
- end
- def conn_dbi
- DBI.connect(psql.dbi,psql.user,psql.db)
- end
- self
- end
- def mysql
- def db
- #"#{Db[:name_prefix]}#{@pwd_stub}"
- end
- def port
- '**'
- end
- def dbi
- "dbi:Mysql:database=#{mysql.db};port=#{mysql.port}"
- end
- self
- end
- def sqlite
- def db
- "#{@env.path.webserv}/#{@pwd_stub}/sisu_sqlite.db"
- end
- def dbi
- "DBI:SQLite3:#{sqlite.db}" #sqlite3 ?
- end
- def sqlite3
- sqlite.db #sqlite3 ?
- end
- def conn_dbi
- DBI.connect(sqlite.dbi)
- end
- def conn_sqlite3
- SQLite3::Database.new(sqlite.sqlite3)
- end
- self
- end
- end
- class Info_port < Info_env
+ class InfoPort < InfoEnv
def initialize
- @env=SiSU_Env::Info_env.new
+ @env=SiSU_Env::InfoEnv.new
end
def webrick
@env.url.webrick_port
end
end
- class Info_program < Info_env #revisit
+ class InfoProgram < InfoEnv #revisit
attr_accessor :editor,:wc,:tidy,:rexml,:pdflatex,:postgresql,:sqlite
def initialize
- prog=SiSU_Env::Info_env.new.program
+ prog=SiSU_Env::InfoEnv.new.program
@editor,@wc,@tidy,@rexml,@pdflatex,@postgresql,@sqlite=prog.text_editor,prog.wc,prog.tidy,prog.rexml,prog.pdflatex,prog.postgresql,prog.sqlite
end
end
- class Info_skin
+ class InfoSkin
def initialize(md=nil,skin=nil)
@md=md
@d_sk=if skin.class==String ; skin
@@ -4970,7 +5532,7 @@ WOK
@home,@pwd=ENV['HOME'],ENV['PWD']
m=/.+\/(?:src\/)?(\S+)/m # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m
@pwd_stub=@pwd[m,1]
- @env=SiSU_Env::Info_env.new
+ @env=SiSU_Env::InfoEnv.new
end
def select # skin loading logic here
load "#{SiSU_lib}/defaults.rb"
@@ -5016,7 +5578,7 @@ WOK
end
end
end
- class CSS_default
+ class CSS_Default
def html
'html.css'
end
@@ -5042,10 +5604,10 @@ WOK
'harvest.css'
end
end
- class CSS_select < Info_env
+ class CSS_Select < InfoEnv
def initialize(md)
@md=md
- @env=SiSU_Env::Info_env.new
+ @env=SiSU_Env::InfoEnv.new('',@md)
end
def html
css=if @md.doc_css \
@@ -5053,7 +5615,7 @@ WOK
"#{@md.doc_css}_html.css"
elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_html.css")
"#{@env.path.stub_pwd}_html.css"
- else CSS_default.new.html
+ else SiSU_Env::CSS_Default.new.html
end
end
def html_tables
@@ -5062,7 +5624,7 @@ WOK
"#{@md.doc_css}_html_tables.css"
elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_html_tables.css")
"#{@env.path.stub_pwd}_html_tables.css"
- else CSS_default.new.html_tables
+ else SiSU_Env::CSS_Default.new.html_tables
end
end
def xhtml
@@ -5071,7 +5633,7 @@ WOK
"#{@md.doc_css}_xhtml.css"
elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_xhtml.css")
"#{@env.path.stub_pwd}_xhtml.css"
- else CSS_default.new.xhtml
+ else SiSU_Env::CSS_Default.new.xhtml
end
end
def xml_sax
@@ -5080,7 +5642,7 @@ WOK
"#{@md.doc_css}_xml_sax.css"
elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_xml_sax.css")
"#{@env.path.stub_pwd}_xml_sax.css"
- else CSS_default.new.xml_sax
+ else SiSU_Env::CSS_Default.new.xml_sax
end
end
def xml_dom
@@ -5089,7 +5651,7 @@ WOK
"#{@md.doc_css}_xml_dom.css"
elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_xml_dom.css")
"#{@env.path.stub_pwd}_xml_dom.css"
- else CSS_default.new.xml_dom
+ else SiSU_Env::CSS_Default.new.xml_dom
end
end
def docbook_xml
@@ -5098,7 +5660,7 @@ WOK
"#{@md.doc_css}_xml_dom.css"
elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_docbook.css")
"#{@env.path.stub_pwd}_docbook.css"
- else CSS_default.new.docbook_xml
+ else SiSU_Env::CSS_Default.new.docbook_xml
end
end
def homepage
@@ -5107,16 +5669,16 @@ WOK
"#{@md.doc_css}_homepage.css"
elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_homepage.css")
"#{@env.path.stub_pwd}_homepage.css"
- else CSS_default.new.homepage
+ else SiSU_Env::CSS_Default.new.homepage
end
end
end
- class CSS_stylesheet
+ class CSS_Stylesheet
def initialize(md)
@md=md
- @css=CSS_select.new(@md)
- @env=SiSU_Env::Info_env.new
- @file=SiSU_Env::SiSU_file.new(@md)
+ @css=SiSU_Env::CSS_Select.new(@md)
+ @env=SiSU_Env::InfoEnv.new('',@md)
+ @file=SiSU_Env::FileOp.new(@md)
end
def html
%{ <link rel="stylesheet" href="#{@file.path_rel_links.html_scroll_css}#{@env.path.style}/#{@css.html}" type="text/css" />}
@@ -5143,15 +5705,15 @@ WOK
%{<?xml-stylesheet type="text/css" href="#{@file.path_rel_links.xml_css}#{@env.path.style}/#{@css.xml_dom}"?>}
end
end
- class Create_site < Info_env
+ class CreateSite < InfoEnv
require_relative 'css' # css.rb
include SiSU_Style
def initialize(cmd)
@cmd=cmd
- @env=SiSU_Env::Info_env.new
+ @env=SiSU_Env::InfoEnv.new
@home,@pwd=ENV['HOME'],ENV['PWD'] #@pwd=Dir.pwd
- @rc=Get_init.instance.sisu_yaml.rc
- @vz=SiSU_Env::Get_init.instance.skin
+ @rc=GetInit.instance.sisu_yaml.rc
+ @vz=SiSU_Env::GetInit.instance.skin
@vz_home=SiSU_Viz::Home.new
end
def homepage
@@ -5203,7 +5765,7 @@ WOK
def cp_external_images
src="#{@env.processing_path.processing}/external_document/image"
dest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image_external"
- if FileTest.directory?(src)
+ if FileTest.directory?(src)
cp_images(src,dest)
end
end
@@ -5240,7 +5802,7 @@ WOK
end
else SiSU_Screen::Ansi.new(@cmd,"modify css is not set or is set to: false").warn if @cmd=~/[MV]/
end
- fn_css=SiSU_Env::CSS_default.new
+ fn_css=SiSU_Env::CSS_Default.new
css=SiSU_Style::CSS.new
path_style="#{@env.path.output}/#{@env.path.style}"
FileUtils::mkdir_p(path_style) unless FileTest.directory?(path_style)