From f330953381476d47deaecfdd209fed0264ace190 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 19 Apr 2011 21:29:58 -0400 Subject: v3: odf:odt processing in separate subdirectories * processing in separate subdirectories that can be kept for maintenance * odt.zip (bin) directory renamed odt from odf * sysenv, odf:odt paths adjusted for changes in maintenance & odt.zip --- lib/sisu/v3/odf.rb | 36 ++++++++++++++++++++++++------------ lib/sisu/v3/sysenv.rb | 14 +++++++++++--- 2 files changed, 35 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb index c14a6c91..894052d6 100644 --- a/lib/sisu/v3/odf.rb +++ b/lib/sisu/v3/odf.rb @@ -82,8 +82,6 @@ module SiSU_ODF begin @md,@env,@dal_array=@particulars.md,@particulars.env,@particulars.dal_array @env.odf_structure - opendoc=@md.fn[:odf] - path=@env.path.output_tell unless @opt.cmd =~/q/ tool=(@opt.cmd =~/[MVv]/) \ ? "#{@env.program.odf_viewer} file://#{@md.file.output_path.odt}/#{@md.file.base_filename.odt}" \ @@ -116,10 +114,20 @@ module SiSU_ODF #@br=(@md.cmd =~/M/) ? "\n" : '' end def songsheet - pre - @data=markup(@dal_array) - post - publish + begin + pre + @data=markup(@dal_array) + post + publish + ensure + unless @md.cmd =~/[MV]/ #check maintenance flag + if @env.processing_path.odt =~/od[ft]/ + #p "rm -r #{@env.processing_path.odt}" if @md.cmd =~/v/ + system("rm -r #{@env.processing_path.odf_pth}") + #system("rm -r #{@env.processing_path.odt}") + end + end + end end # Used for extraction of endnotes from paragraphs def extract_endnotes(dob='') @@ -207,7 +215,9 @@ module SiSU_ODF w=/([0-9]+\.\d{0,3})/.match(w).captures.join image_source=image_src(i) pwd=Dir.pwd - cp("#{image_source}/#{i}","#{@env.processing_path.odf}/Pictures/#{i}") if image_source + if image_source + cp("#{image_source}/#{i}","#{@env.processing_path.odt}/Pictures/#{i}") + end img=if i.to_s =~/jpg|png|gif/ \ and h.to_s =~/\d/ \ and w.to_s =~/\d/ @@ -506,7 +516,9 @@ module SiSU_ODF odf_tail #($1,$2) fix=[] bullet=image_src('bullet_09.png') - cp("#{bullet}/bullet_09.png","#{@env.processing_path.odf}/Pictures/.") #if image_src('bullet_09.png') + if bullet + cp("#{bullet}/bullet_09.png","#{@env.processing_path.odt}/Pictures/.") + end odf_metadata data.each do |dob| #p dob.obj if dob.obj =~safe_characters and @md.cmd =~/V/ #KEEP @@ -686,9 +698,9 @@ module SiSU_ODF def odf #%odf output env=SiSU_Env::SiSU_file.new(@md) env.mkdir - env.make_path(@env.processing_path.odf) + env.make_path(@env.processing_path.odt) env.make_path(@md.file.output_path.odt) - filename="#{@env.processing_path.odf}/content.xml" + filename="#{@env.processing_path.odt}/content.xml" od=File.new(filename,'w+') @content.each do |para| # this is a hack od.puts para unless para =~/\A\s*\Z/ @@ -730,9 +742,9 @@ page break notes?? [you could add a note number for every object/paragraph!] - cd(@env.processing_path.odf) + cd(@env.processing_path.odt) structure=[] - Find.find(@env.processing_path.odf) do |f| + Find.find(@env.processing_path.odt) do |f| structure << puts f end open(opendoc,'wb') do |f| diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 7cc2a327..a573a6c0 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -1654,8 +1654,15 @@ WOK end pth end + def odf_pth + pth="#{processing}/odf/#{@fns}" + pth + end def odf - pth="#{processing}/odf" + odt + end + def odt + pth=odf_pth + '/odt' mkdir_p(pth) unless FileTest.directory?(pth) pth end @@ -2196,8 +2203,9 @@ WOK : (defaults[:papersize].downcase) end def odf_structure - rm_rf("#{processing_path.processing}/odf") - system("unzip -q #{path.share}/#{SiSU_version_dir}/odf/odt.zip -d #{processing_path.processing}") + rm_rf(processing_path.processing_path.odf_pth) + mkdir_p(processing_path.processing_path.odf_pth) + system("unzip -q #{path.share}/#{SiSU_version_dir}/odf/odt.zip -d #{processing_path.odf_pth}") end def sisupod_gen(fns_pod) pwd=Dir.pwd -- cgit v1.2.3