From c09019adee398a25e2b7254a73047b33b8b6f1e1 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 26 Nov 2025 16:08:28 -0500 Subject: [PATCH] Add book introduction content to PDF exports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Include all book page sections (introduction, outline, themes, key verses, historical context, literary style, theological significance, Christ in book, NT relationship, and practical application) at the beginning of book PDF exports before the chapter text. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- kjvstudy_org/server.py | 4 + kjvstudy_org/templates/book_pdf.html | 147 ++++++++++++++++++++++++++- 2 files changed, 150 insertions(+), 1 deletion(-) diff --git a/kjvstudy_org/server.py b/kjvstudy_org/server.py index e05370e..7b9ac48 100644 --- a/kjvstudy_org/server.py +++ b/kjvstudy_org/server.py @@ -2236,11 +2236,15 @@ def book_pdf(request: Request, book: str): detail=f"No verses found for the book '{book}'." ) + # Get book introduction data if available + book_intro = get_book_data(book) if has_book_data(book) else None + html_content = templates.get_template("book_pdf.html").render( book=book, chapters=chapters_data, chapter_count=len(chapters_data), verse_count=total_verses, + book_intro=book_intro, ) pdf_buffer = render_html_to_pdf(html_content) diff --git a/kjvstudy_org/templates/book_pdf.html b/kjvstudy_org/templates/book_pdf.html index 690101c..f078995 100644 --- a/kjvstudy_org/templates/book_pdf.html +++ b/kjvstudy_org/templates/book_pdf.html @@ -84,12 +84,157 @@ color: #888; text-align: center; } + + /* Introduction sections */ + .intro-section { + margin-bottom: 0.3in; + page-break-inside: avoid; + } + + .intro-section h2 { + font-size: 14pt; + margin: 0.2in 0 0.1in 0; + font-weight: normal; + } + + .intro-section p { + margin: 0 0 0.12in 0; + text-align: justify; + } + + .intro-section ul { + margin: 0.1in 0; + padding-left: 0.25in; + } + + .intro-section li { + margin-bottom: 0.08in; + } + + .intro-section blockquote { + margin: 0.15in 0.2in; + padding-left: 0.15in; + border-left: 2px solid #ddd; + } + + .intro-section blockquote p { + font-style: italic; + margin-bottom: 0.05in; + } + + .intro-section blockquote footer { + font-size: 9pt; + color: #666; + } + + .chapters-divider { + margin: 0.4in 0; + border-bottom: 2px solid #333; + page-break-before: always; + }

{{ book }}

Authorized King James Version (KJV)

-

{{ chapter_count }} chapters · {{ verse_count }} verses

+

+ {% if book_intro and book_intro.author %}Author: {{ book_intro.author }}{% endif %} + {% if book_intro and book_intro.date_written %} · Written: {{ book_intro.date_written }}{% endif %} + {% if book_intro and book_intro.category %} · Category: {{ book_intro.category }}{% endif %} +

+ + {% if book_intro %} + + {% if book_intro.introduction %} +
+

Introduction

+ {{ book_intro.introduction|md|safe }} +
+ {% endif %} + + {% if book_intro.outline %} +
+

Book Outline

+
    + {% for item in book_intro.outline %} +
  • {{ item.section }} ({{ item.chapters }}) — {{ item.description|mdi|safe }}
  • + {% endfor %} +
+
+ {% endif %} + + {% if book_intro.key_themes %} +
+

Key Themes

+
    + {% for theme in book_intro.key_themes %} + {% if theme is mapping %} +
  • {{ theme.theme }}: {{ theme.description|mdi|safe }}
  • + {% else %} +
  • {{ theme }}
  • + {% endif %} + {% endfor %} +
+
+ {% endif %} + + {% if book_intro.key_verses %} +
+

Key Verses

+ {% for verse in book_intro.key_verses %} +
+

{{ verse.text|mdi|safe }}

+
— {{ verse.reference }}{% if verse.significance %} ({{ verse.significance|mdi|safe }}){% endif %}
+
+ {% endfor %} +
+ {% endif %} + + {% if book_intro.historical_context %} +
+

Historical Context

+ {{ book_intro.historical_context|md|safe }} +
+ {% endif %} + + {% if book_intro.literary_style %} +
+

Literary Style

+ {{ book_intro.literary_style|md|safe }} +
+ {% endif %} + + {% if book_intro.theological_significance %} +
+

Theological Significance

+ {{ book_intro.theological_significance|md|safe }} +
+ {% endif %} + + {% if book_intro.christ_in_book %} +
+

Christ in {{ book }}

+ {{ book_intro.christ_in_book|md|safe }} +
+ {% endif %} + + {% if book_intro.relationship_to_new_testament %} +
+

Relationship to the New Testament

+ {{ book_intro.relationship_to_new_testament|md|safe }} +
+ {% endif %} + + {% if book_intro.practical_application %} +
+

Practical Application

+ {{ book_intro.practical_application|md|safe }} +
+ {% endif %} + + +
+ {% endif %} {% for chapter in chapters %}