From 35e339dba8a99b371714b52523fdbb4b95237f79 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 22 Aug 2012 13:53:53 +0200 Subject: [PATCH] closes #2043: covers in ebooks --- apps/catalogue/constants.py | 2 +- apps/catalogue/fields.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/catalogue/constants.py b/apps/catalogue/constants.py index 1ad0b1b5e..e2181afa0 100644 --- a/apps/catalogue/constants.py +++ b/apps/catalogue/constants.py @@ -16,6 +16,6 @@ EBOOK_FORMATS_WITHOUT_CHILDREN = ['txt', 'fb2'] # Those will be generated for all books. EBOOK_FORMATS_WITH_CHILDREN = ['pdf', 'epub', 'mobi'] # Those will be generated when inherited cover changes. -EBOOK_FORMATS_WITH_COVERS = ['mobi'] +EBOOK_FORMATS_WITH_COVERS = ['pdf', 'epub', 'mobi'] EBOOK_FORMATS = EBOOK_FORMATS_WITHOUT_CHILDREN + EBOOK_FORMATS_WITH_CHILDREN diff --git a/apps/catalogue/fields.py b/apps/catalogue/fields.py index 0e02ff90f..68aaa4025 100644 --- a/apps/catalogue/fields.py +++ b/apps/catalogue/fields.py @@ -105,13 +105,22 @@ class BuildTxt(BuildEbook): class BuildPdf(BuildEbook): @staticmethod def transform(wldoc, fieldfile): - return wldoc.as_pdf(morefloats=settings.LIBRARIAN_PDF_MOREFLOATS) + return wldoc.as_pdf(morefloats=settings.LIBRARIAN_PDF_MOREFLOATS, + cover=True) def build(self, fieldfile): BuildEbook.build(self, fieldfile) clear_cache(fieldfile.instance.slug) +@BuildEbook.register('epub') +@task(ignore_result=True) +class BuildEpub(BuildEbook): + @staticmethod + def transform(wldoc, fieldfile): + return wldoc.as_epub(cover=True) + + @BuildEbook.register('html') @task(ignore_result=True) class BuildHtml(BuildEbook): -- 2.20.1