EPUB Output: Add an option to flatten the EPUB file structure, specially for FBReaderJ. Fixes #7788 (Flatten content of EPUB created by recipes to make them more compatible)

This commit is contained in:
Kovid Goyal 2010-12-14 14:23:28 -07:00
parent 1b2bdfae81
commit 5f91edf752
4 changed files with 25 additions and 3 deletions

View File

@ -101,6 +101,13 @@ class EPUBOutput(OutputFormatPlugin):
)
),
OptionRecommendation(name='epub_flatten', recommended_value=False,
help=_('This option is needed only if you intend to use the EPUB'
' with FBReaderJ. It will flatten the file system inside the'
' EPUB, putting all files into the top level.')
),
])
recommendations = set([('pretty_print', True, OptionRecommendation.HIGH)])
@ -142,8 +149,12 @@ class EPUBOutput(OutputFormatPlugin):
def convert(self, oeb, output_path, input_plugin, opts, log):
self.log, self.opts, self.oeb = log, opts, oeb
from calibre.ebooks.oeb.transforms.filenames import UniqueFilenames
UniqueFilenames()(oeb, opts)
if self.opts.epub_flatten:
from calibre.ebooks.oeb.transforms.filenames import FlatFilenames
FlatFilenames()(oeb, opts)
else:
from calibre.ebooks.oeb.transforms.filenames import UniqueFilenames
UniqueFilenames()(oeb, opts)
self.workaround_ade_quirks()
self.workaround_webkit_quirks()

View File

@ -21,7 +21,7 @@ class PluginWidget(Widget, Ui_Form):
Widget.__init__(self, parent,
['dont_split_on_page_breaks', 'flow_size',
'no_default_epub_cover', 'no_svg_cover',
'preserve_cover_aspect_ratio',]
'preserve_cover_aspect_ratio', 'epub_flatten']
)
for i in range(2):
self.opt_no_svg_cover.toggle()

View File

@ -81,6 +81,13 @@
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="opt_epub_flatten">
<property name="text">
<string>&amp;Flatten EPUB file structure</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>

View File

@ -236,6 +236,10 @@ def fetch_scheduled_recipe(arg):
recs.append(('header', True, OptionRecommendation.HIGH))
recs.append(('header_format', '%t', OptionRecommendation.HIGH))
epub = load_defaults('epub_output')
if epub.get('epub_flatten', False):
recs.append(('epub_flatten', True, OptionRecommendation.HIGH))
args = [arg['recipe'], pt.name, recs]
if arg['username'] is not None:
recs.append(('username', arg['username'], OptionRecommendation.HIGH))