diff options
-rw-r--r-- | lib/sisu/v0/embedded.rb | 51 | ||||
-rw-r--r-- | lib/sisu/v0/sysenv.rb | 634 |
2 files changed, 458 insertions, 227 deletions
diff --git a/lib/sisu/v0/embedded.rb b/lib/sisu/v0/embedded.rb index 22835e8f..b5d33ac2 100644 --- a/lib/sisu/v0/embedded.rb +++ b/lib/sisu/v0/embedded.rb @@ -83,13 +83,16 @@ module SiSU_Embedded def images src="#{Dir.pwd}/_sisu/image" ldest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image" - rdest="#@rhost/#{@env.path.stub_pwd}/_sisu/image" - if @md.cmd.inspect =~/[vVMR]/ and FileTest.directory?(src) - File.mkpath(ldest) unless FileTest.directory?(ldest) - src_ec="#{src}/" + @md.ec[:image].join(" #{src}/") - SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync - if @md.cmd.inspect =~/R/ #rsync to remote image directory - SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + @rhost.each do |remote_conn| + rdest="#{remote_conn[:name]}/#{@env.path.stub_pwd}/_sisu/image" + if @md.cmd.inspect =~/[vVMR]/ \ + and FileTest.directory?(src) + File.mkpath(ldest) unless FileTest.directory?(ldest) + src_ec="#{src}/" + @md.ec[:image].join(" #{src}/") + SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync + if @md.cmd.inspect =~/R/ #rsync to remote image directory + SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + end end end end @@ -97,13 +100,16 @@ module SiSU_Embedded #p @md.ec[:audio] src="#{Dir.pwd}/_sisu/mm/audio" ldest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/mm/audio" - rdest="#@rhost/#{@env.path.stub_pwd}/_sisu/mm/audio" - if @md.cmd.inspect =~/[vVMR]/ and FileTest.directory?(src) - File.mkpath(ldest) unless FileTest.directory?(ldest) - src_ec="#{src}/" + @md.ec[:audio].join(" #{src}/") - SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync - if @md.cmd.inspect =~/R/ #rsync to remote audio directory - SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + @rhost.each do |remote_conn| + rdest="#{remote_conn[:name]}/#{@env.path.stub_pwd}/_sisu/mm/audio" + if @md.cmd.inspect =~/[vVMR]/ \ + and FileTest.directory?(src) + File.mkpath(ldest) unless FileTest.directory?(ldest) + src_ec="#{src}/" + @md.ec[:audio].join(" #{src}/") + SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync + if @md.cmd.inspect =~/R/ #rsync to remote audio directory + SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + end end end end @@ -111,13 +117,16 @@ module SiSU_Embedded #p @md.ec[:multimedia] src="#{Dir.pwd}/_sisu/mm/video" ldest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/mm/video" - rdest="#@rhost/#{@env.path.stub_pwd}/_sisu/mm/video" - if @md.cmd.inspect =~/[vVMR]/ and FileTest.directory?(src) - File.mkpath(ldest) unless FileTest.directory?(ldest) - src_ec="#{src}/" + @md.ec[:multimedia].join(" #{src}/") - SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync - if @md.cmd.inspect =~/R/ #rsync to remote video directory - SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + @rhost.each do |remote_conn| + rdest="#{remote_conn[:name]}/#{@env.path.stub_pwd}/_sisu/mm/video" + if @md.cmd.inspect =~/[vVMR]/ \ + and FileTest.directory?(src) + File.mkpath(ldest) unless FileTest.directory?(ldest) + src_ec="#{src}/" + @md.ec[:multimedia].join(" #{src}/") + SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync + if @md.cmd.inspect =~/R/ #rsync to remote video directory + SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + end end end end diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb index a06af89d..e5c2c394 100644 --- a/lib/sisu/v0/sysenv.rb +++ b/lib/sisu/v0/sysenv.rb @@ -101,9 +101,11 @@ module SiSU_Env prcss_dir='_sisu_processing' prcss_dir_tmp_root="/tmp/#{prcss_dir}" prcss_dir_stub="#{prcss_dir}/#{@stub_pwd}" - @processing_dir=if @@home and File.writable?("#{@@home}/."); "#{@@home}/#{prcss_dir_stub}" + @processing_dir=if @@home \ + and File.writable?("#{@@home}/.") + "#{@@home}/#{prcss_dir_stub}" #elsif File.writable?("#{@@pwd}/."); "#{@@pwd}/#{prcss_dir}" - else prcss_dir_stub + else prcss_dir_stub end tmp_processing_base=if @@user; "#{prcss_dir_tmp_root}/#{@@user}/#{@stub_pwd}" else "#{prcss_dir_stub}" @@ -115,7 +117,11 @@ module SiSU_Env else "/tmp/#{prcss_dir_stub}" end user=ENV['USER'] - port_pgsql=if defined? ENV['PGPORT'] and not (ENV['PGPORT'].nil? or ENV['PGPORT'].empty?) and ENV['PGPORT']=~/^\d+$/; ENV['PGPORT'] + port_pgsql=if defined? ENV['PGPORT'] \ + and not (ENV['PGPORT'].nil? \ + or ENV['PGPORT'].empty?) \ + and ENV['PGPORT']=~/^\d+$/ + ENV['PGPORT'] else '5432' end IMAGES=:images @@ -230,7 +236,9 @@ module SiSU_Env break end end - if load_prog and @prog=~/dbi/; require 'dbi' #revisit + if load_prog \ + and @prog=~/dbi/ + require 'dbi' #revisit end if load_prog; require @prog else @@ -269,7 +277,8 @@ module SiSU_Env def yamlrc unless @@rc @yamlrc_path.each do |v| - if @@noyaml or FileTest.exist?("#{v}/noyaml") + if @@noyaml \ + or FileTest.exist?("#{v}/noyaml") puts "WARNING - YAML loading switched off, to enable delete the file:\n\t#{v}/noyaml\n\n" unless @@noyaml @@noyaml=true break @@ -298,7 +307,8 @@ module SiSU_Env def ads #WORK AREA tell_no_yaml='WARNING - YAML loading switched off, to enable delete the file:' @ad_path.each do |v| - if @@noyaml or FileTest.exist?("#{v}/noyaml") + if @@noyaml \ + or FileTest.exist?("#{v}/noyaml") puts tell_no_yaml + "\n\t#{v}/noyaml\n" unless @@noyaml @@noyaml=true break @@ -317,7 +327,8 @@ module SiSU_Env end end @ad_path.each do |v| - if @@noyaml or FileTest.exist?("#{v}/noyaml") + if @@noyaml \ + or FileTest.exist?("#{v}/noyaml") puts tell_no_yaml + "\n\t#{v}/noyaml\n" unless @@noyaml @@noyaml=true break @@ -348,10 +359,13 @@ module SiSU_Env @sys=Info_system.instance @rc=Get_init.instance.yamlrc @ad=Get_init.instance.ads - if @fns and @fns != '' and @fns !=@@fns + if @fns \ + and @fns != '' \ + and @fns !=@@fns @@fns,@@fnn,@@fnb,@@fnt,@@flv,@@fnz=@fns,nil,nil,nil,nil,nil end - if @fns and @fns != '' #watch + if @fns \ + and @fns != '' #watch if multilingual m=/((.+?)(?:\~\w{2,3})?)\.((?:-|ssm\.)?sst|ssm)$/ @@fnn ||=@fns[m,1] @@ -373,13 +387,16 @@ module SiSU_Env @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'] - else true + if defined? @rc['default']['multilingual'] \ + and @rc['default']['multilingual'] != nil + @rc['default']['multilingual'] + else true end end def document_language_versions_found @fn={} - unless (@fns.nil? or @fns.empty?) + unless (@fns.nil? \ + or @fns.empty?) if multilingual m=/((.+?)(?:\~\w{2,3})?)\.((?:-|ssm\.)?sst$)/ @fn[:b],@fn[:m],@fn[:t]=@fns[m,1],@fns[m,2],@fns[m,3] @@ -409,7 +426,8 @@ module SiSU_Env ob=output_base @fn={} @m=[] - unless (@fns.nil? or @fns.empty?) + unless (@fns.nil? \ + or @fns.empty?) if multilingual m=/((.+?)(?:\~\w{2,3})?)\.((?:-|ssm\.)?sst$)/ @fn[:b],@fn[:m],@fn[:t]=@fns[m,1],@fns[m,2],@fns[m,3] @@ -510,7 +528,9 @@ module SiSU_Env if program_found?(program) encoding=%x{file #{fnsp}}.strip encoding.gsub!(/#{fnsp}:(\s+|$)/,'') - encoding=if encoding and not encoding.empty?; encoding + encoding=if encoding \ + and not encoding.empty? + encoding else 'UTF-8 assumed, encoding undetermined' end puts encoding if cmd =~/[VM]/ @@ -520,7 +540,9 @@ module SiSU_Env end def wc #word count program='wc' - if program_found?(program) and locale !~/utf-?8/i; true + if program_found?(program) \ + and locale !~/utf-?8/i + true else program_ref="(not available)" unless program_found?(program) program_ref="(UTF-8)" if locale =~/utf-?8/i @@ -764,9 +786,14 @@ module SiSU_Env super() #you may not want to re-execute this tatic info so frequently! @fns,@md=fns,md @env=Env_call.new(fns) if fns - fnb=if @md and defined? @md.fnb; @md.fnb - elsif defined? @env.fnb and @env.fnb; @env.fnb - elsif not @fns.nil? and not @fns.empty? + fnb=if @md \ + and defined? @md.fnb + @md.fnb + elsif defined? @env.fnb \ + and @env.fnb + @env.fnb + elsif not @fns.nil? \ + and not @fns.empty? m=/(.+)?\.(?:(?:-|ssm\.)?sst|ssm)$/m @fns[m,1] if not @fns.empty? end @@ -799,7 +826,8 @@ module SiSU_Env @sys.locale end def concord_max - concord_max=if defined? @rc['processing']['concord_max'] and @rc['processing']['concord_max'] + concord_max=if defined? @rc['processing']['concord_max'] \ + and @rc['processing']['concord_max'] @rc['processing']['concord_max'] else defaults[:concord_max] end @@ -826,7 +854,10 @@ module SiSU_Env # doc [relevant skin if any other than default] # image [all images for specific document gathered here] sisupod_processing_path="#{path.processing}/sisupod" - rm_rf(sisupod_processing_path) if FileTest.directory?(sisupod_processing_path) or FileTest.file?(sisupod_processing_path) + if FileTest.directory?(sisupod_processing_path) \ + or FileTest.file?(sisupod_processing_path) + rm_rf(sisupod_processing_path) + end paths=[] paths=["#{path.processing}/sisupod/_sisu/skin/doc","#{path.processing}/sisupod/_sisu/skin/dir","#{path.processing}/sisupod/_sisu/skin/site","#{path.processing}/sisupod/_sisu/image"] paths.each {|x| File.mkpath(x) unless FileTest.directory?(x) } @@ -846,10 +877,15 @@ module SiSU_Env @flag[:ad]=if @md.flag_promo && @ad[:flag_promo] @flag[:md]=true true - elsif defined? @vz.widget_promo and not @vz.widget_promo.nil? and @vz.widget_promo.class == Array and @vz.widget_promo.length > 0 + elsif defined? @vz.widget_promo \ + and not @vz.widget_promo.nil? \ + and @vz.widget_promo.class == Array \ + and @vz.widget_promo.length > 0 @flag[:sk]=true true - elsif defined? @rc['promo'] and not @rc['promo'].nil? and @rc['promo'].length > 0 + elsif defined? @rc['promo'] \ + and not @rc['promo'].nil? \ + and @rc['promo'].length > 0 @flag[:rc]=true true else @@ -862,16 +898,17 @@ module SiSU_Env flag=false if defined? @rc['search'] searches.each do |type| - flag=if defined? @rc['search'][type] and - defined? @rc['search'][type]['action'] and - @rc['search'][type]['flag']==true and - @rc['search'][type]['action'] =~/https?:\/\// #and - #defined? @rc['search'][type]['db'] and @rc['search'][type]['db'] =~/\S+/ # and + flag=if defined? @rc['search'][type] \ + and defined? @rc['search'][type]['action'] \ + and @rc['search'][type]['flag']==true \ + and @rc['search'][type]['action'] =~/https?:\/\// flag=if promo?[:ad] false - elsif defined? @vz.widget_search and @vz.widget_search == true + elsif defined? @vz.widget_search \ + and @vz.widget_search == true true - elsif defined? @rc['search'][type]['flag'] and @rc['search'][type]['flag'] == true + elsif defined? @rc['search'][type]['flag'] \ + and @rc['search'][type]['flag'] == true true else false end @@ -887,14 +924,18 @@ module SiSU_Env searches=['sisu','hyperestraier'] flag=if defined? @rc['search'] searches.each do |type| |