From: Radek Czajka Date: Wed, 22 Aug 2012 11:53:53 +0000 (+0200) Subject: closes #2043: covers in ebooks X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/35e339dba8a99b371714b52523fdbb4b95237f79?ds=inline;hp=-c closes #2043: covers in ebooks --- 35e339dba8a99b371714b52523fdbb4b95237f79 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):