diff --git a/src/calibre/ebooks/conversion/plugins/htmlz_output.py b/src/calibre/ebooks/conversion/plugins/htmlz_output.py
index eb8169d904..3fee896bf0 100644
--- a/src/calibre/ebooks/conversion/plugins/htmlz_output.py
+++ b/src/calibre/ebooks/conversion/plugins/htmlz_output.py
@@ -37,6 +37,11 @@ class HTMLZOutput(OutputFormatPlugin):
'external: Use an external CSS file that is linked in the document.\n'
'inline: Place the CSS in the head section of the document.'
)),
+ OptionRecommendation(name='htmlz_title_filename',
+ recommended_value=False, level=OptionRecommendation.LOW,
+ help=_('If set this option causes the file name of the html file'
+ ' inside the htmlz archive to be based on the book title.')
+ ),
])
def convert(self, oeb_book, output_path, input_plugin, opts, log):
@@ -44,6 +49,7 @@ class HTMLZOutput(OutputFormatPlugin):
from calibre.ebooks.oeb.base import OEB_IMAGES, SVG_MIME
from calibre.ebooks.metadata.opf2 import OPF, metadata_to_opf
from calibre.utils.zipfile import ZipFile
+ from calibre.utils.filenames import ascii_filename
# HTML
if opts.htmlz_css_type == 'inline':
@@ -59,7 +65,10 @@ class HTMLZOutput(OutputFormatPlugin):
htmlizer = OEB2HTMLizer(log)
html = htmlizer.oeb2html(oeb_book, opts)
- with open(os.path.join(tdir, u'index.html'), 'wb') as tf:
+ fname = u'index'
+ if opts.htmlz_title_filename:
+ fname = ascii_filename(unicode(oeb_book.metadata.title[0]))
+ with open(os.path.join(tdir, fname+u'.html'), 'wb') as tf:
tf.write(html)
# CSS
diff --git a/src/calibre/gui2/convert/htmlz_output.py b/src/calibre/gui2/convert/htmlz_output.py
index 6e9f5bd68c..421465429e 100644
--- a/src/calibre/gui2/convert/htmlz_output.py
+++ b/src/calibre/gui2/convert/htmlz_output.py
@@ -17,7 +17,8 @@ class PluginWidget(Widget, Ui_Form):
ICON = I('mimetypes/html.png')
def __init__(self, parent, get_option, get_help, db=None, book_id=None):
- Widget.__init__(self, parent, ['htmlz_css_type', 'htmlz_class_style'])
+ Widget.__init__(self, parent, ['htmlz_css_type', 'htmlz_class_style',
+ 'htmlz_title_filename'])
self.db, self.book_id = db, book_id
for x in get_option('htmlz_css_type').option.choices:
self.opt_htmlz_css_type.addItem(x)
diff --git a/src/calibre/gui2/convert/htmlz_output.ui b/src/calibre/gui2/convert/htmlz_output.ui
index 7593300653..b8aaca43c0 100644
--- a/src/calibre/gui2/convert/htmlz_output.ui
+++ b/src/calibre/gui2/convert/htmlz_output.ui
@@ -14,7 +14,7 @@
Form
- -
+
-
Qt::Vertical
@@ -27,6 +27,9 @@
+ -
+
+
-
@@ -51,8 +54,12 @@
- -
-
+
-
+
+
+ Use book &title as the filename for the HTML file inside the archive
+
+