- html_tree, method="html", pretty_print=True))
-
- # strip fonts
- tmpdir = mkdtemp('-librarian-epub')
- cwd = os.getcwd()
-
- os.chdir(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'font-optimizer'))
- for fname in 'DejaVuSerif.ttf', 'DejaVuSerif-Bold.ttf', 'DejaVuSerif-Italic.ttf', 'DejaVuSerif-BoldItalic.ttf':
- optimizer_call = ['perl', 'subset.pl', '--chars', ''.join(chars).encode('utf-8'),
- get_resource('fonts/' + fname), os.path.join(tmpdir, fname)]
- if verbose:
- print "Running font-optimizer"
- subprocess.check_call(optimizer_call)
- else:
- subprocess.check_call(optimizer_call, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- zip.write(os.path.join(tmpdir, fname), os.path.join('OPS', fname))
- rmtree(tmpdir)
- os.chdir(cwd)
-
- zip.writestr('OPS/content.opf', etree.tostring(opf, pretty_print=True))
- contents = []
- title = node_name(etree.ETXPath('.//'+DCNS('title'))(input_xml)[0])
+ html_tree, pretty_print=True, xml_declaration=True,
+ encoding="utf-8",
+ doctype='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" ' +
+ '"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
+ ))
+
+ toc.add("Wesprzyj Wolne Lektury", "support.html")
+ manifest.append(etree.fromstring(
+ '<item id="support" href="support.html" media-type="application/xhtml+xml" />'))
+ spine.append(etree.fromstring(
+ '<itemref idref="support" />'))
+ html_string = open(get_resource('epub/support.html')).read()
+ chars.update(used_chars(etree.fromstring(html_string)))
+ zip.writestr('OPS/support.html', html_string)
+
+ toc.add("Strona redakcyjna", "last.html")
+ manifest.append(etree.fromstring(
+ '<item id="last" href="last.html" media-type="application/xhtml+xml" />'))
+ spine.append(etree.fromstring(
+ '<itemref idref="last" />'))
+ html_tree = xslt(document.edoc, get_resource('epub/xsltLast.xsl'), outputtype=output_type)
+ chars.update(used_chars(html_tree.getroot()))
+ zip.writestr('OPS/last.html', etree.tostring(
+ html_tree, pretty_print=True, xml_declaration=True,
+ encoding="utf-8",
+ doctype='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" ' +
+ '"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'
+ ))
+
+ if not flags or 'without-fonts' not in flags:
+ # strip fonts
+ tmpdir = mkdtemp('-librarian-epub')
+ try:
+ cwd = os.getcwd()
+ except OSError:
+ cwd = None
+
+ os.chdir(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'font-optimizer'))
+ for fname in 'DejaVuSerif.ttf', 'DejaVuSerif-Bold.ttf', 'DejaVuSerif-Italic.ttf', 'DejaVuSerif-BoldItalic.ttf':
+ optimizer_call = ['perl', 'subset.pl', '--chars',
+ ''.join(chars).encode('utf-8'),
+ get_resource('fonts/' + fname),
+ os.path.join(tmpdir, fname)]
+ if verbose:
+ print "Running font-optimizer"
+ subprocess.check_call(optimizer_call)
+ else:
+ dev_null = open(os.devnull, 'w')
+ subprocess.check_call(optimizer_call, stdout=dev_null, stderr=dev_null)
+ zip.write(os.path.join(tmpdir, fname), os.path.join('OPS', fname))
+ manifest.append(etree.fromstring(
+ '<item id="%s" href="%s" media-type="application/x-font-truetype" />' % (fname, fname)))
+ rmtree(tmpdir)
+ if cwd is not None:
+ os.chdir(cwd)
+ zip.writestr('OPS/content.opf', etree.tostring(opf, pretty_print=True,
+ xml_declaration=True, encoding="utf-8"))
+ title = document.book_info.title