From e70f6340ee6c3e294468f15ed72ff69508b8f679 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 13 Sep 2011 19:21:46 -0400 Subject: v3: epub * fix for different output structures, language codes not used internally (within epub) * adjustment to image paths for image copy --- data/doc/sisu/CHANGELOG_v3 | 5 +++++ lib/sisu/v3/epub.rb | 15 +++++++++------ lib/sisu/v3/epub_concordance.rb | 10 +++++----- lib/sisu/v3/epub_format.rb | 22 +++++++++++----------- lib/sisu/v3/epub_segments.rb | 4 ++-- lib/sisu/v3/epub_tune.rb | 6 +++--- 6 files changed, 35 insertions(+), 27 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 8994fc51..f366a0b5 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -30,6 +30,11 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.0.18.orig.tar.xz * opt.act modifications * sisupod processing (v2 processing also enabled) + * epub + * fix for different output structures, language codes not used + internally (within epub) + * adjustment to image paths for image copy + * correct sisupod references and path to .txz (replace .zip) * image (relative) paths for different sisu output structures diff --git a/lib/sisu/v3/epub.rb b/lib/sisu/v3/epub.rb index 12ec1ce0..c1dcacec 100644 --- a/lib/sisu/v3/epub.rb +++ b/lib/sisu/v3/epub.rb @@ -338,7 +338,7 @@ module SiSU_EPUB title=if dob.obj !~/Document Information/; linkname else link='metadata' - %{#{linkname}} + %{#{linkname}} end toc={} txt_obj={ txt: title } @@ -423,13 +423,13 @@ module SiSU_EPUB linkname,ocn=dob.obj.strip,dob.ocn p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) if ocn if dob.ln==4 - seg_link=%{ + seg_link=%{ #{dob.obj} } @@seg_url=dob.name elsif dob.obj =~/\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+/ seg_link=dob.obj.gsub(/^(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/, - %{} + + %{} + %{\\1 \\2 }) end p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) if ocn @@ -451,7 +451,7 @@ module SiSU_EPUB if ocn \ and ocn !~/#/ p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) - lnk_n_txt=%{ + lnk_n_txt=%{ #{linkname} } txt_obj={ txt: lnk_n_txt } @@ -472,7 +472,7 @@ module SiSU_EPUB if ocn \ and ocn !~/#/ p_num=SiSU_EPUB_Format::Paragraph_number.new(@md,ocn) - lnk_n_txt=%{ + lnk_n_txt=%{ #{linkname} } txt_obj={ txt: lnk_n_txt } @@ -660,7 +660,10 @@ module SiSU_EPUB img_pth=@md.env.path.image_source_include @md.ec[:image].each do |x| if FileTest.directory?("#{@md.env.processing_path.epub}/#{Ep[:d_oebps]}/image") \ - and FileTest.file?("#{img_pth}/#{x}") + && FileTest.file?("#{@md.file.output_path.epub.rel_image}/#{x}") + cp("#{@md.file.output_path.epub.rel_image}/#{x}","#{@md.env.processing_path.epub}/#{Ep[:d_oebps]}/image") + elsif FileTest.directory?("#{@md.env.processing_path.epub}/#{Ep[:d_oebps]}/image") \ + && FileTest.file?("#{img_pth}/#{x}") cp("#{img_pth}/#{x}","#{@md.env.processing_path.epub}/#{Ep[:d_oebps]}/image") end end diff --git a/lib/sisu/v3/epub_concordance.rb b/lib/sisu/v3/epub_concordance.rb index 687155d2..3a961285 100644 --- a/lib/sisu/v3/epub_concordance.rb +++ b/lib/sisu/v3/epub_concordance.rb @@ -185,18 +185,18 @@ WOK protected def location_scroll(wordlocation,show) @wordlocation=wordlocation - %{#{@wordlocation}; } + %{#{@wordlocation}; } end def location_seg(wordlocation,show) @wordlocation,@show=wordlocation,show - @word_location_seg=wordlocation.gsub(/(.+?)\#(\d+)/,"\\1#{@md.lang_code_insert}#{Sfx[:epub_xhtml]}#o\\2") unless wordlocation.nil? + @word_location_seg=wordlocation.gsub(/(.+?)\#(\d+)/,"\\1#{Sfx[:epub_xhtml]}#o\\2") unless wordlocation.nil? case @wordlocation when @rxp_t1 - %{[H]#{@show}, } + %{[H]#{@show}, } when @rxp_t2 - %{[H]#{@show}, } + %{[H]#{@show}, } when @rxp_t3 - %{[H]#{@show}, } + %{[H]#{@show}, } else %{#{@show}, } end end diff --git a/lib/sisu/v3/epub_format.rb b/lib/sisu/v3/epub_format.rb index 345bee95..42570dd0 100644 --- a/lib/sisu/v3/epub_format.rb +++ b/lib/sisu/v3/epub_format.rb @@ -1763,7 +1763,7 @@ WOK } end def seg_head_navigation_band - firstseg=%{ + firstseg=%{ #{@vz.epub_png_nav_nxt} } if @md.firstseg =~/\S+/ DISABLE[:epub][:internal_navigation] \ @@ -1771,7 +1771,7 @@ WOK : %{

#{firstseg}

} end def seg_head_navigation_band_bottom - firstseg=%{ + firstseg=%{ #{@vz.epub_png_nav_nxt} } if @md.firstseg =~/\S+/ DISABLE[:epub][:internal_navigation] \ @@ -1906,17 +1906,17 @@ WOK def dot_control_pre_next %{
- + #{@vz.png_nav_dot_pre} - + #{@vz.png_nav_dot_toc} - + #{@vz.png_nav_dot_nxt} #{@vz.table_close}} @@ -1924,12 +1924,12 @@ WOK def dot_control_pre %{ @@ -1941,15 +1941,15 @@ WOK end def toc_nav(f_pre=false,f_nxt=false,use=1) pre=nxt='' - toc=%{ + toc=%{ #{@vz.epub_png_nav_toc} } - pre=%{ + pre=%{ #{@vz.epub_png_nav_pre} } if f_pre==true - nxt=%{ + nxt=%{ #{@vz.epub_png_nav_nxt} } if f_nxt==true @@ -2439,7 +2439,7 @@ WOK fn='doc' if fn.to_s.empty? #you may wish to reconsider, sends to 'doc' where no segment info %{

- #{@endnote_part_a}#{fn}#{@md.lang_code_insert}#{Sfx[:epub_xhtml]}#{@endnote_part_b} + #{@endnote_part_a}#{fn}#{Sfx[:epub_xhtml]}#{@endnote_part_b}

} end diff --git a/lib/sisu/v3/epub_segments.rb b/lib/sisu/v3/epub_segments.rb index 7e4c412e..67d0884c 100644 --- a/lib/sisu/v3/epub_segments.rb +++ b/lib/sisu/v3/epub_segments.rb @@ -238,7 +238,7 @@ WOK and dob.ln==4 if tracking != 0 Seg.new(@md).tail - segfilename="#{dir_epub_cont}/#{@@seg_name_xhtml[tracking-1]}#{@md.lang_code_insert}#{Sfx[:epub_xhtml]}" + segfilename="#{dir_epub_cont}/#{@@seg_name_xhtml[tracking-1]}#{Sfx[:epub_xhtml]}" output_epub_cont_seg=File.new(segfilename,'w') if @@seg_name_xhtml[tracking-1] if dob.is=='heading' \ or @@seg_name_xhtml[tracking-1] !~/endnotes|book_index|metadata/ @@ -259,7 +259,7 @@ WOK heading_art(dob) head(dob) if @@seg_name_xhtml[tracking]=='sisu_manifest' # this is for manifest, includes navigation bug - segfilename="#{dir_epub_cont}/#{@@seg_name_xhtml[tracking]}#{@md.lang_code_insert}#{Sfx[:epub_xhtml]}" + segfilename="#{dir_epub_cont}/#{@@seg_name_xhtml[tracking]}#{Sfx[:epub_xhtml]}" output_epub_cont_seg=File.new(segfilename,'w') Seg_output.new(@md,output_epub_cont_seg,@@seg,@minitoc,'sisu_manifest').output Seg.new.reinitialise #BUG navigation bug with items following metadata, and occurring before manifest, this becomes a bug ... work area for book index, FIX diff --git a/lib/sisu/v3/epub_tune.rb b/lib/sisu/v3/epub_tune.rb index d691361b..fedef1b3 100644 --- a/lib/sisu/v3/epub_tune.rb +++ b/lib/sisu/v3/epub_tune.rb @@ -274,11 +274,11 @@ module SiSU_EPUB_Tune c=m[/"(.+?)"/m,1] caption=%{

#{c}

} if c png=m.scan(/\S+/)[0] - image_path='./image' + image_path=@md.file.output_path.epub.rel_image #image_path=@env.url.images_epub ins=if u \ and u.strip !~/^image$/ - %{#{caption}} - else %{#{caption}} + %{#{caption}} + else %{#{caption}} end word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) else -- cgit v1.2.3
- + #{@vz.png_nav_dot_pre} - + #{@vz.png_nav_dot_toc}