def cover_html_content_for( book, static_folder, books, project_id, title_search, add_bookshelves ): cover_img = "{id}_cover_image.jpg".format(id=book.id) cover_img = cover_img if static_folder.joinpath(cover_img).exists() else None translate_author = ( ' data-l10n-id="author-{id}"'.format(id=book.author.name().lower()) if book.author.name() in ["Anonymous", "Various"] else "" ) translate_license = ( ' data-l10n-id="license-{id}"'.format(id=book.license.slug.lower()) if book.license.slug in ["PD", "Copyright"] else "" ) context = get_default_context(project_id=project_id, books=books) context.update( { "book": book, "cover_img": cover_img, "formats": main_formats_for(book), "translate_author": translate_author, "translate_license": translate_license, "title_search": title_search, "add_bookshelves": add_bookshelves, } ) template = jinja_env.get_template("cover_article.html") return template.render(**context)
def cover_html_content_for(book, static_folder, books, project_id): cover_img = "{id}_cover.jpg".format(id=book.id) cover_img = cover_img \ if path(os.path.join(static_folder, cover_img)).exists() else None translate_author = ' data-l10n-id="author-{id}"' \ .format(id=book.author.name().lower()) \ if book.author.name() in ['Anonymous', 'Various'] else '' translate_license = ' data-l10n-id="license-{id}"' \ .format(id=book.license.slug.lower()) \ if book.license.slug in ['PD', 'Copyright'] else '' context = get_default_context(project_id=project_id, books=books) context.update({ 'book': book, 'cover_img': cover_img, 'formats': main_formats_for(book), 'translate_author': translate_author, 'translate_license': translate_license }) template = jinja_env.get_template('cover_article.html') return template.render(**context)
def formats(self): from gutenbergtozim.utils import main_formats_for return main_formats_for(self)