From 2b884fb73428186df29bf22ff38d77e5d2f823cf Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 14 Feb 2012 21:10:19 -0500 Subject: v3dv: --redirect (--redirect=dir_path) & --dump (--dump=dir_path) + consequences * --dump places output in directory specified, if none specified in the current directory (pwd). * --redirect places output in subdirectory under specified directory, subdirectory uses the filename (without the suffix). If no output directory is specified places the subdirectory under the current directory (pwd). * html, css incorporated into each file (concordance & manifest included) * html, xhtml & xmls, css copied into css subdirectory (not used by html as embedded) * html xmls, images copied to output directory * no links to manifest * manifest with relative links only * longer html filenames given to avoid names clashing (e.g. for toc, manifest, concordance) * html, epub, remove manifest toc links * -j copy images associated with file (images used by html & xmls) * automatically invoked by --dump & redirect * v3 v3dv: document --redirect, --dump, -j update sisu_commands.sst [documents not generated until v3.2.0 (when v3dv branch is merged into v3)] --- lib/sisu/v3dv/manifest.rb | 70 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 22 deletions(-) (limited to 'lib/sisu/v3dv/manifest.rb') diff --git a/lib/sisu/v3dv/manifest.rb b/lib/sisu/v3dv/manifest.rb index 3310fa98..19fdc65c 100644 --- a/lib/sisu/v3dv/manifest.rb +++ b/lib/sisu/v3dv/manifest.rb @@ -106,6 +106,12 @@ module SiSU_Manifest @fnb=@md.fnb @base_url="#{@env.url.root}/#{@fnb}" @f=SiSU_Env::FileOp.new(@md) + @o_str=SiSU_Env::OutputStructure.new(md).output_dir_structure + @image_path=if @o_str.dump_or_redirect? + %{./image} + else + %{#{@f.path_rel_links.html_scroll_2}_sisu/image_sys} + end @base_path=@f.output_path.manifest.dir @@dg ||=SiSU_Env::InfoEnv.new.digest.type @dg=@@dg @@ -113,6 +119,7 @@ module SiSU_Manifest @language=l[:n] @translate=SiSU_Translate::Source.new(@md,@language) @brace_url=SiSU_Viz::Skin.new.url_decoration + @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet end def output manifest=@f.write_file.manifest @@ -122,17 +129,26 @@ module SiSU_Manifest manifest << x end end + def url_make(url,file,src=nil) + if @o_str.dump_or_redirect? + '' + elsif :src + %{
#{@brace_url.xml_open}#{url}/#{file}#{@brace_url.xml_close}} + else + %{

#{@brace_url.xml_open}#{url}/#{file}#{@brace_url.xml_close}

} + end + end def summarize(id,file,pth='',rel='',url='',img='● ') size=(File.size("#{pth}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @manifest[:txt] << "#{file} #{id} #{kb}\n" - @manifest[:html] << %{

#{img}#{id}

#{file}

#{@brace_url.xml_open}#{url}/#{file}#{@brace_url.xml_close}

#{kb}

\n} + @manifest[:html] << %{

#{img}#{id}

#{file}

#{url_make(url,file)}

#{kb}

\n} end def summarize_html_seg(id,file,pth='',rel='',url='',img='● ') size=(File.size("#{pth}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @manifest[:txt] << "#{file} #{id} #{kb}\n" - @manifest[:html] << %{

#{img}#{id}

#{file}

#{@brace_url.xml_open}#{url}/#{file}#{@brace_url.xml_close}

#{kb}

\n} + @manifest[:html] << %{

#{img}#{id}

#{file}

#{url_make(url,file)}

#{kb}

\n} end def summarize_sources(id,file,pth,rel,url) sys=SiSU_Env::SystemCall.new @@ -143,7 +159,7 @@ module SiSU_Manifest size=(File.size("#{pth}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @manifest[:txt] << "#{file} #{id} #{kb}\n" - @manifest[:html] << %{

#{id}

#{file}   #{dgst[1]}
#{@brace_url.xml_open}#{url}/#{file}#{@brace_url.xml_close}

#{kb}

\n} if kb and kb =~/\d+/ + @manifest[:html] << %{

#{id}

#{file}   #{dgst[1]}#{url_make(url,file,:src)}

#{kb}

\n} if kb and kb =~/\d+/ end def published_manifests? @f=SiSU_Env::FileOp.new(@md) #.base_filename @@ -153,7 +169,13 @@ module SiSU_Manifest mp,mn,mt,mr=nil,nil,nil,nil ln=SiSU_i18n::Languages.new.language.list Px[:lng_lst].each do |lc| - if @env.output_dir_structure.by_language_code? + if @o_str.dump_or_redirect? #does not work for --redirect or --dump + mp="#{@f.output_path.base.dir}" + mn="#{@md.fnb}.html" + mt="#{mp}/#{mn}" + mr="../../#{lc}/manifest/#{mn}" + mu="#{url}/#{mn}" + elsif @env.output_dir_structure.by_language_code? mp="#{@f.output_path.base.dir}/#{lc}/manifest" mn="#{@md.fnb}.html" mt="#{mp}/#{mn}" @@ -212,7 +234,7 @@ module SiSU_Manifest end def output_tests if FileTest.file?(@f.place_file.html_segtoc.dir)==true - img=%{TOC linked } + img=%{TOC linked } pth=@f.output_path.html_seg.dir rel=@f.output_path.html_seg.rel_sm url=@f.output_path.html_seg.url @@ -220,7 +242,7 @@ module SiSU_Manifest summarize_html_seg(id,file,pth,rel,url,img) end if FileTest.file?(@f.place_file.html_scroll.dir)==true - img=%{Full Text } + img=%{Full Text } pth=@f.output_path.html_scroll.dir rel=@f.output_path.html_scroll.rel_sm url=@f.output_path.html_scroll.url @@ -242,7 +264,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url) end if FileTest.file?(@f.place_file.epub.dir)==true - img=%{EPUB } + img=%{EPUB } id,file='EPUB (Electronic Publication, e-book standard)',@f.base_filename.epub pth=@f.output_path.epub.dir rel=@f.output_path.epub.rel_sm @@ -250,7 +272,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_letter}")==true - img=%{PDF portrait } + img=%{PDF portrait } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -258,7 +280,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_letter}")==true - img=%{PDF landscape } + img=%{PDF landscape } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -266,7 +288,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_a4}")==true - img=%{PDF portrait } + img=%{PDF portrait } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -274,7 +296,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_a4}")==true - img=%{PDF landscape } + img=%{PDF landscape } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -282,7 +304,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_a5}")==true - img=%{PDF portrait } + img=%{PDF portrait } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -290,7 +312,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_a5}")==true - img=%{PDF landscape } + img=%{PDF landscape } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -298,7 +320,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_b5}")==true - img=%{PDF portrait } + img=%{PDF portrait } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -306,7 +328,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_b5}")==true - img=%{PDF landscape } + img=%{PDF landscape } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -314,7 +336,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_legal}")==true - img=%{PDF portrait } + img=%{PDF portrait } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -322,7 +344,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_legal}")==true - img=%{PDF landscape } + img=%{PDF landscape } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -330,7 +352,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?(@f.place_file.odt.dir)==true - img=%{ODF/ODT } + img=%{ODF/ODT } pth=@f.output_path.odt.dir rel=@f.output_path.odt.rel_sm url=@f.output_path.odt.url @@ -416,8 +438,11 @@ module SiSU_Manifest end def qrc_image fn=@md.fnb - img_md="qrcode/#{fn}.md.png" - img_title="qrcode/#{fn}.title.png" + pth=(@o_str.dump_or_redirect?) \ + ? '.' \ + : 'qrcode' + img_md="#{pth}/#{fn}.md.png" + img_title="#{pth}/#{fn}.title.png" if FileTest.file?(@f.place_file.qrcode_md.dir)==true @manifest[:html] <<< @@ -763,13 +788,14 @@ SiSU manifest: #{@md.title.full} - +#{@stylesheet.css_head} #{banner_table} WOK if @env.manifest_minitoc? - if @env.output_dir_structure.by_language_code? \ + if @o_str.dump_or_redirect? + elsif @env.output_dir_structure.by_language_code? \ or @env.output_dir_structure.by_filetype? minitoc=minitoc.gsub(/