diff --git a/src/calibre/ebooks/epub/output.py b/src/calibre/ebooks/epub/output.py
index 4bc0f679cc..2e254e99cc 100644
--- a/src/calibre/ebooks/epub/output.py
+++ b/src/calibre/ebooks/epub/output.py
@@ -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()
diff --git a/src/calibre/gui2/convert/epub_output.py b/src/calibre/gui2/convert/epub_output.py
index c1ef6282f7..2fcbd751fe 100644
--- a/src/calibre/gui2/convert/epub_output.py
+++ b/src/calibre/gui2/convert/epub_output.py
@@ -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()
diff --git a/src/calibre/gui2/convert/epub_output.ui b/src/calibre/gui2/convert/epub_output.ui
index abca2405e8..a0d9570226 100644
--- a/src/calibre/gui2/convert/epub_output.ui
+++ b/src/calibre/gui2/convert/epub_output.ui
@@ -81,6 +81,13 @@
+ -
+
+
+ &Flatten EPUB file structure
+
+
+
diff --git a/src/calibre/gui2/tools.py b/src/calibre/gui2/tools.py
index fc84e88d09..d18cc61baf 100644
--- a/src/calibre/gui2/tools.py
+++ b/src/calibre/gui2/tools.py
@@ -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))