E-book viewer: When viewing epub files that have their cover marked as non-linear, show the cover at the start of the book instead of the end. Fixes #1126030 (Epub file: import ziped and cover position)

This commit is contained in:
Kovid Goyal 2013-02-15 17:12:00 +05:30
parent 68007f2c7f
commit 173a3cbd9c

View File

@ -103,6 +103,12 @@ class EPUBInput(InputFormatPlugin):
if not self.for_viewer: if not self.for_viewer:
spine[0].getparent().remove(spine[0]) spine[0].getparent().remove(spine[0])
removed = guide_cover removed = guide_cover
else:
# Ensure the cover is displayed as the first item in the book, some
# epub files have it set with liner='no' which causes the cover to
# display in the end
spine[0].attrib.pop('linear', None)
opf.spine[0].is_linear = True
guide_elem.set('href', 'calibre_raster_cover.jpg') guide_elem.set('href', 'calibre_raster_cover.jpg')
from calibre.ebooks.oeb.base import OPF from calibre.ebooks.oeb.base import OPF
t = etree.SubElement(elem[0].getparent(), OPF('item'), t = etree.SubElement(elem[0].getparent(), OPF('item'),