aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/sysenv.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2007-10-14 21:29:55 +0100
committerRalph Amissah <ralph@amissah.com>2007-10-14 21:29:55 +0100
commit69e8c05210e249e679b259cb843a5e708273e9be (patch)
tree065b61391a561df11711106e4767d6d0b2a7225e /lib/sisu/v0/sysenv.rb
parentremote, (put, get) in single file; embedded content, posted locally and remot... (diff)
shared markup source output moved to own common src directory
Diffstat (limited to 'lib/sisu/v0/sysenv.rb')
-rw-r--r--lib/sisu/v0/sysenv.rb173
1 files changed, 111 insertions, 62 deletions
diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb
index 4080795d..1c684052 100644
--- a/lib/sisu/v0/sysenv.rb
+++ b/lib/sisu/v0/sysenv.rb
@@ -339,9 +339,9 @@ module SiSU_Env
end
end
class Env_call
- @@rc,@@fns,@@fnn,@@fnb,@@fnt,@@flv=nil,nil,nil,nil,nil,nil
+ @@rc,@@fns,@@fnn,@@fnb,@@fnt,@@flv,@@fnz=nil,nil,nil,nil,nil,nil,nil
@@ad={}
- attr_accessor :rc,:fnn,:fnb,:fnt,:fnv,:ad
+ attr_accessor :rc,:fnn,:fnb,:fnt,:fnv,:fnz,:ad
def initialize(fns='')
super()
@fns=fns
@@ -349,7 +349,7 @@ module SiSU_Env
@rc=Get_init.instance.yamlrc
@ad=Get_init.instance.ads
if @fns and @fns != '' and @fns !=@@fns
- @@fns,@@fnn,@@fnb,@@fnt,@@flv=@fns,nil,nil,nil,nil
+ @@fns,@@fnn,@@fnb,@@fnt,@@flv,@@fnz=@fns,nil,nil,nil,nil,nil
end
if @fns and @fns != '' #watch
if multilingual
@@ -358,13 +358,19 @@ module SiSU_Env
@@fnb ||=@fns[m,2]
@@fnt ||=@fns[m,3]
@@flv ||=document_language_versions_found[:f]
+ @@fnz ||=if @@fns =~/(?:\~\S{2,3})?\.(?:_sst|ssm)$/; @@fnb + '.ssm.zip'
+ else @@fnb + '.sst.zip'
+ end
else m=/(.+?)\.([_-]?sst|ssm)$/
@@fnb ||=@fns[m,1]
@@fnm ||=@fns[m,1]
@@fnt ||=@fns[m,2]
+ @@fnz ||=if @@fns =~/(?:\~\S{2,3})?\.(?:_sst|ssm)$/; @@fnb + '.ssm.zip'
+ else @@fnb + '.sst.zip'
+ end
end
end
- @fnn,@fnb,@fnt,@flv=@@fnn,@@fnb,@@fnt,@@flv
+ @fnn,@fnb,@fnt,@flv,@fnz=@@fnn,@@fnb,@@fnt,@@flv,@@fnz
end
def multilingual
if defined? @rc['default']['multilingual'] and @rc['default']['multilingual'] != nil; @rc['default']['multilingual']
@@ -442,7 +448,10 @@ module SiSU_Env
def filename(code,name,suffix)
d=SiSU_Env::Info_env.new(@fns)
fnl=d.i18n.lang_filename(code)
- "#{fnl[:pre]}#{name}#{fnl[:mid]}#{suffix}#{fnl[:post]}"
+ if code
+ "#{fnl[:pre]}#{name}#{fnl[:mid]}#{suffix}#{fnl[:post]}"
+ else "#{name}#{suffix}"
+ end
end
def lang(code)
@fn={
@@ -469,7 +478,8 @@ module SiSU_Env
:sitemap_touch => filename(code,"sitemap_#@fnb",'.xml'),
:sxs => filename(code,@fnb,'.sxs.xml'),
:sxd => filename(code,@fnb,'.sxd.xml'),
- :sxn => filename(code,@fnb,'.sxn.xml')
+ :sxn => filename(code,@fnb,'.sxn.xml'),
+ :sisupod => filename(nil,@fnz,'')
}
@fn
end
@@ -747,7 +757,7 @@ module SiSU_Env
class Info_env < Env_call
require 'fileutils'
include FileUtils
- attr_accessor :filename,:sys,:home,:hostname,:user,:env,:rc,:www,:fnb,:fnn,:fnt,:flv,:webserv_path,:stub_pwd,:webserv_host_cgi,:webserv_port_cgi,:processing,:etc,:yamlrc_dir
+ attr_accessor :filename,:sys,:home,:hostname,:user,:env,:rc,:www,:fnb,:fnn,:fnt,:flv,:webserv_path,:stub_pwd,:stub_src,:webserv_host_cgi,:webserv_port_cgi,:processing,:etc,:yamlrc_dir
@@image_flag,@@local_image=true,true #warning on @@image_flag
@@fb=@@man_path=nil,nil
def initialize(fns='',md=nil)
@@ -768,6 +778,7 @@ module SiSU_Env
@pwd=@@pwd||=Dir.pwd
m=/.+\/(\S+)/m
@stub_pwd=@@pwd[m,1]
+ @stub_src=@stub_pwd + '/src'
end
def user
@sys.user
@@ -800,6 +811,9 @@ module SiSU_Env
def stub_pwd #200412
@stub_pwd
end
+ def stub_src
+ @stub_src
+ end
def sisupod
#path.processing
# sisupod
@@ -1121,6 +1135,9 @@ WOK
def stub_pwd
@stub_pwd
end
+ def stub_src
+ @stub_src
+ end
def etc
defaults[:sisu_etc] #live/dynamic
# @sys.sisu_etc #broken: live/dynamic
@@ -1208,6 +1225,9 @@ WOK
def output #web/webserv output directory... subdirectory into which further subdirectories are made based on file names
"#{path.webserv}/#@stub_pwd"
end
+ def output_src #web/webserv output directory... subdirectory into which further subdirectories are made based on file names
+ "#{path.webserv}/src"
+ end
def manpage
"#{path.output}/man"
end
@@ -1892,7 +1912,7 @@ WOK
end
if @md.cmd =~ /s/; ft << @md.fns
end
- if @md.cmd =~ /S/; ft << 'sisupod.zip' << '.kdi'
+ if @md.cmd =~ /S/; ft << @md.fn[:sisupod] << '.kdi'
end
@fnb=@md.fnb
else # still needed where/when param is not parsed
@@ -1912,7 +1932,7 @@ WOK
end
if @opt.cmd =~ /i/; ft << '.1' << '??.man.1' << 'man.??.1'
end
- if @opt.cmd =~ /a/; ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt'
+ if @opt.cmd =~ /a/; ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt'
end
if @opt.cmd =~ /[g]/; ft << 'wiki.txt' << '??.wiki.txt' << 'wiki.??.txt'
end
@@ -1924,7 +1944,7 @@ WOK
end
if @opt.cmd =~ /s/; ft << '.sst' << '.ssi' << '.ssm'
end
- if @opt.cmd =~ /S/; ft << 'sisupod.zip' << '.kdi'
+ if @opt.cmd =~ /S/; ft << '.zip' << '.kdi'
end
if @opt.mod.inspect =~ /sxm|sxs|xml/; ft << @fnb << '.sxs.xml'
end
@@ -1943,6 +1963,9 @@ WOK
@source_path=if @fnb and not @fnb.empty?; "#{@env.path.output}/#@fnb"
else @env.path.output
end
+ @source_path_src=if @fnb and not @fnb.empty?; "#{@env.path.output}/src"
+ else @env.path.output_src
+ end
@local_sisu_source=if @filetypes =~/\S/; "#@source_path/#@filetypes"
else @source_path
end
@@ -2019,105 +2042,131 @@ WOK
remote_host_base_general[:name]
end
def scp #sort out later using ruby libraries #not ideal, first time each file is sent, -r must be called separately for subdir to be built
- input=@local_sisu_source
- output=case @opt.cmd
+ local=@source_path
+ remote=case @opt.cmd
when /u/; "#{self.remote_host_base}/#{@env.path.stub_pwd}/." #creates remote directory tree, this is not the usual function of u
when /[abhHNopwxXy]/; "#{self.remote_host_base}/#{@env.path.stub_pwd}/#{@fnb}/."
else "#{self.remote_host_base}/#{@env.path.stub_pwd}/."
end
- if (input =~/\S/ and input !~/\/\//) and (output =~/\S/ and output !~/\/\//) and @@flag_remote==true and @opt.cmd !~/U/
- System_call.new(input,output).scp
- elsif @opt.cmd =~/U/; puts "#{input} -> #{output}"
- else puts 'suspect scp request, ignored'
+ #remote="#{self.remote_host_base}/#{@env.path.stub_pwd}/."
+ local_src=@source_path_src
+ remote_src="#{self.remote_host_base}/#{@env.path.stub_src}/."
+ src_txt=@opt.fnc
+ src_pod=@opt.fncb.gsub(/(\.ss[mt])(?:\.sst)?$/,'\1.zip')
+ if (local =~/\S/ and local !~/\/\//) and (remote =~/\S/ and remote !~/\/\//) and @@flag_remote==true and @opt.cmd !~/U/
+ System_call.new(local,remote).scp
+ if FileTest.file?("#{local_src}/#{src_txt}") or FileTest.file?("#{local_src}/#{src_pod}")
+ System_call.new("#{local_src}/#{src_txt} #{local_src}/#{src_pod}",remote_src).scp
+ end
+ elsif @opt.cmd =~/U/
+ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
+ puts "#{local} -> #{remote}"
+ if FileTest.file?("#{local_src}/#{src_doc}") or FileTest.file?("#{local_src}/#{src_doc}.zip")
+ puts "#{local_src}/#{src_doc}* -> #{remote_src}"
+ end
+ else
+ puts 'suspect scp request, ignored'
+ puts "#{local} -> #{remote} remote flag: #@@flag_remote"
+ puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
end
end
def rsync
- input=@source_path
- output="#{self.remote_host_base}/#{@env.path.stub_pwd}/."
- if (input =~/\S/ and input !~/\/\//) and (output =~/\S/ and output !~/\/\//) and @@flag_remote==true and @opt.cmd !~/U/
- System_call.new(input,output,@opt.cmd).rsync('--delete-after')
+ local=@source_path
+ remote="#{self.remote_host_base}/#{@env.path.stub_pwd}/."
+ local_src=@source_path_src
+ remote_src="#{self.remote_host_base}/#{@env.path.stub_src}/."
+ src_txt=@opt.fnc
+ src_pod=@opt.fncb.gsub(/(\.ss[mt])(?:\.sst)?$/,'\1.zip')
+ if (local =~/\S/ and local !~/\/\//) and (remote =~/\S/ and remote !~/\/\//) and @@flag_remote==true and @opt.cmd !~/U/
+ System_call.new(local,remote,@opt.cmd).rsync('--delete-after')
+ if FileTest.file?("#{local_src}/#{src_txt}") or FileTest.file?("#{local_src}/#{src_pod}")
+ System_call.new("#{local_src}/#{src_txt} #{local_src}/#{src_pod}",remote_src,@opt.cmd).rsync
+ end
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
- puts "#{input} -> #{output}"
+ puts "#{local} -> #{remote}"
+ if FileTest.file?("#{local_src}/#{src_doc}") or FileTest.file?("#{local_src}/#{src_doc}.zip")
+ puts "#{local_src}/#{src_doc}* -> #{remote_src}"
+ end
else
puts 'suspect rsync request, ignored'
- puts "#{input} -> #{output} remote flag: #@@flag_remote"
+ puts "#{local} -> #{remote} remote flag: #@@flag_remote"
puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
end
end
def scp_base #base site
- input=@source_path
- output="#{remote_host_base}/#{@env.path.stub_pwd}/."
+ local=@source_path
+ remote="#{remote_host_base}/#{@env.path.stub_pwd}/."
if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] and @@flag_remote==true and @opt.cmd !~/U/
- puts "begin scp_base: #{input} -> #{output}"
- System_call.new("#{input}/#{@env.path.style}/",output).scp
+ puts "begin scp_base: #{local} -> #{remote}"
+ System_call.new("#{local}/#{@env.path.style}/",remote).scp
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
- puts "begin scp_base: #{input} -> #{output}"
- puts "#{input}/#{@env.path.style}/ -> #{output}"
+ puts "begin scp_base: #{local} -> #{remote}"
+ puts "#{local}/#{@env.path.style}/ -> #{remote}"
else puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
end
end
def scp_base_all #base site
- input=@source_path
- output="#{remote_host_base}/#{@env.path.stub_pwd}/."
+ local=@source_path
+ remote="#{remote_host_base}/#{@env.path.stub_pwd}/."
if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] and @@flag_remote==true and @opt.cmd !~/U/
- puts "begin scp_base_all: #{input} -> #{output}"
- System_call.new("#{input}/_sisu/image/",output).scp
- System_call.new("#{input}/_sisu/image_local/",output).scp
- System_call.new("#{input}/#{@env.path.style}/",output).scp
+ puts "begin scp_base_all: #{local} -> #{remote}"
+ System_call.new("#{local}/_sisu/image/",remote).scp
+ System_call.new("#{local}/_sisu/image_local/",remote).scp
+ System_call.new("#{local}/#{@env.path.style}/",remote).scp
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
- puts "scp_base_all: #{input} -> #{output}"
- puts "#{input}/_sisu/image/ -> #{output}"
- puts "#{input}/_sisu/image_local/ -> #{output}"
- puts "#{input}/#{@env.path.style}/ -> #{output}"
+ puts "scp_base_all: #{local} -> #{remote}"
+ puts "#{local}/_sisu/image/ -> #{remote}"
+ puts "#{local}/_sisu/image_local/ -> #{remote}"
+ puts "#{local}/#{@env.path.style}/ -> #{remote}"
else puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
end
end
def rsync_base #base site
- input=@source_path
- output="#{remote_host_base}/#{@env.path.stub_pwd}/."
+ local=@source_path
+ remote="#{remote_host_base}/#{@env.path.stub_pwd}/."
if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] and @@flag_remote==true and @opt.cmd !~/U/
- #puts "begin rsync_base: #{input} -> #{output}"
- #System_call.new("#{input}/_sisu/image/",output).rsync
- #System_call.new("#{input}/_sisu/image_local/",output).rsync
- #System_call.new("#{input}/#{@env.path.style}/",output).rsync
+ #puts "begin rsync_base: #{local} -> #{remote}"
+ #System_call.new("#{local}/_sisu/image/",remote).rsync
+ #System_call.new("#{local}/_sisu/image_local/",remote).rsync
+ #System_call.new("#{local}/#{@env.path.style}/",remote).rsync
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
- puts "rsync_base: #{input} -> #{output}"
- puts "#{input}/_sisu/image/ -> #{output}"
- puts "#{input}/_sisu/image_local/ -> #{output}"
- puts "#{input}/#{@env.path.style}/ -> #{output}"
+ puts "rsync_base: #{local} -> #{remote}"
+ puts "#{local}/_sisu/image/ -> #{remote}"
+ puts "#{local}/_sisu/image_local/ -> #{remote}"
+ puts "#{local}/#{@env.path.style}/ -> #{remote}"
else puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
end
end
def rsync_base_sync #base site
- input=@source_path
- output="#{remote_host_base}/#{@env.path.stub_pwd}/."
+ local=@source_path
+ remote="#{remote_host_base}/#{@env.path.stub_pwd}/."
if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] and @@flag_remote==true and @opt.cmd !~/U/
- puts "begin rsync_base_sync: #{input} -> #{output}"
- System_call.new("#{input}/_sisu/image/",output).rsync('--delete-after')
- System_call.new("#{input}/_sisu/image_local/",output).rsync('--delete-after')
- System_call.new("#{input}/#{@env.path.style}/",output).rsync('--delete-after')
+ puts "begin rsync_base_sync: #{local} -> #{remote}"
+ System_call.new("#{local}/_sisu/image/",remote).rsync('--delete-after')
+ System_call.new("#{local}/_sisu/image_local/",remote).rsync('--delete-after')
+ System_call.new("#{local}/#{@env.path.style}/",remote).rsync('--delete-after')
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
- puts "rsync_base_sync: #{input} -> #{output}"
- puts "#{input}/_sisu/image/ -> #{output}"
- puts "#{input}/_sisu/image_local/ -> #{output}"
- puts "#{input}/#{@env.path.style}/ -> #{output}"
+ puts "rsync_base_sync: #{local} -> #{remote}"
+ puts "#{local}/_sisu/image/ -> #{remote}"
+ puts "#{local}/_sisu/image_local/ -> #{remote}"
+ puts "#{local}/#{@env.path.style}/ -> #{remote}"
else puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
end
end
def rsync_sitemaps #sitemap directory
- input="#@source_path/sitemapindex.xml"
- output="#{remote_host_base}/#{@env.path.stub_pwd}/."
+ local="#@source_path/sitemapindex.xml"
+ remote="#{remote_host_base}/#{@env.path.stub_pwd}/."
if @@flag_remote
#if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] #and @@flag_remote==true and @opt.cmd !~/U/
- System_call.new(input,output).rsync('--delete-after')
+ System_call.new(local,remote).rsync('--delete-after')
elsif @opt.cmd =~/U/
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
- puts "rsync_sitemaps: #{input} -> #{output}"
+ puts "rsync_sitemaps: #{local} -> #{remote}"
else puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
end
end