diff options
-rw-r--r-- | data/doc/sisu/CHANGELOG_v3 | 13 | ||||
-rw-r--r-- | lib/sisu/v3/constants.rb | 12 | ||||
-rw-r--r-- | lib/sisu/v3/epub.rb | 9 | ||||
-rw-r--r-- | lib/sisu/v3/epub_format.rb | 117 | ||||
-rw-r--r-- | lib/sisu/v3/epub_segments.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v3/sysenv.rb | 17 | ||||
-rw-r--r-- | 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] << %{<div class="content">\n<div class="substance">} 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 <?xml version="1.0" encoding="UTF-8"?> -<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0"> +<container version="1.0" + xmlns="urn:oasis:names:tc:opendocument:xmlns:container"> <rootfiles> - <rootfile full-path="OPS/epb.opf" media-type="application/oebps-package+xml"/> + <rootfile full-path="#{Ep[:d_oebps]}/#{Ep[:f_opf]}" + media-type="application/oebps-package+xml" /> </rootfiles> </container> WOK @@ -1335,6 +1337,9 @@ WOK end def open <<WOK +<?xml version="1.0"?> +<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" + "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd"> <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1"> WOK end @@ -1353,11 +1358,13 @@ WOK <<WOK <!-- four required metadata items (for all NCX documents, (including the relaxed constraints of OPS 2.0) --> - <meta name="dtb:uid" content="#{@md.dgst[1]}"/> - <!-- <meta name="epub-creator" content="#{@md.publisher}"/> --> - <meta name="dtb:depth" content="#{depth}"/> - <meta name="dtb:totalPageCount" content="0"/> - <meta name="dtb:maxPageNumber" content="0"/> + <title>#{@md.title.full} by #{@md.author}</title> + <link href="css/xhtml.css" rel="stylesheet" type="text/css" id="main-css" /> + <meta name="dtb:uid" content="urn:uuid:#{@md.dgst[1]}" /> + <!-- <meta name="epub-creator" content="#{@md.publisher}" /> --> + <meta name="dtb:depth" content="#{depth}" /> + <meta name="dtb:totalPageCount" content="0" /> + <meta name="dtb:maxPageNumber" content="0" /> 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}" <<WOK - <navPoint id="navpoint-#{no}" playOrder="#{no}"> + <navPoint id="navpoint#{id_u}" playOrder="#{no}"> <navLabel> <text>Table of Contents</text> </navLabel> - <content src="index#{Sfx[:epub_xhtml]}"/> + <content src="index#{Sfx[:epub_xhtml]}" /> </navPoint> WOK end def navpoint(dob,no) + id_u=DISABLE[:epub][:ncx_navpoint_unique_id] \ + ? '' \ + : "-#{no}" <<WOK - <navPoint id="navpoint-#{no}" playOrder="#{no}"> + <navPoint id="navpoint#{id_u}" playOrder="#{no}"> <navLabel> <text>#{dob.obj}</text> </navLabel> - <content src="#{dob.name}#{Sfx[:epub_xhtml]}"/> + <content src="#{dob.name}#{Sfx[:epub_xhtml]}" /> WOK end def navpoint_top3(dob,no,name) + id_u=DISABLE[:epub][:ncx_navpoint_unique_id] \ + ? '' \ + : "-#{no}" <<WOK - <navPoint id="navpoint-#{no}" playOrder="#{no}"> + <navPoint id="navpoint#{id_u}" playOrder="#{no}"> <navLabel> <text>#{dob.obj}</text> </navLabel> - <content src="#{name}#{Sfx[:epub_xhtml]}"/> + <content src="#{name}#{Sfx[:epub_xhtml]}" /> 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 <dc:rights>#{rights}</dc:rights>} else '' end + f=SiSU_Env::SiSU_file.new(@md) <<WOK - <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf"> + <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:opf="http://www.idpf.org/2007/opf" + unique-identifier="urn:uuid:#{@md.dgst[1]}" version="2.0"> <dc:title>#{@md.title.full}</dc:title> #{author}#{editor}#{translator}#{illustrator}#{language}#{date_published}#{subject}#{rights} - <dc:identifier id="bookid">...</dc:identifier> - <dc:identifier id="EPB-UUID">urn:uuid:#{@md.dgst[1]}</dc:identifier> + <dc:identifier opf:scheme="URI">#{f.output_path.epub.url}/#{f.base_filename.epub}</dc:identifier> + <dc:identifier id="bookid">urn:uuid:#{@md.dgst[1]}</dc:identifier> + <!-- <dc:identifier id="EPB-UUID">urn:uuid:#{@md.dgst[1]}</dc:identifier> --> </metadata> WOK end @@ -1576,20 +1598,20 @@ WOK <<WOK <manifest> <!-- NCX --> - <item id="ncx" href="epb.ncx" media-type="application/x-dtbncx+xml"/> + <item id="ncx" href="#{Ep[:f_ncx]}" media-type="application/x-dtbncx+xml" /> <!-- CSS Style Sheets --> - <item id="main-css" href="css/xhtml.css" media-type="text/css"/> + <item id="main-css" href="css/xhtml.css" media-type="text/css" /> <!-- Content Documents --> WOK end def manifest_content_sisu_toc <<WOK - <item id="index" href="index.xhtml" media-type="application/xhtml+xml"/> + <item id="index" href="index.xhtml" media-type="application/xhtml+xml" /> WOK end def manifest_content(dob) <<WOK - <item id="#{dob.name}" href="#{dob.name}#{Sfx[:epub_xhtml]}" media-type="application/xhtml+xml"/> + <item id="#{dob.name}" href="#{dob.name}#{Sfx[:epub_xhtml]}" media-type="application/xhtml+xml" /> 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 - <item id="#{image}" href="image/#{image}.#{type}" media-type="image/#{type}"/> + <item id="#{image}" href="image/#{image}.#{type}" media-type="image/#{type}" /> WOK end images=images.join('') @@ -1610,19 +1632,19 @@ 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 <spine toc="ncx"> WOK end def spine_sisu_toc <<WOK - <itemref idref="index" linear="yes"/> + <itemref idref="index" linear="yes" /> WOK end def spine(dob) <<WOK - <itemref idref="#{dob.name}" linear="yes"/> + <itemref idref="#{dob.name}" linear="yes" /> WOK end def spine_close @@ -1630,6 +1652,27 @@ WOK </spine> WOK end + def guide_open + #guide: presentation order of XHTML files by reader). + <<WOK + <guide> +WOK + end + def guide_sisu_toc + <<WOK + <reference type="index" href="index#{Sfx[:epub_xhtml]}" /> +WOK + end + def guide(dob) + <<WOK + <reference type="text" href="#{dob.name}#{Sfx[:epub_xhtml]}" /> +WOK + end + def guide_close + <<WOK + </guide> +WOK + end self end def toc_head_escript @@ -1705,13 +1748,17 @@ WOK firstseg=%{<a href="#{@md.firstseg}#{@md.lang_code_insert}#{Sfx[:epub_xhtml]}" target="_top"> #{@vz.epub_png_nav_nxt} </a>} if @md.firstseg =~/\S+/ - %{<p class="align_right">#{firstseg}</p>} + DISABLE[:epub][:internal_navigation] \ + ? '' \ + : %{<p class="align_right">#{firstseg}</p>} end def seg_head_navigation_band_bottom firstseg=%{<a href="#{@md.firstseg}#{@md.lang_code_insert}#{Sfx[:epub_xhtml]}" target="_top"> #{@vz.epub_png_nav_nxt} </a>} if @md.firstseg =~/\S+/ - %{<p class="align_right">#{firstseg}</p>} + DISABLE[:epub][:internal_navigation] \ + ? '' \ + : %{<p class="align_right">#{firstseg}</p>} end def manifest_link(text) #watch fix removed font size 2 %{ <a href="#{@md.fn[:manifest]}" target="_top" #{@vz.js_manifest}>#{text}</a>} @@ -1888,7 +1935,9 @@ WOK #{@vz.epub_png_nav_nxt} </a> } if f_nxt==true - %{<p class="align_right"> + DISABLE[:epub][:internal_navigation] \ + ? '' \ + : %{<p class="align_right"> #{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/ \ |