X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/db91f942ce46e3af1420f3469a83257ef5aca4c2..c7734daf3d6884c358f1644c1f8f7970453fafb1:/src/librarian/builders/epub.py diff --git a/src/librarian/builders/epub.py b/src/librarian/builders/epub.py index 91405c3..8544846 100644 --- a/src/librarian/builders/epub.py +++ b/src/librarian/builders/epub.py @@ -9,9 +9,6 @@ from librarian.cover import make_cover from librarian.embeds.mathml import MathML import librarian.epub from librarian.fonts import strip_font -from librarian.fundraising import FUNDRAISING - - class Xhtml: @@ -30,9 +27,11 @@ class Xhtml: class Builder: file_extension = None - def __init__(self, base_url=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() @@ -140,21 +138,21 @@ class EpubBuilder(Builder): self.add_support_page() self.add_last_page() + if self.fundraising: + e = len(self.output.spine) - 3 - 3 + nfunds = len(self.fundraising) + if e > 4 * nfunds: + nfunds *= 2 - e = len(self.output.spine) - 3 - 3 - nfunds = len(FUNDRAISING) - if e > 16: - nfunds *= 2 - - # COUNTING CHARACTERS? - for f in range(nfunds): - spine_index = int(4 + (f / nfunds * e) + f) + # COUNTING CHARACTERS? + for f in range(nfunds): + spine_index = int(4 + (f / nfunds * e) + f) - h = Xhtml() - h.body.append( - etree.XML('