Fix #5409 (Covers in ePub don't show on device)

This commit is contained in:
Kovid Goyal 2010-04-29 15:41:18 -06:00
parent 2982987cb4
commit 5389be9376
3 changed files with 44 additions and 6 deletions

View File

@ -81,12 +81,40 @@ class EPUBOutput(OutputFormatPlugin):
OptionRecommendation(name='no_default_epub_cover', recommended_value=False, OptionRecommendation(name='no_default_epub_cover', recommended_value=False,
help=_('Normally, if the input file has no cover and you don\'t' help=_('Normally, if the input file has no cover and you don\'t'
' specify one, a default cover is generated with the title, ' ' specify one, a default cover is generated with the title, '
'authors, etc. This option disables the generation of this cover.')), 'authors, etc. This option disables the generation of this cover.')
),
OptionRecommendation(name='no_svg_cover', recommended_value=False,
help=_('Do not use SVG for the book cover. Use this option if '
'your EPUB is going to be used ona device that does not '
'support SVG, like the iPhone or the JetBook Lite. '
'Without this option, such devices will display the cover '
'as a blank page.')
),
]) ])
recommendations = set([('pretty_print', True, OptionRecommendation.HIGH)]) recommendations = set([('pretty_print', True, OptionRecommendation.HIGH)])
NONSVG_TITLEPAGE_COVER = '''\
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="calibre:cover" content="true" />
<title>Cover</title>
<style type="text/css" title="override_css">
@page {padding: 0pt; margin:0pt}
body { text-align: center; padding:0pt; margin: 0pt; }
div { padding:0pt; margin: 0pt; }
</style>
</head>
<body>
<div>
<img src="%s" alt="cover" style="height: 100%%" />
</div>
</body>
</html>
'''
TITLEPAGE_COVER = '''\ TITLEPAGE_COVER = '''\
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
@ -301,7 +329,9 @@ class EPUBOutput(OutputFormatPlugin):
else: else:
href = self.default_cover() href = self.default_cover()
if href is not None: if href is not None:
tp = self.TITLEPAGE_COVER%unquote(href) templ = self.NONSVG_TITLEPAGE_COVER if self.opts.no_svg_cover \
else self.TITLEPAGE_COVER
tp = templ%unquote(href)
id, href = m.generate('titlepage', 'titlepage.xhtml') id, href = m.generate('titlepage', 'titlepage.xhtml')
item = m.add(id, href, guess_type('t.xhtml')[0], item = m.add(id, href, guess_type('t.xhtml')[0],
data=etree.fromstring(tp)) data=etree.fromstring(tp))

View File

@ -17,7 +17,8 @@ class PluginWidget(Widget, Ui_Form):
def __init__(self, parent, get_option, get_help, db=None, book_id=None): def __init__(self, parent, get_option, get_help, db=None, book_id=None):
Widget.__init__(self, parent, 'epub_output', Widget.__init__(self, parent, 'epub_output',
['dont_split_on_page_breaks', 'flow_size', 'no_default_epub_cover'] ['dont_split_on_page_breaks', 'flow_size',
'no_default_epub_cover', 'no_svg_cover']
) )
self.db, self.book_id = db, book_id self.db, self.book_id = db, book_id
self.initialize_options(get_option, get_help, db, book_id) self.initialize_options(get_option, get_help, db, book_id)

View File

@ -21,7 +21,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Split files &amp;larger than:</string> <string>Split files &amp;larger than:</string>
@ -31,7 +31,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="3" column="1">
<widget class="QSpinBox" name="opt_flow_size"> <widget class="QSpinBox" name="opt_flow_size">
<property name="suffix"> <property name="suffix">
<string> KB</string> <string> KB</string>
@ -47,7 +47,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="4" column="0">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -67,6 +67,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QCheckBox" name="opt_no_svg_cover">
<property name="text">
<string>No &amp;SVG cover</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>