diff --git a/Aetheria/static/fiction/the-burden-of-proof.epub b/Aetheria/static/fiction/the-burden-of-proof.epub index d4c775a..e21d65f 100644 Binary files a/Aetheria/static/fiction/the-burden-of-proof.epub and b/Aetheria/static/fiction/the-burden-of-proof.epub differ diff --git a/scripts/fiction/build_the_burden_of_proof_epub.py b/scripts/fiction/build_the_burden_of_proof_epub.py index 3635174..cdcb163 100644 --- a/scripts/fiction/build_the_burden_of_proof_epub.py +++ b/scripts/fiction/build_the_burden_of_proof_epub.py @@ -28,27 +28,6 @@ class Chapter: blocks: list[str] -@dataclass -class SpinePage: - chapter_index: int - page_index: int - title: str - movement: str - blocks: list[str] - - @property - def href(self) -> str: - if self.page_index == 1: - return f"text/chapter-{self.chapter_index:02}.xhtml" - return f"text/chapter-{self.chapter_index:02}-p{self.page_index:02}.xhtml" - - @property - def item_id(self) -> str: - if self.page_index == 1: - return f"chapter-{self.chapter_index}" - return f"chapter-{self.chapter_index}-p{self.page_index}" - - def inline_markup(text: str) -> str: placeholders: dict[str, str] = {} @@ -113,40 +92,6 @@ def chapter_xhtml(chapter: Chapter) -> str: return xhtml_page(chapter.title, body, "chapter") -def paginate_chapters(chapters: list[Chapter], target_chars: int = 1400) -> list[SpinePage]: - pages: list[SpinePage] = [] - for chapter_index, chapter in enumerate(chapters, 1): - chunks: list[list[str]] = [] - current: list[str] = [] - current_chars = 0 - for block in chapter.blocks: - block_chars = len(block) - if current and current_chars + block_chars > target_chars: - chunks.append(current) - current = [] - current_chars = 0 - current.append(block) - current_chars += block_chars - if current: - chunks.append(current) - for page_index, blocks in enumerate(chunks, 1): - pages.append(SpinePage(chapter_index, page_index, chapter.title, chapter.movement, blocks)) - return pages - - -def page_xhtml(page: SpinePage) -> str: - paragraphs = [] - for block in page.blocks: - rendered = inline_markup(block) - css_class = " class=\"pov\"" if re.fullmatch(r"[^<]+", rendered) else "" - paragraphs.append(f"{rendered}

") - header = "" - if page.page_index == 1: - header = f'

{html.escape(page.movement)}

{html.escape(page.title)}

' - body = header + "\n".join(paragraphs) - return xhtml_page(page.title, body, "chapter") - - def modified_timestamp(source: Path) -> str: epoch = int(os.environ.get("SOURCE_DATE_EPOCH", source.stat().st_mtime)) return datetime.fromtimestamp(epoch, timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") @@ -154,13 +99,12 @@ def modified_timestamp(source: Path) -> str: def build(source: Path, output: Path) -> None: title, chapters = parse_manuscript(source) - pages = paginate_chapters(chapters) output.parent.mkdir(parents=True, exist_ok=True) chapter_items = "\n".join( - f'' - for page in pages + f'' + for i in range(1, len(chapters) + 1) ) - spine = "\n".join(f'' for page in pages) + spine = "\n".join(f'' for i in range(1, len(chapters) + 1)) nav_points = "\n".join( f'
  • {html.escape(chapter.title)}
  • ' for i, chapter in enumerate(chapters, 1) @@ -191,8 +135,8 @@ def build(source: Path, output: Path) -> None: archive.writestr("EPUB/toc.ncx", ncx) archive.writestr("EPUB/styles/book.css", css) archive.writestr("EPUB/text/title.xhtml", title_page) - for page in pages: - archive.writestr(f"EPUB/{page.href}", page_xhtml(page)) + for i, chapter in enumerate(chapters, 1): + archive.writestr(f"EPUB/text/chapter-{i:02}.xhtml", chapter_xhtml(chapter)) validate(output, len(chapters)) diff --git a/site/quartz.layout.ts b/site/quartz.layout.ts index 7c5e76a..3cf1dae 100644 --- a/site/quartz.layout.ts +++ b/site/quartz.layout.ts @@ -25,19 +25,28 @@ export const defaultContentPageLayout: PageLayout = { showCurrentPage: false, showRoot: false, }), - condition: (page) => page.fileData.slug !== "index", + condition: (page) => page.fileData.slug !== "index" && page.fileData.slug !== "Fiction/The-Burden-of-Proof", }), Component.ConditionalRender({ component: Component.ArticleTitle(), - condition: (page) => !page.fileData.slug?.endsWith("/index") && page.fileData.slug !== "index", + condition: (page) => + !page.fileData.slug?.endsWith("/index") && + page.fileData.slug !== "index" && + page.fileData.slug !== "Fiction/The-Burden-of-Proof", }), Component.ConditionalRender({ component: AetheriaAuthorMeta(), - condition: (page) => !page.fileData.slug?.endsWith("/index") && page.fileData.slug !== "index", + condition: (page) => + !page.fileData.slug?.endsWith("/index") && + page.fileData.slug !== "index" && + page.fileData.slug !== "Fiction/The-Burden-of-Proof", }), Component.ConditionalRender({ component: Component.ContentMeta(), - condition: (page) => !page.fileData.slug?.endsWith("/index") && page.fileData.slug !== "index", + condition: (page) => + !page.fileData.slug?.endsWith("/index") && + page.fileData.slug !== "index" && + page.fileData.slug !== "Fiction/The-Burden-of-Proof", }), Component.ConditionalRender({ component: AetheriaEpubReader(), diff --git a/site/quartz/components/AetheriaEpubReader.tsx b/site/quartz/components/AetheriaEpubReader.tsx index 3fd76b2..77dee16 100644 --- a/site/quartz/components/AetheriaEpubReader.tsx +++ b/site/quartz/components/AetheriaEpubReader.tsx @@ -7,7 +7,7 @@ export default (() => { const AetheriaEpubReader: QuartzComponent = () => (
    @@ -32,7 +32,7 @@ export default (() => {