X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/e67fee0ec88f99401f5add011bf801ec10181e37..c7734daf3d6884c358f1644c1f8f7970453fafb1:/src/librarian/builders/epub.py?ds=sidebyside diff --git a/src/librarian/builders/epub.py b/src/librarian/builders/epub.py index 4471e30..8544846 100644 --- a/src/librarian/builders/epub.py +++ b/src/librarian/builders/epub.py @@ -11,8 +11,6 @@ import librarian.epub from librarian.fonts import strip_font - - class Xhtml: def __init__(self): self.element = etree.XML('''WolneLektury.pl''') @@ -29,10 +27,11 @@ class Xhtml: class Builder: file_extension = None - def __init__(self, base_url=None, fundraising=None): + def __init__(self, base_url=None, fundraising=None, cover=None): self._base_url = base_url or 'file:///home/rczajka/for/fnp/librarian/temp~/maly/img/' self.fundraising = fundraising self.footnotes = etree.Element('div', id='footnotes') + self.make_cover = cover or make_cover self.cursors = { # None: None, @@ -60,8 +59,6 @@ class Builder: def forget_fragment(self, name): del self.cursors[name] - - @property def base_url(self): if self._base_url is not None: @@ -78,6 +75,8 @@ class Builder: class EpubBuilder(Builder): file_extension = 'epub' + isbn_field = 'isbn_epub' + orphans = True def __init__(self, *args, **kwargs): self.chars = set() @@ -109,7 +108,6 @@ class EpubBuilder(Builder): self.set_metadata() - self.add_cover() self.add_title_page() @@ -212,10 +210,10 @@ class EpubBuilder(Builder): e = self.document.tree.find('//autor_utworu') if e is not None: - etree.SubElement(tp, 'h2', **{'class': 'author'}).text = e.raw_printable_text() + etree.SubElement(tp, 'h2', **{'class': 'author'}).text = e.raw_printable_text(self) e = self.document.tree.find('//nazwa_utworu') if e is not None: - etree.SubElement(tp, 'h1', **{'class': 'title'}).text = e.raw_printable_text() + etree.SubElement(tp, 'h1', **{'class': 'title'}).text = e.raw_printable_text(self) if not len(tp): for author in self.document.meta.authors: @@ -251,8 +249,8 @@ class EpubBuilder(Builder):

""")) - if self.document.meta.isbn_epub: - etree.SubElement(tp, 'p', **{"class": "info"}).text = self.document.meta.isbn_epub + if getattr(self.document.meta, self.isbn_field): + etree.SubElement(tp, 'p', **{"class": "info"}).text = getattr(self.document.meta, self.isbn_field) tp.append(etree.XML("""