diff options
Diffstat (limited to 'lib/sisu/v3/epub_format.rb')
-rw-r--r-- | lib/sisu/v3/epub_format.rb | 117 |
1 files changed, 86 insertions, 31 deletions
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 '' |