aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/sisupod_make.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3/sisupod_make.rb')
-rw-r--r--lib/sisu/v3/sisupod_make.rb196
1 files changed, 121 insertions, 75 deletions
diff --git a/lib/sisu/v3/sisupod_make.rb b/lib/sisu/v3/sisupod_make.rb
index f54f43d9..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)$/ \
- ? "#{@env.processing_path.composite_file}/#{@opt.fnb}.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