UI for FB2 output options

This commit is contained in:
Kovid Goyal 2018-07-04 14:22:05 +05:30
parent 75b6a17bd8
commit 0e56c4eede
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 27 additions and 9 deletions

View File

@ -142,22 +142,31 @@ class FB2Output(OutputFormatPlugin):
'home_sex', # Erotica & sex 'home_sex', # Erotica & sex
'home', # Other '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([ options = set([
OptionRecommendation(name='sectionize', OptionRecommendation(name='sectionize',
recommended_value='files', level=OptionRecommendation.LOW, recommended_value='files', level=OptionRecommendation.LOW,
choices=['toc', 'files', 'nothing'], choices=ui_data['sectionize'],
help=_('Specify the sectionization of elements. ' help=_('Specify how sections are created:\n'
'A value of "nothing" turns the book into a single section. ' ' * nothing: {nothing}\n'
'A value of "files" turns each file into a separate section; use this if your device is having trouble. ' ' * files: {files}\n'
'A value of "Table of Contents" turns the entries in the Table of Contents into titles and creates sections; ' ' * toc: {toc}\n'
'if it fails, adjust the "Structure detection" and/or "Table of Contents" settings ' '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").')), '(turn on "Force use of auto-generated Table of Contents").').format(**ui_data['sectionize'])
),
OptionRecommendation(name='fb2_genre', OptionRecommendation(name='fb2_genre',
recommended_value='antique', level=OptionRecommendation.LOW, recommended_value='antique', level=OptionRecommendation.LOW,
choices=FB2_GENRES, 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 ' + help=(_('Genre for the book. Choices: %s\n\n See: ') % ', '.join(FB2_GENRES)
_('for a complete list with descriptions.')), ) + '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): def convert(self, oeb_book, output_path, input_plugin, opts, log):

View File

@ -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'))) 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(): def restore_defaults():
for setting in registry: for setting in registry:
set(setting, get_option_default_value(setting)) set(setting, get_option_default_value(setting))