closes #2043: covers in ebooks
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Wed, 22 Aug 2012 11:53:53 +0000 (13:53 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Wed, 22 Aug 2012 11:53:53 +0000 (13:53 +0200)
apps/catalogue/constants.py
apps/catalogue/fields.py

index 1ad0b1b..e2181af 100644 (file)
@@ -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
index 0e02ff9..68aaa40 100644 (file)
@@ -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):