footer in epub
authorJan Szejko <janek37@gmail.com>
Fri, 9 Dec 2016 16:16:22 +0000 (17:16 +0100)
committerJan Szejko <janek37@gmail.com>
Fri, 9 Dec 2016 16:16:22 +0000 (17:16 +0100)
librarian/formats/epub/__init__.py
librarian/formats/epub/res/chapter.html

index bf21a6f..708b063 100644 (file)
@@ -34,6 +34,9 @@ class EpubFormat(Format):
         if cover is not None:
             self.cover = cover
 
+    def dc(self, tag):
+        return self.doc.meta.get_one(DCNS(tag))
+
     def build(self, ctx=None):
 
         def add_file(url, file_id):
@@ -52,7 +55,7 @@ class EpubFormat(Format):
         guide = opf.find(OPFNS('guide'))
         spine = opf.find(OPFNS('spine'))
 
-        author = ", ". join(self.doc.meta.get(DCNS('creator')) or '')
+        author = ", ". join(self.doc.meta.get(DCNS('creator')) or [])
         title = self.doc.meta.title()
         opf.find('.//' + DCNS('creator')).text = author
         opf.find('.//' + DCNS('title')).text = title
@@ -150,6 +153,31 @@ class EpubFormat(Format):
             zip.writestr('OPS/footnotes.html', etree.tostring(
                                 wrap, method="html", pretty_print=True))
 
+        footer_text = [
+            'Information about the resource',
+            'Publisher: %s' % self.dc('publisher'),
+            'Rights: %s' % self.dc('rights'),
+            'Intended audience: %s' % self.dc('audience'),
+            self.dc('description'),
+            'Resource prepared using MIL/PEER editing platform.',
+            'Source available at %s' % ctx.source_url,
+        ]
+        footer_wrap = deepcopy(wrap_tmpl)
+        footer_body = footer_wrap.find('//*[@id="book-text"]')
+        for line in footer_text:
+            footer_line = etree.Element('p')
+            footer_line.text = line
+            footer_body.append(footer_line)
+        manifest.append(manifest.makeelement(OPFNS('item'), attrib={
+            'id': 'footer',
+            'href': "footer.html",
+            'media-type': 'application/xhtml+xml',
+        }))
+        spine.append(spine.makeelement(OPFNS('itemref'), attrib={
+            'idref': 'footer',
+        }))
+        zip.writestr('OPS/footer.html', etree.tostring(footer_wrap, method='html'))
+
         zip.writestr('OPS/content.opf', etree.tostring(opf, pretty_print=True))
         ctx.toc.render(toc_file[-1])
         zip.writestr('OPS/toc.ncx', etree.tostring(toc_file, pretty_print=True))
index 342d5df..2123756 100644 (file)
@@ -3,7 +3,7 @@
     <head>
         <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"></meta>
         <title>
-          WolneLektury.pl
+          Milpeer.eu
         </title>
     </head>
     <body>