lib/softcover/builders/epub.rb in softcover-1.4.2 vs lib/softcover/builders/epub.rb in softcover-1.4.3

- old
+ new

@@ -50,11 +50,11 @@ def escape(string) CGI.escape_html(string) end # Returns a content.opf file based on a valid template. - def content_opf_template(title, copyright, author, uuid, cover_id, + def content_opf_template(escaped_title, copyright, author, uuid, cover_id, toc_chapters, manifest_chapters, images) if cover_id cover_meta = %(<meta name="cover" content="#{cover_id}"/>) cover_html = %(<item id="cover" href="#{cover_filename}" media-type="application/xhtml+xml"/>) cover_ref = '<itemref idref="cover" linear="no" />' @@ -63,14 +63,14 @@ end %(<?xml version="1.0" encoding="UTF-8"?> <package unique-identifier="BookID" version="3.0" xmlns="http://www.idpf.org/2007/opf"> <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:opf="http://www.idpf.org/2007/opf"> - <dc:title>#{escape(title)}</dc:title> + <dc:title>#{escaped_title}</dc:title> <dc:language>en</dc:language> <dc:rights>Copyright (c) #{copyright} #{escape(author)}</dc:rights> - <dc:creator>#{author}</dc:creator> + <dc:creator>#{escape(author)}</dc:creator> <dc:publisher>Softcover</dc:publisher> <dc:identifier id="BookID">urn:uuid:#{uuid}</dc:identifier> <meta property="dcterms:modified">#{Time.now.strftime('%Y-%m-%dT%H:%M:%S')}Z</meta> #{cover_meta} </metadata> @@ -94,40 +94,40 @@ </package> ) end # Returns a toc.ncx file based on a valid template. - def toc_ncx_template(title, uuid, chapter_nav) + def toc_ncx_template(escaped_title, uuid, chapter_nav) %(<?xml version="1.0" encoding="UTF-8"?> <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1"> <head> <meta name="dtb:uid" content="#{uuid}"/> <meta name="dtb:depth" content="2"/> <meta name="dtb:totalPageCount" content="0"/> <meta name="dtb:maxPageNumber" content="0"/> </head> <docTitle> - <text>#{escape(title)}</text> + <text>#{escaped_title}</text> </docTitle> <navMap> #{chapter_nav.join("\n")} </navMap> </ncx> ) end # Returns the navigation HTML based on a valid template. - def nav_html_template(title, nav_list) + def nav_html_template(escaped_title, nav_list) %(<?xml version="1.0" encoding="utf-8"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"> <head> <meta charset="UTF-8" /> - <title>#{title}</title> + <title>#{escaped_title}</title> </head> <body> <nav epub:type="toc"> - <h1>#{escape(title)}</h1> + <h1>#{escaped_title}</h1> <ol> #{nav_list.join("\n")} </ol> </nav> </body> @@ -543,11 +543,13 @@ # invalid character such as a number. label = File.basename(image).gsub('.', '-') id = "img-#{label}" %(<item id="#{id}" href="#{href}" media-type="image/#{ext}"/>) end - content_opf_template(manifest.title, manifest.copyright, + + manifest.html_title + content_opf_template(manifest.html_title, manifest.copyright, manifest.author, manifest.uuid, cover_id(options), toc_ch, man_ch, images) end def cover_page @@ -588,11 +590,11 @@ chapter_nav << %( <navLabel><text>#{chapter_name(n)}</text></navLabel>) chapter_nav << %( <content src="#{xhtml(chapter.fragment_name)}"/>) chapter_nav << %(</navPoint>) end end - toc_ncx_template(manifest.title, manifest.uuid, chapter_nav) + toc_ncx_template(manifest.html_title, manifest.uuid, chapter_nav) end def chapter_name(n) n == 0 ? language_labels["frontmatter"] : strip_html(chapters[n].menu_heading) end @@ -613,10 +615,10 @@ nav_list = manifest.chapters.map do |chapter| element = preview? ? chapter.title : nav_link(chapter) %(<li>#{element}</li>) end end - nav_html_template(manifest.title, nav_list) + nav_html_template(manifest.html_title, nav_list) end # Returns a navigation link for the chapter. def nav_link(chapter) %(<a href="#{xhtml(chapter.fragment_name)}">#{chapter.html_title}</a>) \ No newline at end of file