Browse Source

Dynamic cover image

pull/7/head
Michel Roux 4 months ago
parent
commit
2bcdc024f1
  1. 2
      pypub/epub.py
  2. 2
      pypub/templates/coverpage.xhtml.xml.j2

2
pypub/epub.py

@ -134,7 +134,6 @@ class Epub:
log.info('epub=%r, generating static content' % self.title)
copy_file('static/mimetype', self.EPUB_DIR)
copy_file('static/container.xml', self.META_INF_DIR)
copy_file('static/coverpage.xhtml', self.OEBPS_DIR)
copy_file('static/css/coverpage.css', self.STYLE_DIR)
copy_file('static/css/styles.css', self.STYLE_DIR)
# get vars and start writing chapters
@ -167,6 +166,7 @@ class Epub:
render_template('templates/book.ncx.xml.j2', self.OEBPS_DIR, epub_vars)
render_template('templates/book.opf.xml.j2', self.OEBPS_DIR, epub_vars)
render_template('templates/toc.xhtml.xml.j2', self.OEBPS_DIR, epub_vars)
render_template('templates/coverpage.xhtml.xml.j2', self.OEBPS_DIR, epub_vars)
def create_epub(self, output_dir: str = '.', fname: Optional[str] = None):
"""

2
pypub/static/coverpage.xhtml → pypub/templates/coverpage.xhtml.xml.j2

@ -9,7 +9,7 @@
</head>
<body>
<div>
<img src="images/cover.png" alt="Cover image" style="width: 100%;height: 100%"/>
<img src="images/{{ cover_img }}" alt="Cover image" style="width: 100%;height: 100%"/>
</div>
</body>
</html>
Loading…
Cancel
Save