From 0e56c4eede2b7cf040ad377c9119b36b7207f263 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 4 Jul 2018 14:22:05 +0530 Subject: [PATCH] UI for FB2 output options --- .../ebooks/conversion/plugins/fb2_output.py | 27 ++++++++++++------- src/pyj/book_list/conversion_widgets.pyj | 9 +++++++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/calibre/ebooks/conversion/plugins/fb2_output.py b/src/calibre/ebooks/conversion/plugins/fb2_output.py index ca38c8d608..aaa54db5af 100644 --- a/src/calibre/ebooks/conversion/plugins/fb2_output.py +++ b/src/calibre/ebooks/conversion/plugins/fb2_output.py @@ -142,22 +142,31 @@ class FB2Output(OutputFormatPlugin): 'home_sex', # Erotica & sex 'home', # Other ] + ui_data = { + 'sectionize': { + 'toc': _('Section per entry in the ToC'), + 'files': _('Section per file'), + 'nothing': _('A single section') + }, + 'genres': FB2_GENRES, + } options = set([ OptionRecommendation(name='sectionize', recommended_value='files', level=OptionRecommendation.LOW, - choices=['toc', 'files', 'nothing'], - help=_('Specify the sectionization of elements. ' - 'A value of "nothing" turns the book into a single section. ' - 'A value of "files" turns each file into a separate section; use this if your device is having trouble. ' - 'A value of "Table of Contents" turns the entries in the Table of Contents into titles and creates sections; ' - 'if it fails, adjust the "Structure detection" and/or "Table of Contents" settings ' - '(turn on "Force use of auto-generated Table of Contents").')), + choices=ui_data['sectionize'], + help=_('Specify how sections are created:\n' + ' * nothing: {nothing}\n' + ' * files: {files}\n' + ' * toc: {toc}\n' + 'If ToC based generation fails, adjust the "Structure detection" and/or "Table of Contents" settings ' + '(turn on "Force use of auto-generated Table of Contents").').format(**ui_data['sectionize']) + ), OptionRecommendation(name='fb2_genre', recommended_value='antique', level=OptionRecommendation.LOW, choices=FB2_GENRES, - help=(_('Genre for the book. Choices: %s\n\n See: ') % ', '.join(FB2_GENRES)) + 'http://www.fictionbook.org/index.php/Eng:FictionBook_2.1_genres ' + - _('for a complete list with descriptions.')), + help=(_('Genre for the book. Choices: %s\n\n See: ') % ', '.join(FB2_GENRES) + ) + 'http://www.fictionbook.org/index.php/Eng:FictionBook_2.1_genres ' + _('for a complete list with descriptions.')), ]) def convert(self, oeb_book, output_path, input_plugin, opts, log): diff --git a/src/pyj/book_list/conversion_widgets.pyj b/src/pyj/book_list/conversion_widgets.pyj index 9fb23cc1ff..d47f8c8b19 100644 --- a/src/pyj/book_list/conversion_widgets.pyj +++ b/src/pyj/book_list/conversion_widgets.pyj @@ -559,6 +559,15 @@ def docx_output(container): g.appendChild(checkbox('preserve_cover_aspect_ratio', _('Preserve the aspect ratio of the image inserted as cover'))) # }}} +# FB2 Output {{{ +@ep +def fb2_output(container): + g = E.div(class_='simple-group') + container.appendChild(g) + g.appendChild(choices('sectionize', _('Sec&tionize:'), ui_data.sectionize)) + g.appendChild(choices('fb2_genre', _('&Genre:'), ui_data.genres)) +# }}} + def restore_defaults(): for setting in registry: set(setting, get_option_default_value(setting))