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.rb261
1 files changed, 200 insertions, 61 deletions
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