From 45a35b75f4196bbf30e65b64b4463ab4fb620846 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 28 May 2012 05:25:04 -0400 Subject: v3: sisupod.txz processing * BUG image copying/processing for sisupod --- lib/sisu/v3/dal.rb | 3 +++ lib/sisu/v3/hub.rb | 14 +++++++---- lib/sisu/v3/options.rb | 60 +++++++++++++++++++++++++++++++-------------- lib/sisu/v3/param.rb | 3 ++- lib/sisu/v3/sisupod_make.rb | 21 +++++++++++++--- lib/sisu/v3/sysenv.rb | 6 ++++- 6 files changed, 77 insertions(+), 30 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/dal.rb b/lib/sisu/v3/dal.rb index 476ddb94..dd1ec494 100644 --- a/lib/sisu/v3/dal.rb +++ b/lib/sisu/v3/dal.rb @@ -271,6 +271,9 @@ module SiSU_DAL fn=(@fnx && @fnx =~/\.ss[tmi]$/) \ ? @fnx : @opt.fns + if @opt.fno =~/\.txz$/ + Dir.chdir(@opt.f_pth[:pth]) + end file_array=@env.read_source_file(fn) file_array.each do |l| if l =~/\r\n/; l.gsub!(/\r\n/,"\n") diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index 1e400504..daa75166 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -77,7 +77,9 @@ module SiSU @opt.lng='en' end @@pwd=@opt.pth - Dir.chdir(@opt.pth) #watch + @opt.pth=@opt.f_pths[i][:pth] + @opt.lng=@opt.f_pths[i][:lng] + Dir.chdir(@opt.f_pth[:pth]) #watch @env=SiSU_Env::InfoEnv.new(fns) yield end @@ -108,9 +110,11 @@ module SiSU @opt.pth=Dir.pwd @opt.lng='en' elsif @opt.fno =~/\.txz$/ + @opt.pth=@opt.f_pths[i][:pth] + @opt.lng=@opt.f_pths[i][:lng] else - @opt.pth=@opt.paths[i] - @opt.lng=@opt.lngs[i] + @opt.pth=@opt.f_pths[i][:pth] + @opt.lng=@opt.f_pths[i][:lng] end @@pwd=@opt.pth Dir.chdir(@opt.pth) #watch @@ -332,8 +336,8 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on gsub(/\.ssm$/,'.ssm.sst') @opt.f_pth=@opt.f_pths[i] if @opt.fns !~/\.-sst$/ - @opt.pth=@opt.paths[i] - @opt.lng=@opt.lngs[i] + @opt.pth=@opt.f_pths[i][:pth] + @opt.lng=@opt.f_pths[i][:lng] else @opt.pth=Dir.pwd @opt.lng='en' diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb index 44d4e40e..c7789f3a 100644 --- a/lib/sisu/v3/options.rb +++ b/lib/sisu/v3/options.rb @@ -196,6 +196,7 @@ module SiSU_Commandline def set_files_and_paths_and_general_extract(s) c,w='','' m,f,pth,z,lng,lngs=[],[],[],[],[],[] + lng_is='' a=s.split(/\s+/) r_l=Px[:lng_lst].join('|') a.uniq.each do |x| @@ -208,7 +209,43 @@ module SiSU_Commandline m << x end elsif x =~ /(?:\.(?:(?:-|ssm\.)?sst(?:\.xml)?|ssm|ssi|sx[sdn]\.xml|s[1-3]|kdi|ssp)|\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip))$/ - if x =~/^(?:https?|file):\/\/\S+/ \ + if x =~/\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip)/ + if x =~/^(?:https?|file):\/\/\S+/ #\ + end + pwd=Dir.pwd + fn_pod=x.gsub(/.+?([^\/]+)\.txz$/,'\1') + fullname=@env.processing_path.processing + '/sisupod/' + fn_pod + pt=Pathname.new(fullname) + FileUtils::mkdir_p(pt.to_s) + Dir.chdir(pt.realpath) + options=s.gsub(/(\s+--?\S+)+.+/,'\1') + system(" + chdir #{fullname} + tar xaf #{x} + chdir #{pwd} + ") + Dir.chdir(pt.realpath.to_s + '/sisupod/doc') + r=Px[:lng_lst].join('|') + Dir.entries("#{fullname}/sisupod/doc").each do |d_lng| + if d_lng =~/^(?:#{r})$/ + Dir.chdir(pt.realpath.to_s + "/sisupod/doc/#{d_lng}") + filenames=Dir.glob("*.ss[mt]") + filenames.each do |fn| + f_pths << { + pth: "#{fullname}/sisupod/doc/#{d_lng}", + f: "#{fn}", + pth_stub: 'doc', + lng: d_lng, + lng_is: d_lng, + url_base: '', + url: '' + } + Dir.chdir(pwd) + f << fn + end + end + end + elsif x =~/^(?:https?|file):\/\/\S+/ \ and x =~/\S+?\.ss[mt]$/ r_url=/(http:\/\/\S+?\/\S+?\/src(?:\/(?:#{r_l}))?)\// url_base = (x[r_url,1]) @@ -252,12 +289,7 @@ module SiSU_Commandline url: url } f << fn - elsif x =~/^(?:https?|file):\/\/\S+/ \ - and x =~/\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip)/ - x=x.gsub(/^file:\/\//,'') - f << x elsif FileTest.file?(x) -### FIX pt=Pathname.new(x) pth << pt.split[0].realpath.to_s #remove? f << pt.split[1].to_s #remove? @@ -266,14 +298,7 @@ module SiSU_Commandline l_p = (pt.split[0].realpath.to_s[t,1]) \ ? pt.split[0].realpath.to_s[t,1] : nil - lng << l_p - lngs << if l_p - l_p - elsif x =~/~(#{r_l})\.ss[tm]/ - $1 - else lng_base - end - lng_is =if l_p + lngs << lng_is = if l_p l_p elsif x =~/~(#{r_l})\.ss[tm]/ $1 @@ -283,14 +308,11 @@ module SiSU_Commandline pth: pt.split[0].realpath.to_s, f: pt.split[1].to_s, pth_stub: pt.split[0].realpath.to_s[r_u,1], - lng: (pt.split[0].realpath.to_s[t,1]) \ - ? pt.split[0].realpath.to_s[t,1] - : nil, + lng: lng_is, lng_is: lng_is, url_base: nil, url: nil } -# Dir.chdir(pt.split[0].realpath) else puts "file not found: #{x}" end elsif x =~ /\.termsheet\.rb$/ @@ -301,7 +323,7 @@ module SiSU_Commandline puts "#{x} in #{a.join(' ')}?" end end - { cmd: c, mod: m, what: w, paths: pth, files: f, f_pths: f_pths, lng: lng, lngs: lngs } + { cmd: c, mod: m, what: w, paths: pth, files: f, f_pths: f_pths, lng: lng_is, lngs: lngs } end def expand_numeric_shortcuts(a) shortcut=SiSU_Env::InfoProcessingFlag.new diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index 77b4e8e7..f1c4aa3a 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -90,6 +90,7 @@ module SiSU_Param and @opt.f_pth[:pth] != Dir.pwd #BUG check # you may need to change Dir.pwd to @opt.f_pth[:pth] where the latter # has a path value that is different, however, f_pth is not always set! + Dir.chdir(@opt.f_pth[:pth]) p '-- bug alert -- ' p __FILE__ + ':' + __LINE__.to_s p 'f_pth ' + @opt.f_pth[:pth] @@ -1076,6 +1077,7 @@ module SiSU_Param @rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m @rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/ @rgx_mm=/\{\s*(\S+?\.(?:ogg|mpeg))/ #expand and distinguish ogg + Dir.chdir(@opt.f_pth[:pth]) begin rescue SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@fns).error do @@ -1469,7 +1471,6 @@ module SiSU_Param end @papersize_array=@papersize.scan(/(?:a4|letter|legal|book|a5|b5)/i) fn=@opt.fno #decide what to do a filesize on .ssm tells very little about actual document size - #fn=@fns=~/\.ssm\.sst$/ ? @fns.gsub(/.sst/,'') : @fns #decide what to do a filesize on .ssm tells very little about actual document size @filesize=(File.size(fn)).to_s if @sys.openssl !=false skin=@doc_skin \ diff --git a/lib/sisu/v3/sisupod_make.rb b/lib/sisu/v3/sisupod_make.rb index f438687f..33ae8db2 100644 --- a/lib/sisu/v3/sisupod_make.rb +++ b/lib/sisu/v3/sisupod_make.rb @@ -272,9 +272,22 @@ module SiSU_Doc x[:f].each do |f| pth="#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}" FileUtils::mkdir_p(pth) unless FileTest.directory?(pth) - (@opt.fno =~/\.ssm$/) \ - ? FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}","#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}") - : FileUtils::cp_r("#{@env.path.pwd}/#{f[:f]}","#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}") + if f[:f] =~/\~(\S{2,3})\.ss[tm]$/ + lng_f=$1 + if @opt.lng == lng_f + (@opt.fno =~/\.ssm$/) \ + ? FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}", + "#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}") + : FileUtils::cp_r("#{@env.path.pwd}/#{f[:f]}", + "#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}") + end + else + (@opt.fno =~/\.ssm$/) \ + ? FileUtils::cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}", + "#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}") + : FileUtils::cp_r("#{@env.path.pwd}/#{f[:f]}", + "#{@env.processing_path.processing_sisupod(@opt)}/doc/#{@opt.lng}/#{f[:n]}") + end end end #NB not all possibilies met, revisit, also in case of composite file may wish to add README end @@ -302,7 +315,7 @@ module SiSU_Doc end end __END__ -question?: should you permit the packing of multiple files in single .gz ? +question?: should you permit the packing of multiple documents in single .xz ? open @opt.fns, parse file extract from file content: diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index f699ee92..acc38507 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -1885,7 +1885,11 @@ WOK r=Px[:lng_lst].join('|') u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/ base_stub=@sys.pwd.gsub(u,'\1') - "#{path.webserv}/#{base_stub}" + if Dir.pwd =~/\/sisupod\/[^\/]+\/sisupod\/doc/ + "#{path.webserv}/doc" + else + "#{path.webserv}/#{base_stub}" + end end def feed (defined? @rc['webserv']['feed']) \ -- cgit v1.2.3