Add Tetragrammaton PDF export

This commit is contained in:
2025-11-26 01:43:55 -05:00
parent 776e39370e
commit 03fa79833c
3 changed files with 159 additions and 0 deletions
+20
View File
@@ -786,6 +786,7 @@ def tetragrammaton_page(request: Request):
{
"books": get_books(),
"content": TETRAGRAMMATON_CONTENT,
"pdf_available": WEASYPRINT_AVAILABLE,
"breadcrumbs": [
{"text": "Home", "url": "/"},
{"text": "Resources", "url": "/resources"},
@@ -795,6 +796,25 @@ def tetragrammaton_page(request: Request):
)
@router.get("/tetragrammaton/pdf")
def tetragrammaton_pdf():
"""PDF export for the Tetragrammaton page."""
if not WEASYPRINT_AVAILABLE:
raise HTTPException(
status_code=503,
detail="PDF generation is not available. WeasyPrint system libraries are not installed."
)
html_content = templates.get_template("tetragrammaton_pdf.html").render(content=TETRAGRAMMATON_CONTENT)
pdf_buffer = render_html_to_pdf(html_content)
return StreamingResponse(
pdf_buffer,
media_type="application/pdf",
headers={"Content-Disposition": "attachment; filename=tetragrammaton.pdf"}
)
# ============================================================================
# MIRACLES OF JESUS
# ============================================================================
@@ -45,6 +45,35 @@
padding-left: 1.5rem;
font-size: 0.95rem;
}
.tetragrammaton-actions {
margin: 1rem 0 1.5rem;
}
.tetragrammaton-download-btn {
display: inline-flex;
align-items: center;
gap: 0.35rem;
padding: 0.35rem 0.75rem;
font-size: 0.85rem;
color: var(--text-secondary, #666);
background: var(--code-bg, #f8f8f8);
border: 1px solid var(--border-color, #ddd);
border-radius: 4px;
text-decoration: none;
transition: all 0.2s;
}
.tetragrammaton-download-btn:hover {
background: var(--bg-color, #fff);
border-color: var(--link-color);
color: var(--link-color);
}
.tetragrammaton-download-btn svg {
width: 14px;
height: 14px;
}
</style>
{% endblock %}
@@ -52,6 +81,17 @@
<h1>{{ content.title }}</h1>
<p class="subtitle">{{ content.subtitle }}</p>
{% if pdf_available %}
<div class="tetragrammaton-actions">
<a class="tetragrammaton-download-btn" href="/tetragrammaton/pdf">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
Download Study (PDF)
</a>
</div>
{% endif %}
<nav class="toc" id="toc">
<h2>Contents</h2>
<ul id="toc-list"></ul>
@@ -0,0 +1,99 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ content.title }}</title>
<style>
@page {
size: letter;
margin: 0.85in;
@bottom-center {
content: counter(page);
font-family: "et-book", Georgia, serif;
font-size: 10pt;
color: #666;
}
}
body {
font-family: "et-book", Georgia, "Times New Roman", serif;
font-size: 11pt;
line-height: 1.6;
color: #111;
}
h1 {
font-size: 24pt;
font-weight: normal;
margin: 0 0 0.2in 0;
}
h2 {
font-size: 16pt;
font-weight: normal;
margin-top: 0.35in;
}
.subtitle {
font-style: italic;
color: #666;
margin-bottom: 0.3in;
}
.section-content {
margin-bottom: 0.2in;
}
.verse-block {
margin: 0.15in 0;
padding-left: 0.25in;
border-left: 2px solid #ddd;
}
.verse-ref {
font-weight: 600;
color: #444;
}
.verse-text {
font-style: italic;
color: #555;
}
.footer {
margin-top: 0.4in;
font-size: 9pt;
color: #888;
text-align: center;
}
</style>
</head>
<body>
<h1>{{ content.title }}</h1>
<p class="subtitle">{{ content.subtitle }}</p>
<div class="section-content">{{ content.introduction | safe }}</div>
{% for section in content.sections %}
<section>
<h2>{{ section.heading }}</h2>
<div class="section-content">{{ section.content | safe }}</div>
{% if section.verses %}
{% for verse in section.verses %}
<div class="verse-block">
<div class="verse-ref">{{ verse.reference }}</div>
<div class="verse-text">{{ verse.text }}</div>
</div>
{% endfor %}
{% endif %}
</section>
{% endfor %}
<section>
<h2>Conclusion</h2>
<div class="section-content">{{ content.conclusion | safe }}</div>
</section>
<div class="footer">From KJV Study &bull; kjvstudy.org</div>
</body>
</html>