From 532c0301d456758990609bdf65b718ce2f1f32ca Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 9 Aug 2011 00:06:18 -0400 Subject: v3: epub, constants, experiment with presentation * disable some internal "features" * make file and directory naming more flexible, now using 'OEBPS', 'toc.ncx', 'content.opf', * adjustment of some headers and general tuning * add opf guide * clean processing directory between each build * constants, added constants Ep (for epub) * constants, added DISABLE (used here with epub) --- data/doc/sisu/CHANGELOG_v3 | 13 ++++- lib/sisu/v3/constants.rb | 12 +++++ lib/sisu/v3/epub.rb | 9 ++-- lib/sisu/v3/epub_format.rb | 117 +++++++++++++++++++++++++++++++------------ lib/sisu/v3/epub_segments.rb | 2 +- lib/sisu/v3/sysenv.rb | 17 ++++--- lib/sisu/v3/urls.rb | 2 +- 7 files changed, 127 insertions(+), 45 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 47d99f52..c4898e76 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -31,7 +31,18 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.0.15.orig.tar.gz * texpdf, possibility to translate "Contents" for table of contents - * constants, re-arranged + * epub, experiment with presentation + * disable some internal "features" + * make file and directory naming more flexible, now using + 'OEBPS', 'toc.ncx', 'content.opf', + * adjustment of some headers and general tuning + * add opf guide + * clean processing directory between each build + + * constants + * added constants Ep (for epub) + * added DISABLE (used here with epub) + * re-arranged * objects.txt, removed, cleaning diff --git a/lib/sisu/v3/constants.rb b/lib/sisu/v3/constants.rb index 3357996b..498ee1f3 100644 --- a/lib/sisu/v3/constants.rb +++ b/lib/sisu/v3/constants.rb @@ -195,6 +195,11 @@ Px={ lv5: '.', lv6: '.', } +Ep={ + d_oebps: 'OEBPS', + f_ncx: 'toc.ncx', + f_opf: 'content.opf', +} Db={ name_prefix: "SiSU#{SiSU_version_dir}e_", name_prefix_db: "sisu_#{SiSU_version_dir}e_", @@ -229,6 +234,13 @@ Gt={ conf: 'conf', skin: 'conf/skin', #Gt[:skin: 'conf/skin/doc' } +DISABLE={ + epub: { + internal_navigation: true, + per_section_title: true, + ncx_navpoint_unique_id: true, + }, +} __END__ consider: 〔comment〕 diff --git a/lib/sisu/v3/epub.rb b/lib/sisu/v3/epub.rb index 2522b68a..83a0a795 100644 --- a/lib/sisu/v3/epub.rb +++ b/lib/sisu/v3/epub.rb @@ -198,7 +198,7 @@ module SiSU_EPUB toc=nil @@firstseg=nil @@toc={ seg: [], seg_mini: [], scr: [], ncx: [], opf: [] } - md_opf_a_content,md_opf_a_spine=[],[] + md_opf_a_content,md_opf_a_spine,md_opf_a_guide=[],[],[] @nav_no=1 @@toc[:ncx] << @epub.toc_ncx.open #epub ncx navmap @@toc[:ncx] << @epub.toc_ncx.head_open << @epub.toc_ncx.head << @epub.toc_ncx.head_close @@ -212,6 +212,7 @@ module SiSU_EPUB @@toc[:scr] << %{
\n
} md_opf_a_content << @epub.metadata_opf.manifest_content_sisu_toc md_opf_a_spine << @epub.metadata_opf.spine_sisu_toc + md_opf_a_guide << @epub.metadata_opf.guide_sisu_toc @ncxo=[nil,false,false,false,false,false,false] @dob_toc2,@dob_toc3=nil,nil @ncx_cls=[] @@ -254,6 +255,7 @@ module SiSU_EPUB @ncxo[4]=true md_opf_a_content << @epub.metadata_opf.manifest_content(dob_toc) md_opf_a_spine << @epub.metadata_opf.spine(dob_toc) + md_opf_a_guide << @epub.metadata_opf.guide(dob_toc) Toc.new(@md,dob_toc).level_4 when 5; Toc.new(@md,dob_toc).level_5 when 6; Toc.new(@md,dob_toc).level_6 @@ -288,6 +290,7 @@ module SiSU_EPUB @@toc[:ncx] << @epub.toc_ncx.close @@toc[:opf] << md_opf_a_content << @epub.metadata_opf.manifest_close @@toc[:opf] << @epub.metadata_opf.spine_open << md_opf_a_spine << @epub.metadata_opf.spine_close + @@toc[:opf] << @epub.metadata_opf.guide_open << md_opf_a_guide << @epub.metadata_opf.guide_close @@toc[:opf] << @epub.metadata_opf.package_close @@toc[:opf]=@@toc[:opf].flatten Epub_output.new(@md,@@toc[:opf]).epub_metadata_opf @@ -629,9 +632,9 @@ module SiSU_EPUB def images img_pth=@md.env.path.image_source_include @md.ec[:image].each do |x| - if FileTest.directory?("#{@md.env.processing_path.epub}/OPS/image") \ + if FileTest.directory?("#{@md.env.processing_path.epub}/#{Ep[:d_oebps]}/image") \ and FileTest.file?("#{img_pth}/#{x}") - cp("#{img_pth}/#{x}","#{@md.env.processing_path.epub}/OPS/image") + cp("#{img_pth}/#{x}","#{@md.env.processing_path.epub}/#{Ep[:d_oebps]}/image") end end end diff --git a/lib/sisu/v3/epub_format.rb b/lib/sisu/v3/epub_format.rb index 2a9af20e..6afae58b 100644 --- a/lib/sisu/v3/epub_format.rb +++ b/lib/sisu/v3/epub_format.rb @@ -1310,12 +1310,14 @@ WOK end def metainf_container #container.xml file in META-INF directory #simple, make sure full-path of rootfile points to metadata.opf - #epub_metadata.opf epb.opf + #epub_metadata.opf content.opf < - + - + WOK @@ -1335,6 +1337,9 @@ WOK end def open < + WOK end @@ -1353,11 +1358,13 @@ WOK < - - - - - + #{@md.title.full} by #{@md.author} + + + + + + WOK end def head_close @@ -1385,31 +1392,40 @@ WOK WOK end def navmap_sisu_toc(no) + id_u=DISABLE[:epub][:ncx_navpoint_unique_id] \ + ? '' \ + : "-#{no}" < + Table of Contents - + WOK end def navpoint(dob,no) + id_u=DISABLE[:epub][:ncx_navpoint_unique_id] \ + ? '' \ + : "-#{no}" < + #{dob.obj} - + WOK end def navpoint_top3(dob,no,name) + id_u=DISABLE[:epub][:ncx_navpoint_unique_id] \ + ? '' \ + : "-#{no}" < + #{dob.obj} - + WOK end def navpoint_close @@ -1433,6 +1449,8 @@ WOK manifest_close spine_open spine_close + guide_open + guide_close package_close end def package_open @@ -1563,12 +1581,16 @@ WOK %{\n #{rights}} else '' end + f=SiSU_Env::SiSU_file.new(@md) < + #{@md.title.full} #{author}#{editor}#{translator}#{illustrator}#{language}#{date_published}#{subject}#{rights} - ... - urn:uuid:#{@md.dgst[1]} + #{f.output_path.epub.url}/#{f.base_filename.epub} + urn:uuid:#{@md.dgst[1]} + WOK end @@ -1576,20 +1598,20 @@ WOK < - + - + WOK end def manifest_content_sisu_toc < + WOK end def manifest_content(dob) < + WOK end def manifest_images(imgs) @@ -1598,7 +1620,7 @@ WOK imgs.each do |i| image,type=/(\S+?)\.(png|jpg|gif)/.match(i)[1,2] images<<< + WOK end images=images.join('') @@ -1610,24 +1632,45 @@ WOK WOK end def spine_open - #spine: reading order of HTML files from manifest, idref attribute refers back to id in manifest (exclude images, CSS etc.). + #spine: reading order of XHTML files from manifest, idref attribute refers back to id in manifest (exclude images, CSS etc.). < WOK end def spine_sisu_toc < + WOK end def spine(dob) < + WOK end def spine_close < +WOK + end + def guide_open + #guide: presentation order of XHTML files by reader). + < +WOK + end + def guide_sisu_toc + < +WOK + end + def guide(dob) + < +WOK + end + def guide_close + < WOK end self @@ -1705,13 +1748,17 @@ WOK firstseg=%{ #{@vz.epub_png_nav_nxt} } if @md.firstseg =~/\S+/ - %{

#{firstseg}

} + DISABLE[:epub][:internal_navigation] \ + ? '' \ + : %{

#{firstseg}

} end def seg_head_navigation_band_bottom firstseg=%{ #{@vz.epub_png_nav_nxt} } if @md.firstseg =~/\S+/ - %{

#{firstseg}

} + DISABLE[:epub][:internal_navigation] \ + ? '' \ + : %{

#{firstseg}

} end def manifest_link(text) #watch fix removed font size 2 %{ #{text}} @@ -1888,7 +1935,9 @@ WOK #{@vz.epub_png_nav_nxt} } if f_nxt==true - %{

+ DISABLE[:epub][:internal_navigation] \ + ? '' \ + : %{

#{pre} #{toc} #{nxt} @@ -2215,13 +2264,19 @@ WOK } end def title_heading1 - title_heading('h1','tiny') + id_u=DISABLE[:epub][:per_section_title] \ + ? '' \ + : title_heading('h1','tiny') end def title_heading2 - title_heading('h2','tiny') + id_u=DISABLE[:epub][:per_section_title] \ + ? '' \ + : title_heading('h2','tiny') end def title_heading3 - title_heading('h3','tiny') + id_u=DISABLE[:epub][:per_section_title] \ + ? '' \ + : title_heading('h3','tiny') end def title_heading4 '' diff --git a/lib/sisu/v3/epub_segments.rb b/lib/sisu/v3/epub_segments.rb index b9b75b9c..23af70f7 100644 --- a/lib/sisu/v3/epub_segments.rb +++ b/lib/sisu/v3/epub_segments.rb @@ -223,7 +223,7 @@ WOK end end if @@is4==1 - dir_epub_cont="#{@md.env.processing_path.epub}/OPS" + dir_epub_cont="#{@md.env.processing_path.epub}/#{Ep[:d_oebps]}" if newfile==1 \ or dob.obj =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/ newfile=0 diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index c265b010..80069f9d 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -1848,15 +1848,16 @@ WOK "#{processing}/epub/#{@fnb}" end def epub_bld #(md) + rm_rf(processing_path.epub) if FileTest.directory?(processing_path.epub) mkdir_p(processing_path.epub) unless FileTest.directory?(processing_path.epub) mkdir_p("#{processing_path.epub}/META-INF") unless FileTest.directory?("#{processing_path.epub}/META-INF") - mkdir_p("#{processing_path.epub}/OPS/image") unless FileTest.directory?("#{processing_path.epub}/OPS/image") - mkdir_p("#{processing_path.epub}/OPS/css") unless FileTest.directory?("#{processing_path.epub}/OPS/css") + mkdir_p("#{processing_path.epub}/#{Ep[:d_oebps]}/image") unless FileTest.directory?("#{processing_path.epub}/#{Ep[:d_oebps]}/image") + mkdir_p("#{processing_path.epub}/#{Ep[:d_oebps]}/css") unless FileTest.directory?("#{processing_path.epub}/#{Ep[:d_oebps]}/css") images=%W[bullet_09.png arrow_next_red.png arrow_prev_red.png arrow_up_red.png] processing_path.epub end def epub_cp_images(md) - pth="#{processing_path.epub}/OPS/image" + pth="#{processing_path.epub}/#{Ep[:d_oebps]}/image" mkdir_p(pth) unless FileTest.directory?(pth) src="#{path.share}/image" images=%W[bullet_09.png arrow_next_red.png arrow_prev_red.png arrow_up_red.png] @@ -4446,27 +4447,27 @@ WOK def epub @pth=@env.processing_path.epub def xhtml_index - filename_index="#{@pth}/OPS/index.xhtml" + filename_index="#{@pth}/#{Ep[:d_oebps]}/index.xhtml" File.new(filename_index,'w+') end def xhtml_segtoc - filename_segtoc="#{@pth}/OPS/toc.xhtml" + filename_segtoc="#{@pth}/#{Ep[:d_oebps]}/toc.xhtml" File.new(filename_segtoc,'w+') end def mimetype #fixed application/epub+zip ~/grotto/theatre/dbld/builds/epub_sample/mimetype File.new("#{@pth}/mimetype",'w') end def metadata #variable matadata ~/grotto/theatre/dbld/builds/epub_sample/metadata.opf - File.new("#{@pth}/OPS/epb.opf",'w') + File.new("#{@pth}/#{Ep[:d_oebps]}/#{Ep[:f_opf]}",'w') end def toc_ncx #variable toc ~/grotto/theatre/dbld/builds/epub_sample/toc.ncx - File.new("#{@pth}/OPS/epb.ncx",'w') + File.new("#{@pth}/#{Ep[:d_oebps]}/#{Ep[:f_ncx]}",'w') end def metainf_cont #variable content ~/grotto/theatre/dbld/builds/epub_sample/META-INF/container.xml File.new("#{@pth}/META-INF/container.xml",'w') end def xhtml_css #fixed epub xhtml css - File.new("#{@pth}/OPS/css/xhtml.css",'w') + File.new("#{@pth}/#{Ep[:d_oebps]}/css/xhtml.css",'w') end self end diff --git a/lib/sisu/v3/urls.rb b/lib/sisu/v3/urls.rb index d5698b53..5f9b8f00 100644 --- a/lib/sisu/v3/urls.rb +++ b/lib/sisu/v3/urls.rb @@ -261,7 +261,7 @@ module SiSU_urls if x=~/^e/ \ and @opt.cmd=~/e/ \ and x=~/^[#{@opt.cmd}]/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@env.processing_path.epub}/OPS/toc.xhtml").maintenance + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@env.processing_path.epub}/#{Ep[:d_oebps]}/toc.xhtml").maintenance end if x=~/^o/ \ and @opt.cmd=~/o/ \ -- cgit v1.2.3