mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
EPUB Output: Fix generated OPF to be compatible with the asinine epubchecker. Also fix bug that was causing the default cover to use the date even when authors are present.
This commit is contained in:
parent
ddc22b2480
commit
81d70b68d9
@ -125,7 +125,9 @@ class EPUBOutput(OutputFormatPlugin):
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>%(title)s</h1>
|
<h1>%(title)s</h1>
|
||||||
<img class="logo" src="%(img)s" alt="calibre logo" />
|
<div style="text-align:center">
|
||||||
|
<img class="logo" src="%(img)s" alt="calibre logo" />
|
||||||
|
</div>
|
||||||
<h2>%(author)s</h2>
|
<h2>%(author)s</h2>
|
||||||
<h4>Produced by %(app)s</h4>
|
<h4>Produced by %(app)s</h4>
|
||||||
</body>
|
</body>
|
||||||
@ -196,7 +198,7 @@ class EPUBOutput(OutputFormatPlugin):
|
|||||||
images_rc
|
images_rc
|
||||||
m = self.oeb.metadata
|
m = self.oeb.metadata
|
||||||
title = unicode(m.title[0])
|
title = unicode(m.title[0])
|
||||||
a = [unicode(x) for x in m.creators if m.role == 'aut']
|
a = [unicode(x) for x in m.creator if x.role == 'aut']
|
||||||
author = authors_to_string(a)
|
author = authors_to_string(a)
|
||||||
if QApplication.instance() is None: QApplication([])
|
if QApplication.instance() is None: QApplication([])
|
||||||
f = QFile(':/library')
|
f = QFile(':/library')
|
||||||
|
@ -694,7 +694,6 @@ class Metadata(object):
|
|||||||
def to_opf2(self, parent=None):
|
def to_opf2(self, parent=None):
|
||||||
nsmap = self._opf2_nsmap
|
nsmap = self._opf2_nsmap
|
||||||
nsrmap = dict((value, key) for key, value in nsmap.items())
|
nsrmap = dict((value, key) for key, value in nsmap.items())
|
||||||
nsmap.pop('opf', '')
|
|
||||||
elem = element(parent, OPF('metadata'), nsmap=nsmap)
|
elem = element(parent, OPF('metadata'), nsmap=nsmap)
|
||||||
for term in self.items:
|
for term in self.items:
|
||||||
for item in self.items[term]:
|
for item in self.items[term]:
|
||||||
|
@ -3,7 +3,7 @@ __license__ = 'GPL 3'
|
|||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os
|
import os, re
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
@ -34,6 +34,10 @@ class OEBOutput(OutputFormatPlugin):
|
|||||||
if root is not None:
|
if root is not None:
|
||||||
raw = etree.tostring(root, pretty_print=True,
|
raw = etree.tostring(root, pretty_print=True,
|
||||||
encoding='utf-8', xml_declaration=True)
|
encoding='utf-8', xml_declaration=True)
|
||||||
|
if key == OPF_MIME:
|
||||||
|
# Needed as I can't get lxml to output opf:role and
|
||||||
|
# not output <opf:metadata> as well
|
||||||
|
raw = re.sub(r'(<[/]{0,1})opf:', r'\1', raw)
|
||||||
with open(href, 'wb') as f:
|
with open(href, 'wb') as f:
|
||||||
f.write(raw)
|
f.write(raw)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user