aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2011-09-05 11:04:42 -0400
committerRalph Amissah <ralph@amissah.com>2011-09-05 11:08:50 -0400
commit22f6ac004b2b86d8554ddbc5650aa3f11d348d90 (patch)
tree1d25a04955e2915b89a306bbccc7b3bd57f8e994
parentv3: Dir.chdir, remove "system cd" (change directory) use Dir.chdir (diff)
v3: sisupod_v3 make (build); place (rsync); process (generate sisu output from)sisu_3.0.17sisu-3.0.17
* sisupod v3 * modify pod dir structure, place sisu source in dir/[lang_code]/ e.g. dir/en/ * use tar.xz (.txz) * bundle all language version in pod * bundle .ssm and all included files for each selected language (rather than composited .ssm.sst file) (filename pattern) or named in files to be processed string * remote placement * sisu processing from sisupod v3 * rsync sisupod v3 * sysenv, check that tree is available and use as desired when available
-rw-r--r--data/doc/sisu/CHANGELOG_v317
-rw-r--r--lib/sisu/v3/hub.rb52
-rw-r--r--lib/sisu/v3/manifest.rb8
-rw-r--r--lib/sisu/v3/options.rb21
-rw-r--r--lib/sisu/v3/remote.rb7
-rw-r--r--lib/sisu/v3/sisupod_make.rb194
-rw-r--r--lib/sisu/v3/sysenv.rb261
7 files changed, 394 insertions, 166 deletions
diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3
index bebc961e..6749a23e 100644
--- a/data/doc/sisu/CHANGELOG_v3
+++ b/data/doc/sisu/CHANGELOG_v3
@@ -21,6 +21,23 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.0.17.orig.tar.xz
sisu_3.0.17-1.dsc
sisu_3.0.17-1.debian.tar.gz
+ * sisupod v3
+ * modify pod dir structure, place sisu source in dir/[lang_code]/ e.g. dir/en/
+ * use tar.xz (.txz)
+ * bundle all language version in pod
+ * bundle .ssm and all included files for each selected language (rather
+ than composited .ssm.sst file)
+ * [DO] prioritize and warn where duplicate files in directory
+ * [DO] ideally, allow selection those files selected in command line using -G
+ (filename pattern) or named in files to be processed string
+ * remote placement
+ * sisu processing from sisupod v3
+ * [DO] sisu processing from sisupod v2 (retain possibility)
+
+ * rsync sisupod v3
+
+ * sysenv, check that tree is available and use as desired when available
+
* unix conditional tests ? : remove line break marker at end of line before
:, cosmetic
diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb
index 5e288b96..029c2861 100644
--- a/lib/sisu/v3/hub.rb
+++ b/lib/sisu/v3/hub.rb
@@ -70,16 +70,27 @@ module SiSU
end
def pod_output(fns_pod)
dir_pwd=@@env.path.pwd
- dir_pod=@@env.sisupod_gen(fns_pod)
- Dir.chdir(dir_pod)
- content=Dir.glob("*.ss[mt]").join(' ')
- if content =~/\.ss[mt]/
- Dir.chdir(dir_pwd)
- @opt.fns=content #check
- system("cd #{dir_pod}
- sisu -CC #{@opt.cmd} #{@opt.mod.join(' ')} #{content}
- cd -
+ dir_pod=@@env.sisupod_gen_v3(fns_pod)
+ Dir.chdir("#{dir_pod}/doc")
+ #system("ls")
+ files=Dir['*/*.ss[tm]']
+ files_ssm=Dir['*/*.ssm']
+ files_sst=Dir['*/*.sst']
+ content=if files_ssm.length > 0
+ files_ssm.join(' ')
+ elsif files_sst.length > 0
+ files_sst.join(' ')
+ else
+ p 'no files found'
+ end
+ @opt.fns=content #check
+ if FileTest.directory?("#{dir_pod}/doc")
+ Dir.chdir("#{dir_pod}/doc")
+ system("
+ sisu3 -CC #{@opt.cmd} #{@opt.mod.join(' ')} #{content}
+ #sisu3 -CC #{@opt.cmd} -G #{@opt.mod.join(' ')} #{content}
")
+ Dir.chdir(dir_pwd)
end
@pwd=`pwd`.strip
Dir.chdir(@pwd)
@@ -92,10 +103,15 @@ module SiSU
if not @opt.files.empty?
@opt.files.each_with_index do |fns,i|
env=SiSU_Env::Info_env.new(fns)
- if fns =~ /sisupod(?:\.zip)?|\S+?(?:\.ss[mt]\.zip|\.ssp)$/
+ if fns =~ /sisupod(?:\.txz)?|\S+?(?:\.ss[mt]\.txz|\.ssp)$/
# env=SiSU_Env::Info_env.new(fns)
require_relative 'remote' # remote.rb #check
- pod_name=SiSU_Remote::Remote_download.new(fns).pod.name
+ pod_name=if fns =~ /http:\/\/\S+?(?:\.ss[mt]\.txz|\.ssp)$/
+ SiSU_Remote::Remote_download.new(fns).pod.name
+ else
+ re_p=/(\S+?\.ss[mt](?:\.txz)?)$/
+ re_p.match(fns).captures.join
+ end
SiSU_Screen::Ansi.new(@opt.cmd,pod_name).puts_blue unless @opt.cmd =~/q/
@opt.files.shift
pod_output(pod_name)
@@ -317,7 +333,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
path[:xsd]=path[:xml] + '/xsd'
path[:xsd]=path[:xml] + '/rnc'
path[:xsd]=path[:xml] + '/rng'
- re_p=/(sisupod(?:\.zip)?|\S+?\.ss[mt]\.zip|[^\/]+?\.ssp)$/
+ re_p=/(sisupod(?:\.txz)?|\S+?\.ss[mt]\.txz|[^\/]+?\.ssp)$/
unless @opt.files.join(',') =~ re_p #do not mix pods with source markup files in command line
unless ( FileTest.directory?(path[:css]) \
and FileTest.directory?(path[:xsd]) )
@@ -361,9 +377,10 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
begin
path_image='./_sisu/processing/external_document/image'
path_skin='./_sisu/processing/external_document/skin/doc'
- @get_s,@get_p=[],[]
+ @get_s,@get_p,@get_pl=[],[],[]
re_s=/((?:https?|file):\/\/\S+?\.sst)$/
- re_p=/((?:https?|file):\/\/\S+?(?:\/\S+?\.ss[mt]\.zip|sisupod(?:\.zip)?|\.ssp))/
+ re_p=/((?:https?|file):\/\/\S+?(?:\/\S+?\.ss[mt]\.txz|sisupod(?:\.txz)?|\.ssp))/
+ re_pl=/^(\/\S+?\.ss[mt]\.txz)/
@opt.files.each do |fns|
if fns =~re_s
@get_s << re_s.match(fns)[1] if re_s
@@ -371,6 +388,9 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
if fns =~re_p
@get_p << re_p.match(fns)[1] if re_p
end
+ if fns =~re_pl
+ @get_pl << re_pl.match(fns)[1] if re_p
+ end
end
if @get_s.length > 0 #% remote markup file .sst
require_relative 'remote' # remote.rb
@@ -394,7 +414,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
end
@opt.files=@opt.files.collect {|x| x=x.gsub(/\.ssm$/,'.ssm.sst') }
if @opt.act[:sisupod] #% --sisupod, -S make sisupod
- op('sisupod_make','sisupod (zip)')
+ op('sisupod_make','sisupod (txz)')
if @opt.fns=~/\.kdi._sst/
op('share_src_kdissert','kdissert (kdi)') #% -S share kdissert source
end
@@ -535,7 +555,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
@opt.files.each do |fns|
if FileTest.file?(fns)
@opt.fns=fns
- unless @opt.fns =~ /(?:\.(?:(?:-|ssm\.)?sst|ssm|ssp|sx[sdn]\.xml|termsheet.rb)|\S+?\.ss[mt]\.zip|sisupod(?:\.zip)?|\S+?\.ssp)$/
+ unless @opt.fns =~ /(?:\.(?:(?:-|ssm\.)?sst|ssm|ssp|sx[sdn]\.xml|termsheet.rb)|\S+?\.ss[mt]\.txz|sisupod(?:\.txz)?|\S+?\.ssp)$/
if @opt.cmd.inspect=~/-P/
elsif @opt.fns=~/\.kdi$/ \
and @opt.mod.inspect =~/--(?:convert(?:-from)?|from)[=-]kdi/
diff --git a/lib/sisu/v3/manifest.rb b/lib/sisu/v3/manifest.rb
index d4e150f0..3b34d0b2 100644
--- a/lib/sisu/v3/manifest.rb
+++ b/lib/sisu/v3/manifest.rb
@@ -456,8 +456,7 @@ WOK
else
if FileTest.file?(@f.place_file.src.dir)==true
pth=@f.output_path.src.dir
- rel=@f.output_path.src.rel
- #rel=@f.output_path.src.rel_sm
+ rel=@f.output_path.src.rel_sm
url=@f.output_path.src.url
id,file='Markup (SiSU source)',@f.base_filename.src
summarize_sources(id,file,pth,rel,url)
@@ -465,10 +464,9 @@ WOK
end
if FileTest.file?(@f.place_file.sisupod.dir)==true
pth=@f.output_path.sisupod.dir
- rel=@f.output_path.sisupod.rel
- #rel=@f.output_path.sisupod.rel_sm
+ rel=@f.output_path.sisupod.rel_sm
url=@f.output_path.sisupod.url
- id,file='SiSU doc (zip)',@f.base_filename.sisupod
+ id,file='SiSU doc (tar.xz)',@f.base_filename.sisupod
summarize_sources(id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.pot.dir)==true
diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb
index 77031ea4..ac31a896 100644
--- a/lib/sisu/v3/options.rb
+++ b/lib/sisu/v3/options.rb
@@ -62,9 +62,9 @@ module SiSU_commandline
require_relative 'sysenv' # sysenv.rb
@@base_path=nil
class Options
- attr_accessor :cmd,:mod,:act,:dir_structure_by,:f_pths,:files,:base_path,:base_stub,:paths,:lngs,:f_pth,:pth,:fns,:fnb,:fnc,:fncb,:lng,:lng_base,:what
+ attr_accessor :cmd,:mod,:act,:dir_structure_by,:f_pths,:files,:base_path,:base_stub,:sub_location,:paths,:lngs,:f_pth,:pth,:fns,:fnb,:fnc,:fncb,:lng,:lng_base,:what
def initialize(a)
- @cmd,@f_pth,@pth,@fns,@fnb,@fnc,@fncb,@what,@lng,@lng_base,@base_path,@base_stub='','','','','','','','','','','','',''
+ @cmd,@f_pth,@pth,@fns,@fnb,@fnc,@fncb,@what,@lng,@lng_base,@base_path,@base_stub,@sub_location='','','','','','','','','','','','',''
@f_pths,@files,@paths,@mod,@act=Array.new(5){[]}
@env=SiSU_Env::Info_env.new
@lng_base=@env.language_default_set
@@ -197,12 +197,18 @@ module SiSU_commandline
a.uniq.each do |x|
if x =~/^-[a-z0-5]+/i \
or x =~/^--\S+/
- if x =~/^-([a-z0-5]+)/i; c << $1
+ if x =~/^-([a-z0-5]+)/i
+ c << $1
end
- if x =~/^--\S+/; m << x
+ if x =~/^--\S+/
+ m << x
end
- elsif x =~ /(?:\.(?:(?:-|ssm\.)?sst(?:\.xml)?|ssm|ssi|sx[sdn]\.xml|s[1-3]|kdi|ssp)|\S+?\.ss[mt]\.zip|sisupod(\.zip)?)$/
- if x =~/^(?:https?|file):\/\/\S+/; f << x
+ elsif x =~ /(?:\.(?:(?:-|ssm\.)?sst(?:\.xml)?|ssm|ssi|sx[sdn]\.xml|s[1-3]|kdi|ssp)|\S+?\.ss[mt]\.txz|sisupod(\.txz)?)$/
+ if x =~/^(?:https?|file):\/\/\S+/ \
+ or x =~/\S+?\.ss[mt]\.txz|sisupod\.txz/ \
+ && FileTest.file?(x)
+ x=x.gsub(/^file:\/\//,'')
+ f << x
elsif FileTest.file?(x)
### FIX
pt=Pathname.new(x)
@@ -586,6 +592,9 @@ module SiSU_commandline
def pth
@pth
end
+ def sub_location
+ pth.gsub(/#{base_path}/,'')
+ end
def lng
@lng
end
diff --git a/lib/sisu/v3/remote.rb b/lib/sisu/v3/remote.rb
index 5537d7b4..bda7529b 100644
--- a/lib/sisu/v3/remote.rb
+++ b/lib/sisu/v3/remote.rb
@@ -165,7 +165,6 @@ module SiSU_Remote
require 'net/http'
for requested_pod in get_p
pod_info=Remote_download.new(requested_pod)
- @opt.fns=pod_info.pod.name
Net::HTTP.start(pod_info.pod.site) do |http|
resp=http.get("#{pod_info.pod.path}/#{pod_info.pod.name_source}")
open(pod_info.pod.name,'wb') do |file|
@@ -181,12 +180,12 @@ module SiSU_Remote
@requested_file=requested_file
end
def pod
- re_p_div=/https?:\/\/([^\/]+)(\/\S+)\/(sisupod(?:\.zip)?|\S+?(?:\.ss[mt]\.zip)?|[^\/]+?\.ssp)$/
- re_p=/(sisupod(?:\.zip)?|\S+?\.ss[mt](?:\.zip)?|[^\/]+?\.ssp)$/
+ re_p_div=/https?:\/\/([^\/]+)(\/\S+)\/(sisupod(?:\.txz)?|\S+?(?:\.ss[mt]\.txz)?|[^\/]+?\.ssp)$/
+ re_p=/(sisupod(?:\.txz)?|\S+?\.ss[mt](?:\.txz)?|[^\/]+?\.ssp)$/
if @requested_file =~ re_p_div
@site,@pth,@pod= re_p_div.match(@requested_file).captures
elsif @requested_file =~ re_p
- @pod= re_p.match(@requested_file).captures
+ @pod=re_p.match(@requested_file).captures.join
end
def site
@site
diff --git a/lib/sisu/v3/sisupod_make.rb b/lib/sisu/v3/sisupod_make.rb
index 9c280df5..dd6c89c2 100644
--- a/lib/sisu/v3/sisupod_make.rb
+++ b/lib/sisu/v3/sisupod_make.rb
@@ -66,41 +66,38 @@ module SiSU_Doc
require_relative 'particulars' # particulars.rb
def initialize(opt)
@opt=opt
- m=/.+\/(?:src\/)?(\S+)/im # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m
+ m=/.+\/(?:src\/)?(\S+)/im
@date=SiSU_Env::Info_date.new.dt
@env=SiSU_Env::Info_env.new(@opt.fns)
@ver=SiSU_Env::Info_version.instance.get_version
@ans=SiSU_Response::Response.new
pod_path="#{@env.processing_path.processing}/sisupod"
- @v=if @opt.cmd =~/[VM]/; 'v'
- else ''
- end
+ @v=(@opt.cmd =~/[VM]/) ? 'v' : ''
@particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt)
@file=@particulars.file
- @local_path="#{@file.output_path.sisupod.dir}" #@local_path="#{@env.path.output}/#{@env.fnb}"
- @zipfile=if @opt.fns =~/\.ssm\.sst$/; @opt.fns.gsub(/(?:\~\S{2,3})?\.ssm\.sst$/,'.ssm')
- else @opt.fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1')
- end
+ @local_path="#{@file.output_path.sisupod.dir}"
+ @zipfile=(@opt.fns =~/\.ssm\.sst$/) \
+ ? @opt.fns.gsub(/(?:\~\S{2,3})?\.ssm\.sst$/,'.ssm')
+ : @opt.fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1')
mkdir_p(pod_path) unless FileTest.directory?(pod_path)
rm_rf("#{@env.processing_path.processing}sisupod/*") if FileTest.directory?("#{@env.processing_path.processing}sisupod")
end
def read
unless @opt.cmd =~/q/
@opt.cmd=~/[MVvz]/ \
- ? SiSU_Screen::Ansi.new(@opt.cmd,'Share SiSU Document (zip)',@opt.fns).green_hi_blue
- : SiSU_Screen::Ansi.new(@opt.cmd,'Share SiSU Document (zip)',@opt.fns).green_title_hi
+ ? SiSU_Screen::Ansi.new(@opt.cmd,'Share SiSU Document (txz)',@opt.fns).green_hi_blue
+ : SiSU_Screen::Ansi.new(@opt.cmd,'Share SiSU Document (txz)',@opt.fns).green_title_hi
end
unless @opt.fns.empty?
unless @opt.cmd =~/q/
- SiSU_Screen::Ansi.new(@opt.cmd,'Make sisu document (zip) and place in output directory',"#{@opt.fns} -> file://#{@file.output_path.sisupod.dir}/#{@zipfile}.zip").warn if @opt.cmd =~/[MVv]/
+ SiSU_Screen::Ansi.new(@opt.cmd,'Make sisu document (txz) and place in output directory',"#{@opt.fns} -> file://#{@file.output_path.sisupod.dir}/#{@zipfile}.txz").warn if @opt.cmd =~/[MVv]/
end
directories
sisupod_build
- sisupod_zip
- #sisupod_7zip
+ sisupod_xz
else
if @opt.cmd =~/[MVv]/
- SiSU_Screen::Ansi.new(@opt.cmd,'Make (zip) of sisu work directory',"#{@env.stub_pwd}\_#{@date}.zip").warn
+ SiSU_Screen::Ansi.new(@opt.cmd,'Make (zip (txz)) of sisu work directory',"#{@env.stub_pwd}\_#{@date}.txz").warn
SiSU_Screen::Ansi.new(@opt.cmd,'').blue_tab
end
ans=@ans.response?('make sisupod of entire directory?')
@@ -109,7 +106,7 @@ module SiSU_Doc
end
end
def sisupod_zip_directory
- sisupod_directory="sisupod-#{@env.stub_pwd}-#{@date}.ssp" # "sisupod-#{@env.stub_pwd}-#{@date}.zip"
+ sisupod_directory="sisupod-#{@env.stub_pwd}-#{@date}.ssp"
unless File.symlink?('sisupod'); File.symlink(Dir.pwd,'sisupod')
end
re_base_dir='^sisupod/([^.][^/]*\.(ssm|ssi|sst)$|_sisu/)'
@@ -131,15 +128,15 @@ module SiSU_Doc
else puts "the required systemlink 'sisupod' could not be created on the current directory: remove the file or directory named 'sisupod' within #{Dir.pwd}"
end
if @opt.cmd =~/[MVv]/
- SiSU_Screen::Ansi.new(@opt.cmd,'Share SiSU Document (tar gzip)',@opt.fns).green_hi_blue
- SiSU_Screen::Ansi.new(@opt.cmd,'Zipped directory',sisupod_directory).warn
+ SiSU_Screen::Ansi.new(@opt.cmd,'Share SiSU Document (tar xz)',@opt.fns).green_hi_blue
+ SiSU_Screen::Ansi.new(@opt.cmd,'Zipped directory (tgz)',sisupod_directory).warn
SiSU_Screen::Ansi.new('',sisupod_directory).blue_tab
end
end
def directories
- SiSU_Env::Info_env.new.sisupod
+ SiSU_Env::Info_env.new.sisupod_v3(@opt)
end
- def select(skin='') # skin loading logic here
+ def select_skin(skin='') #skin loading logic here
load "#{SiSU_lib}/defaults.rb"
@skin={}
skin_path = [
@@ -165,37 +162,59 @@ module SiSU_Doc
end
@skin
end
- def sisupod_build #see also sisupod in sysenv
+ def images_extract(f,images)
+ rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/
+ if f !~/^%+\s/ \
+ and f =~rgx_image
+ images << f.scan(rgx_image).uniq
+ end
+ images.flatten
+ end
+ def sisupod_build #see also sisupod in sysenv
+ @pwd=Dir.pwd
@rgx_rb_image=/["'](\S+?\.(?:png|jpg|gif))["']/
@rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/
@rgx_skin=/^\s+:skin:\s+(\S+)/
- @rgx_doc_import=/^%\s\s*\|(\S+?\.ss[ti])\|@\|\^\|>>ok/
+ @rgx_doc_import=/^<<\s*(\S+?\.ss[ti])/
use_file=@opt.fns =~/(?:\.ssm|\.ssm\.sst)$/ \
? @opt.fns.gsub(/\.ssm\.sst$/,'.ssm')
: @opt.fns
file_array=IO.readlines(use_file,'')
skin,images,doc_import=[],[],[]
- file_array.each do |f| #% work area
+ doc_import_dir=@opt.sub_location
+ file_array.each do |f| #% work area
if f !~/^%+\s/
skin << f.scan(@rgx_skin).uniq.flatten if f =~@rgx_skin
if f !~/^%+\s/ \
and f =~@rgx_image
- images << f.scan(@rgx_image).uniq
+ images=images_extract(f,images)
+ end
+ if use_file =~/\.ssm$/
+ doc_import << f.scan(@rgx_doc_import) if f =~@rgx_doc_import
+ end
+ end
+ end
+ if doc_import.length > 0
+ doc_import=doc_import.uniq.flatten
+ doc_import.each do |fn|
+ file_array=IO.readlines(fn,'')
+ file_array.each do |f| #% work area
+ if f !~/^%+\s/ \
+ and f =~@rgx_image
+ images=images_extract(f,images)
+ end
end
- elsif f =~/^%\s/ \
- and @opt.fns =~/\.ssm\.sst$/
- doc_import << f.scan(@rgx_doc_import).uniq if f =~@rgx_doc_import
end
end
docskin=nil
if skin \
and skin.length > 0
docskin=skin.pop.flatten.join
- skin_source=select(docskin)
+ skin_source=select_skin(docskin)
else
- skin_source=select
+ skin_source=select_skin
end
- docskin_place="#{@env.processing_path.processing}/sisupod/_sisu/skin/#{skin_source[:type]}"
+ docskin_place="#{@env.processing_path.processing}/sisupod/doc/_sisu/skin/#{skin_source[:type]}"
if skin_source[:type] =~/dir/
docskin_with_path="#{docskin_place}/skin_#{@env.stub_pwd}.rb"
docskin=[docskin_with_path.gsub(/.+?\/(skin_\S+?)\.rb/,'\1')]
@@ -208,9 +227,9 @@ module SiSU_Doc
cp_r(skin_source[:name],"#{docskin_place}/#{docskin}.rb")
skinfile_array=IO.readlines(skin_source[:name],'')
para_images=[]
- skinfile_array.each do |f| #% work area
+ skinfile_array.each do |f| #% work area
unless f =~/^%+ / #hmmm
- images << f.scan(@rgx_rb_image).uniq if f =~@rgx_rb_image #and FileTest.file?(f.scan(@rgx_rb_image).uniq)
+ images << f.scan(@rgx_rb_image).uniq if f =~@rgx_rb_image
#does not really discriminate, may duplicate images in sisu file, and may take images from default image pool
end
end
@@ -224,11 +243,12 @@ module SiSU_Doc
images.uniq!
images.delete_if {|x| x =~/https?:\/\// }
#images.sort!
- image_path_pwd='_sisu/image'
+ path_pod="#{@env.processing_path.processing}/sisupod"
path_pod_conf="#{@env.processing_path.processing}/sisupod/_sisu"
- images_path_pod="#{path_pod_conf}/image"
+ images_path_pod="#{path_pod}/image"
#unattractive hard coding ... !
- images_pwd="#{@env.path.pwd}/#{image_path_pwd}"
+ image_path='_sisu/image'
+ images_pwd="#{@env.path.pwd}/#{image_path}"
##sequence copies base images, defaults used in all html outputs
#image_source_base='/usr/share/sisu/image'
#dir_pwd=Dir.pwd
@@ -238,58 +258,67 @@ module SiSU_Doc
# cp_r(i,"#{images_path_pod}/#{i}")
#end
#Dir.chdir(dir_pwd)
- if FileTest.directory?(image_path_pwd)
+ if FileTest.directory?(images_pwd)
images=images.uniq
images.each do |i|
cp_r("#{images_pwd}/#{i}","#{images_path_pod}/#{i}") if FileTest.file?("#{images_pwd}/#{i}")
end
- #chmod(0755, dir_images_www)
- else puts "\tWARN, did not find - #{image_path_pod}"
+ else puts "\tWARN, did not find - #{images_pwd} #{images_path_pod}"
end
end
- x=@env.document_language_versions_found #check multiple document language versions (param not used)
- if doc_import.flatten.length > 0 \
- and @opt.fns =~/\.ssm\.sst$/
- doc_import.flatten.each do |f|
- cp_r("#{@env.path.pwd}/#{f}","#{@env.processing_path.processing}/sisupod/#{f}")
+ if doc_import.length > 0 \
+ and use_file =~/\.ssm$/
+ doc_import.each do |f|
+ cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f}","#{@env.processing_path.processing}/sisupod/doc/#{@opt.lng}/#{f}")
end
end
+ x=@env.document_language_versions_found #check multiple document language versions (param not used)
if x[:f] \
- and x[:f].length > 1 #store multiple document language versions, sisupod
+ and x[:f].length > 0 #store multiple document language versions, sisupod
x[:f].each do |f|
- cp_r("#{@env.path.pwd}/#{f}","#{@env.processing_path.processing}/sisupod/#{f}")
+ (use_file =~/\.ssm$/) \
+ ? cp_r("#{@env.path.pwd}#{doc_import_dir}/#{f[:f]}","#{@env.processing_path.processing}/sisupod/doc/#{f[:l]}/#{f[:n]}")
+ : cp_r("#{@env.path.pwd}/#{f[:f]}","#{@env.processing_path.processing}/sisupod/doc/#{f[:l]}/#{f[:n]}")
end
- elsif @opt.fns =~/\.ssm\.sst/
- ssm=@opt.fns.gsub(/\.ssm\.sst/,'.ssm')
- cp_r("#{@env.path.pwd}/#{ssm}","#{@env.processing_path.processing}/sisupod/#{ssm}")
- else cp_r("#{@env.path.pwd}/#{@opt.fns}","#{@env.processing_path.processing}/sisupod/#{@opt.fns}")
end #NB not all possibilies met, revisit, also in case of composite file may wish to add README
end
- def sisupod_7zip #look at later
+ def sisupod_xz
mkdir_p(@file.output_path.sisupod.dir) unless FileTest.directory?(@file.output_path.sisupod.dir)
- system(%{
- cd #{@env.processing_path.processing}
- echo "SiSU sisupod #{@ver[:version]}" > sisu_zip.txt
- #7zip -qz #{@opt.fns}.7z sisu_zip.txt < sisu_zip.txt
- 7zr a -t7z -m0=lzma -mx=9 -ms=on #{@zipfile}.7z sisu_zip.txt
- 7zr a -t7z -m0=lzma -mx=9 -ms=on #{@zipfile}.7z sisupod
- #7zip -qr #{@zipfile}.7z sisupod
- mv #{@zipfile}.7z #{@file.place_file.sisupod.dir} &
- rm -r sisupod/* && cd #{@env.path.pwd}
- })
- SiSU_Screen::Ansi.new('',"#{@opt.fns}.7z").blue_tab unless @opt.cmd =~/q/
+ tree=(@opt.cmd =~/[vVM]/ \
+ && SiSU_Env::System_call.new.program_found?('tree')) \
+ ? 'tree sisupod'
+ : ''
+ if FileTest.directory?(@env.processing_path.processing)
+ Dir.chdir(@env.processing_path.processing)
+ system(%{
+ #{tree}
+ tar -cJf #{@zipfile}.txz sisupod
+ #echo "#{@file.place_file.sisupod.dir}"
+ mv #{@zipfile}.txz #{@file.place_file.sisupod.dir} &
+ rm -r sisupod/*
+ })
+ Dir.chdir(@env.path.pwd)
+ SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz").blue_tab unless @opt.cmd =~/q/
+ else
+ SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz not built").blue_tab
+ end
end
def sisupod_zip
mkdir_p(@file.output_path.sisupod.dir) unless FileTest.directory?(@file.output_path.sisupod.dir)
- system(%{
- cd #{@env.processing_path.processing}
- echo "SiSU sisupod #{@ver[:version]}" > sisu_zip.txt
- zip -qz #{@zipfile}.zip sisu_zip.txt < sisu_zip.txt
- zip -qr #{@zipfile}.zip sisupod
- mv #{@zipfile}.zip #{@file.place_file.sisupod.dir} &
- rm -r sisupod/* && cd #{@env.path.pwd}
- })
- SiSU_Screen::Ansi.new('',"#{@zipfile}.zip").blue_tab if @opt.cmd =~/[MVv]/
+ if FileTest.directory?(@env.processing_path.processing)
+ Dir.chdir(@env.processing_path.processing)
+ system(%{
+ echo "SiSU sisupod #{@ver[:version]}" > sisu_zip.txt
+ zip -qz #{@zipfile}.zip sisu_zip.txt < sisu_zip.txt
+ zip -qr #{@zipfile}.zip sisupod
+ mv #{@zipfile}.zip #{@file.place_file.sisupod.dir} &
+ rm -r sisupod/*
+ })
+ Dir.chdir(@env.path.pwd)
+ SiSU_Screen::Ansi.new('',"#{@zipfile}.zip").blue_tab if @opt.cmd =~/[MVv]/
+ else
+ SiSU_Screen::Ansi.new('',"#{@zipfile}.zip not built").blue_tab
+ end
end
end
end
@@ -305,16 +334,33 @@ question?: should you permit the packing of multiple files in
remove previously existing contents of _/sisu/sisupod &
make directory structure:
+v3 -->
_sisu
sisupod
- sisu
- content.sst [file content]
- filename.sst [link to content.sst]
+ doc
+ manifest.txt
+ en/content.sst [file content]
+ fr/content.sst
_sisu
conf
skin/
- doc [relevant skin if any other than default]
- image [all images for specific document gathered here]
+ doc [relevant skin if any other than default]
+ image (ln -s ../../image)
+ audio (ln -s ../../audio)
+ video (ln -s ../../video)
+ image [all images for specific document gathered here]
+ audio
+ video
+
+v2 -->
+ _sisu
+ sisupod
+ content.sst [file content]
+ filename.sst [link to content.sst]
+ _sisu/
+ skin/
+ doc [relevant skin if any other than default]
+ image/ [all images for specific document gathered here]
sisu
_sisu
diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb
index 070ba4f8..475a8369 100644
--- a/lib/sisu/v3/sysenv.rb
+++ b/lib/sisu/v3/sysenv.rb
@@ -376,27 +376,17 @@ module SiSU_Env
end
if @fns \
and @fns != '' #watch
- #if multilingual
- m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/
- @@fnn ||=@fns[m,1]
- @@fnb ||=@fns[m,2]
- @@fnt ||=@fns[m,3]
- @@flv ||=document_language_versions_found[:f]
- unless @@fns =~/\S+?\.zip/
- @@fnz ||=if @@fns =~/(?:\~\S{2,3})?\.(?:ssm\.sst|ssm)$/; @@fnb + '.ssm.zip'
- elsif @@fnb; @@fnb + '.sst.zip'
- else '' # e.g. termsheet
- end
+ m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/
+ @@fnn ||=@fns[m,1]
+ @@fnb ||=@fns[m,2]
+ @@fnt ||=@fns[m,3]
+ @@flv ||=document_language_versions_found[:f]
+ unless @@fns =~/\S+?\.zip/
+ @@fnz ||=if @@fns =~/(?:\~\S{2,3})?\.(?:ssm\.sst|ssm)$/; @@fnb + '.ssm.zip'
+ elsif @@fnb; @@fnb + '.sst.zip'
+ else '' # e.g. termsheet
end
- #else m=/(.+?)\.((?:-|ssm\.)?sst|ssm)$/
- # @@fnb ||=@fns[m,1]
- # @@fnt ||=@fns[m,2]
- # unless @@fns =~/\S+?\.zip/
- # @@fnz ||=if @@fns =~/(?:\~\S{2,3})?\.(?:ssm\.sst|ssm)$/; @@fnb + '.ssm.zip'
- # else @@fnb + '.sst.zip'
- # end
- # end
- #end
+ end
end
@fnn,@fnb,@fnt,@flv,@fnz=@@fnn,@@fnb,@@fnt,@@flv,@@fnz
end
@@ -455,31 +445,52 @@ module SiSU_Env
end
def document_language_versions_found #REVISIT
@fn={}
- unless (@fns.nil? \
- or @fns.empty?)
+ filename=(@fns =~/\.ssm\.sst$/) \
+ ? @fns.gsub(/\.ssm\.sst$/,'.ssm')
+ : @fns
+ unless (filename.nil? \
+ or filename.empty?)
if output_dir_structure.by_language_code?
- m=/((.+?)(?:\~\w{2,3})?)\.((?:-|ssm\.)?sst$)/
- @fn[:b],@fn[:m],@fn[:t]=@fns[m,1],@fns[m,2],@fns[m,3]
- else m=/(.+?)\.((?:-|ssm\.)?sst$)/
- @fn[:b]=@fn[:m]=@fns[m,1]
- @fn[:t]=@fns[m,2]
+ m=/((.+?)(?:\~\w{2,3})?)\.(sst|ssm)$/
+ @fn[:b],@fn[:m],@fn[:t]=filename[m,1],filename[m,2],filename[m,3]
+ else m=/(.+?)\.(sst|ssm)$/
+ @fn[:b]=@fn[:m]=filename[m,1]
+ @fn[:t]=filename[m,2]
end
end
+ lng_base=Info_env.new.language_default_set
lang=SiSU_Env::Standardise_language.new
langs=lang.codes
x=[]
- if FileTest.file?("#{@fn[:m]}.#{@fn[:t]}"); x << "#{@fn[:m]}.#{@fn[:t]}"
+ if FileTest.file?("#{@fn[:m]}.#{@fn[:t]}")
+ n=@fn[:m].gsub(/^.+?\//,'')
+ n =n + '.' + @fn[:t]
+ x << { f: "#{@fn[:m]}.#{@fn[:t]}", l: lng_base, n: n }
end
- x << @fns
+ #x << { f: "#{@fns}", l: lng_base }
langs.each do |l|
lng=SiSU_Env::Standardise_language.new(l)
if FileTest.file?("#{@fn[:m]}~#{lng.code}.#{@fn[:t]}")
- x << "#{@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]}")
- x << "#{@fn[:m]}~#{lng.name}.#{@fn[:t]}"
+ x << { f: "#{@fn[:m]}~#{lng.name}.#{@fn[:t]}", l: lng.code }
+ end
+ if FileTest.file?("#{lng.code}/#{@fn[:m]}~#{lng.code}.#{@fn[:t]}")
+ if FileTest.file?("#{lng.code}/#{@fn[:m]}~#{lng.code}.#{@fn[:t]}")
+ x << { f: "#{lng.code}/#{@fn[:m]}~#{lng.code}.#{@fn[:t]}", l: lng.code }
+ elsif FileTest.file?("#{lng.code}/#{@fn[:m]}~#{lng.name}.#{@fn[:t]}")
+ x << { f: "#{lng.code}/#{@fn[:m]}~#{lng.name}.#{@fn[:t]}", l: lng.code }
+ end
+ end
+ if FileTest.file?("#{lng.code}/#{@fn[:m]}.#{@fn[:t]}")
+ if FileTest.file?("#{lng.code}/#{@fn[:m]}.#{@fn[:t]}")
+ x << { f: "#{lng.code}/#{@fn[:m]}.#{@fn[:t]}", l: lng.code }
+ elsif FileTest.file?("#{lng.code}/#{@fn[:m]}.#{@fn[:t]}")
+ x << { f: "#{lng.code}/#{@fn[:m]}.#{@fn[:t]}", l: lng.code }
+ end
end
end
- @fn[:f]=x.uniq!
+ @fn[:f]=x
@fn
end
def published_manifests?(output_base)
@@ -1075,24 +1086,80 @@ module SiSU_Env
def stub_pod
@stub_pod
end
- def sisupod
+ def sisupod_v3(opt)
#processing_path.processing
# sisupod
- # sisu
- # content.sst [file content]
- # filename.sst [link to content.sst]
+ # doc/
+ # manifest.txt
+ # en/content.sst [file content]
+ # fr/content.sst
# _sisu
- # conf
- # skin/
- # doc [relevant skin if any other than default]
- # image [all images for specific document gathered here]
+ # skin/
+ # doc [relevant skin if any other than default]
+ # image@ (ln -s ../../image)
+ # audio@ (ln -s ../../audio)
+ # video@ (ln -s ../../video)
+ # image/ [all images for specific document gathered here]
+ # audio/
+ # video/
+ spp="#{processing_path.processing}/sisupod"
+ sppc="#{spp}/doc/_sisu"
+ lng_dirs=[]
+ if FileTest.directory?(spp) \
+ or FileTest.file?(spp)
+ rm_rf(spp)
+ end
+ paths=[]
+ flv=Env_call.new(opt.fns).document_language_versions_found
+ flv[:f].each {|l| lng_dirs << l[:l] }
+ lng_dirs.uniq!
+ lng_dirs.each do |lng|
+ paths << "#{spp}/doc/#{lng}"
+ end
+ paths \
+ << "#{spp}/image" \
+ << "#{sppc}/skin/doc" \
+ << "#{sppc}/skin/dir" \
+ << "#{sppc}/skin/site"
+ #<< "#{spp}/audio" \
+ #<< "#{spp}/video" \
+ paths.each do |x|
+ unless FileTest.directory?(x)
+ mkdir_p(x)
+ end
+ end
+ if FileTest.directory?(sppc)
+ pwd=Dir.pwd
+ Dir.chdir(sppc)
+ system("
+ ln -s ../../image
+ #ln -s ../../audio
+ #ln -s ../../video
+ ")
+ Dir.chdir(pwd)
+ end
+ end
+ def sisupod_v2
+ #processing_path.processing
+ # sisupod
+ # content.sst [file content]
+ # filename.sst [link to content.sst]
+ # _sisu
+ # skin/
+ # doc [relevant skin if any other than default]
+ # image [all images for specific document gathered here]
sisupod_processing_path="#{processing_path.processing}/sisupod"
if FileTest.directory?(sisupod_processing_path) \
or FileTest.file?(sisupod_processing_path)
rm_rf(sisupod_processing_path)
end
paths=[]
- paths=["#{processing_path.processing}/sisupod/_sisu/skin/doc","#{processing_path.processing}/sisupod/_sisu/skin/dir","#{processing_path.processing}/sisupod/_sisu/skin/site","#{processing_path.processing}/sisupod/_sisu/image"]
+ paths=[
+ "#{processing_path.processing}/sisupod/_sisu/skin/doc",
+ "#{processing_path.processing}/sisupod/_sisu/skin/dir",
+ "#{processing_path.processing}/sisupod/_sisu/skin/site",
+ "#{processing_path.processing}/sisupod/_sisu/image"
+ ]
paths.each {|x| mkdir_p(x) unless FileTest.directory?(x) }
end
def defaults #multiple default directories
@@ -2370,7 +2437,8 @@ WOK
if defined? @rc['program_set']['file_encoding']; is=@rc['program_set']['encoding']
end
if is.nil? \
- or is==true; is='encoding'
+ or is==true
+ is='encoding'
end
is
end
@@ -2385,6 +2453,40 @@ WOK
system("unzip -q #{path.share}/#{SiSU_version_dir}/odf/odt.zip -d #{processing_path.odf_pth}")
end
def sisupod_gen(fns_pod)
+ sisupod_gen_v3(fns_pod)
+ end
+ def sisupod_gen_v3(fns_pod)
+ pwd=Dir.pwd
+ sisupod_processing_path="#{processing_path.processing}/sisupod"
+ if FileTest.directory?(sisupod_processing_path) \
+ or FileTest.file?(sisupod_processing_path)
+ rm_rf(sisupod_processing_path)
+ end
+ unless FileTest.directory?(sisupod_processing_path)
+ mkdir_p(sisupod_processing_path)
+ end
+ f_pod=if FileTest.file?("#{Dir.pwd}/#{fns_pod}")
+ "#{Dir.pwd}/#{fns_pod}"
+ elsif FileTest.file?(fns_pod)
+ fns_pod
+ end
+ if f_pod \
+ && FileTest.file?(f_pod)
+ tree=(SiSU_Env::System_call.new.program_found?('tree')) \
+ ? "tree #{processing_path.processing}/sisupod"
+ : ''
+ if FileTest.directory?(processing_path.processing)
+ Dir.chdir(processing_path.processing)
+ system(%{tar xJf #{f_pod}})
+ Dir.chdir(pwd)
+ end
+ #system(tree) #enable if (/[vVM]/)
+ else
+ SiSU_Screen::Ansi.new('',"file not found: #{fns_pod}").warn unless @cmd=~/q/
+ end
+ sisupod_processing_path
+ end
+ def sisupod_gen_v2(fns_pod)
pwd=Dir.pwd
sisupod_processing_path="#{processing_path.processing}/sisupod"
if FileTest.directory?(sisupod_processing_path) \
@@ -3715,9 +3817,9 @@ WOK
: (@fno + '.pot')
end
def sisupod
- if @md.fns =~/\.ssm\.sst$/; @md.fns.gsub(/(?:\~\S{2,3})?\.ssm\.sst$/,'.ssm.zip')
- else @md.fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1.zip')
- end
+ (@md.fns =~/\.ssm\.sst$/) \
+ ? @md.fns.gsub(/(?:\~\S{2,3})?\.ssm\.sst$/,'.ssm.txz')
+ : @md.fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1.txz')
end
self
end
@@ -3747,6 +3849,9 @@ WOK
"#{output_path.base.dir}/#{@ft}"
end
end
+ def ab_pod
+ "#{output_path.base.dir}/#{@ft}"
+ end
self
end
def url
@@ -3773,6 +3878,9 @@ WOK
"#{output_path.base.url}/#{@ft}"
end
end
+ def ab_pod
+ "#{output_path.base.url}/#{@ft}"
+ end
self
end
def rel
@@ -3794,13 +3902,53 @@ WOK
end
def ab_src
if @env.output_dir_structure.by_language_code?
- "../../#{@ft}/#{@md.opt.lng}"
+ "#{@ft}/#{@md.opt.lng}"
+ else
+ "#{@ft}"
+ end
+ end
+ def ab_pod
+ if @env.output_dir_structure.by_language_code?
+ "#{@ft}"
else
"#{@ft}"
end
end
self
end
+ def rel_sm
+ def abc
+ if @env.output_dir_structure.by_language_code?
+ "#{@md.opt.lng}/#{@ft}"
+ elsif @env.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}"
+ end
+ end
+ def ab_src
+ if @env.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?
+ "../../#{@ft}/#{@md.opt.lng}"
+ else
+ "../#{@ft}"
+ end
+ end
+ self
+ end
def rcp
def abc
if @env.output_dir_structure.by_language_code?
@@ -3914,16 +4062,7 @@ WOK
set_path(ft).rcp.ab_src
end
def rel_sm
- if @env.output_dir_structure.by_language_code?
- ''
- #"#{output_path.base.dir}/#{@md.opt.lng}/#{@ft}"
- elsif @env.output_dir_structure.by_filetype?
- ''
- #"#{output_path.base.dir}/#{@ft}"
- else
- ''
- #"#{output_path.base.dir}/#{@md.fnb}"
- end
+ set_path(ft).rel_sm.ab_src
end
self
end
@@ -3932,19 +4071,19 @@ WOK
Gt[:src] + '/' + Gt[:pod]
end
def dir
- set_path(ft).dir.ab_src
+ set_path(ft).dir.ab_pod
end
def url
- set_path(ft).url.ab_src
+ set_path(ft).url.ab_pod
end
def rel
- set_path(ft).rel.ab_src
+ set_path(ft).rel.ab_pod
end
def rcp
- set_path(ft).rcp.ab_src
+ set_path(ft).rcp.ab_pod
end
def rel_sm
- #"#{output_path.base.rel}/pod"
+ set_path(ft).rel_sm.ab_pod
end
self
end