Commit Graph

587 Commits

Author SHA1 Message Date
kennethreitz 7522b27e7c Implement Phase 2 performance optimizations
1. Replace regex markdown with mistune library
   - Add mistune>=3.0.2 dependency
   - Replace custom regex patterns with proper markdown parser
   - Better performance and more robust parsing
   - Supports full markdown syntax (bold, italic, strikethrough, etc.)

2. Cache story counts
   - Cache get_story_count() and get_category_count()
   - Expected: 10-20x faster story index page loads
   - Added cache invalidation to refresh_stories()

3. Fix O(n) pattern in helpers.py
   - Replace manual chapter filtering with bible.get_chapters_for_book()
   - Uses existing @lru_cache for instant lookups

Combined expected improvement: 10-20% on story pages, faster markdown

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 12:06:13 -05:00
kennethreitz 6c4c23a83e Implement major performance optimizations (Phase 1)
Optimization #2: Replace O(n) verse filtering with cached methods
- Replace manual filtering loops with bible.get_verses_by_book_chapter()
- Replace chapter filtering with bible.get_chapters_for_book()
- 13 replacements in server.py
- Expected: 80-95% faster book/chapter pages after first access

Optimization #3: Build slug index for O(1) resource lookups
- Create pre-built slug indexes for all 38 resource dictionaries
- Replace O(n) linear search with O(1) hash lookup
- Add find_resource_by_slug() function to data module
- Expected: 95% faster resource page lookups

Combined expected improvement: 50-80% overall performance gain

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 12:00:13 -05:00
kennethreitz 2c2726ff01 Optimize books loading by using cached get_books() method
Replace all 26 calls to list(bible.iter_books()) with bible.get_books()
which uses @lru_cache to avoid iterating through 31,102 verses on
every page request.

Expected improvement: 50-70% faster page loads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 11:56:18 -05:00
kennethreitz 954f05f66d Fix async conversion for _resource_index_pdf_response helper
- Make _resource_index_pdf_response async
- Add await to all 35 calls to this helper function
- Fixes second SyntaxError in resources.py PDF generation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 11:49:41 -05:00
kennethreitz ad72a91c03 Fix async PDF helper function syntax error
Make _resource_detail_pdf_response async and add await to all calls.

This fixes the SyntaxError where await was used in a non-async function.
The helper function is called by 38 PDF endpoints and needs to be async
to properly await render_html_to_pdf_async().

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 11:46:33 -05:00
kennethreitz 9ec7885dce Make PDF generation async to prevent event loop blocking
Convert all PDF generation endpoints from synchronous to async to
prevent blocking FastAPI's event loop during CPU-intensive operations.

Changes:
- Add render_html_to_pdf_async() using ThreadPoolExecutor (2 workers)
- Convert all PDF endpoints to async def
- Use await render_html_to_pdf_async() instead of blocking calls
- Keep render_html_to_pdf() for backward compatibility

Performance impact:
- Prevents event loop blocking during PDF generation
- Allows other requests to be processed while PDFs are rendering
- Limits concurrent PDF generation to 2 workers to control CPU usage

Files updated:
- kjvstudy_org/utils/pdf.py (new async implementation)
- kjvstudy_org/server.py (5 PDF endpoints)
- kjvstudy_org/routes/api.py (4 PDF endpoints)
- kjvstudy_org/routes/resources.py (7 PDF endpoints)
- kjvstudy_org/routes/stories.py (2 PDF endpoints)
- kjvstudy_org/routes/study_guides.py (1 PDF endpoint)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 11:44:35 -05:00
kennethreitz 24c11f5f3a Optimize search performance with FTS5 index
Add SQLite FTS5 search index initialization to dramatically improve
search performance from ~2.8s to <100ms.

Changes:
- Build search index at Docker image build time
- Initialize search index on app startup as fallback
- Index enables fast full-text search across all 31,102 verses

Performance impact:
- Before: ~2.8s (O(n) iteration through all verses)
- After: <100ms (FTS5 indexed search)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 11:20:15 -05:00
kennethreitz d009163bd0 Update books.py filename map for Solomon's Song
Update _BOOK_FILENAME_MAP to use "Solomon's Song" as the key and
point to the renamed file "solomons_song.json".

This fixes the book data loading issue where get_book_data() couldn't
find the book introduction, themes, and other metadata, causing the
page to fall back to generic auto-generated content.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 11:15:30 -05:00
kennethreitz c153f61bdb Update commentary.py to use "Solomon's Song" book name
Replace all "Song of Solomon" references with "Solomon's Song" in
commentary route dictionaries to match the updated book naming.

This fixes the "Major Themes" display issue where dictionary lookups
were failing because the book is now named "Solomon's Song" throughout
the codebase but commentary.py still used "Song of Solomon" as keys.

Changes:
- Updated 9 dictionary entries across multiple functions
- Functions affected: genre, time_period, historical_context, tags,
  word studies, and OT book list

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 09:31:22 -05:00
kennethreitz 7d1f7a65ee Align Song of Solomon book data with verses file naming
Rename book data file and update all references to use "Solomon's Song"
(matching verses-1769.json) instead of "Song of Solomon".

Changes:
- Rename song_of_solomon.json → solomons_song.json
- Update "name" field: "Song of Solomon" → "Solomon's Song"
- Update all verse references to use "Solomon's Song X:Y" format

This ensures the book data name matches the verses file exactly,
eliminating the need for normalization redirects.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 09:27:26 -05:00
kennethreitz 9def1c4ce9 Fix Song of Solomon book name mapping (reverse direction)
Correct the book name normalization to map FROM "Song of Solomon"
TO "Solomon's Song" (the name used in verses-1769.json).

Changes:
- Reverse all Song mappings to point to "Solomon's Song"
- Update OT_BOOKS to use "Solomon's Song" (matching verses file)
- Map "Song of Solomon", "Song of Songs", and "Canticles" → "Solomon's Song"

This fixes the 404 error on /book/Song%20of%20Solomon by ensuring
that alternative names redirect to the canonical verses file name.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 09:25:52 -05:00
kennethreitz 5f52497a43 Fix Song of Solomon book name routing
Add "Solomon's Song" to BOOK_ABBREVIATIONS mapping to fix URL
routing. The KJV verses file (verses-1769.json) uses "Solomon's Song"
as the book name, but the book data uses "Song of Solomon". This
mapping ensures normalize_book_name() correctly handles the variant.

Fixes URL: https://kjvstudy.org/book/Solomon's%20Song

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 09:23:05 -05:00
kennethreitz f2a079f4b8 Replace Song of Solomon content with new comprehensive version
Updated all sections of the Song of Solomon book data:

- Introduction: Revised to emphasize the Song's unique place in Scripture,
  Hebrew superlative title, dialogue structure, and dual literal/typological
  interpretation following Reformed approach

- Key Themes: Replaced 8 themes with 7 focused themes including goodness of
  marital desire, exclusive devotion, love strong as death, beauty of the
  beloved, seeking and finding, the garden enclosed, and Christ/church typology

- Key Verses: Simplified to 7 core verses with reference and text only

- Outline: Updated to 6 sections tracking the Song's movement from longing
  through consummation to the seal of love

- Historical Context: Expanded on Solomonic era and wisdom literature context

- Literary Style: Enhanced treatment of lyric poetry, wasf genre, imagery,
  and Hebrew linguistic complexity

- Theological Significance: Four-paragraph treatment of creation goodness,
  marital love, bride metaphor, and love's cosmic significance

- Christ in Book: Six-paragraph typological reading showing bridegroom seeking
  bride, delighting in beauty, mutual possession, garden restoration, and
  love conquering death

- Relationship to NT: Four-paragraph treatment of Ephesians 5, Revelation's
  marriage imagery, Jesus as bridegroom, and NT sexual ethics

- Practical Application: Five-paragraph treatment for married couples, singles,
  spiritual dryness, non-transactional love, and meditation on Christ's love

All content maintains theological depth while being more accessible and
clearly structured for the website.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 09:14:33 -05:00
kennethreitz 3841fecba6 Expand book introductions for Titus, 2 Timothy, Zechariah, and Philemon
All four books now have comprehensive 2,000+ character introductions:

- Titus (890 → 2,800+ chars): Expanded to cover Cretan culture, Pastoral
  Epistles context, dual emphasis on doctrine and good works, gospel
  counterculture theme, and detailed letter structure

- 2 Timothy (898 → 3,400+ chars): Expanded to emphasize final testament
  nature, contrast between imprisonments, passing the torch theme, guarding
  the gospel deposit, Scripture's inspiration, and finishing well

- Zechariah (1,029 → 3,800+ chars): Expanded to cover post-exilic context,
  eight night visions, messianic prophecies (humble king, pierced one),
  two-part structure (chs 1-8 vs 9-14), and extensive NT quotations

- Philemon (1,090 → 3,600+ chars): Expanded to cover slavery in Roman
  context, gospel doctrines (substitution, imputation, reconciliation),
  Paul's pastoral diplomacy, gospel undermining slavery from within

All introductions now match the depth and comprehensiveness of other
major books (Genesis, Romans, John, Song of Solomon, etc.)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 09:03:52 -05:00
kennethreitz 27c59ccd2f Fix italic markdown rendering in resource pages
- Add mdi (markdown inline) filter to resource_index.html template
  to properly render *italic* and **bold** markdown syntax
- Italicize transliterated Hebrew/Greek terms in spirits-and-demons content
- Ensures foreign language terms display with proper emphasis

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 08:52:19 -05:00
kennethreitz f4df5b88fe Fix JSON syntax errors in spirits and demons descriptions
Fixed two issues:
- Replaced unescaped straight double quotes with single quotes in "I wills"
- Fixed typo: "cunningbut" → "cunning but"

JSON now validates correctly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 22:46:29 -05:00
kennethreitz 14bacc552a Expand spirits and demons page with multi-paragraph prose
Significantly expand 10 key theological sections with comprehensive,
multi-paragraph descriptions:

Major expansions:
- Demons Are Real: 4 paragraphs on reality of spiritual beings
- Origin of Demons: 4 paragraphs on fallen angels
- Demonic Hierarchy: 4 paragraphs on organized evil
- Names of Satan: 4 paragraphs on devil's titles and meanings
- Satan's Fall: 4 paragraphs on pride and rebellion
- Satan's Limitations: 4 paragraphs on defeated foe under God's sovereignty
- Binding the Strong Man: 4 paragraphs on plundering Satan's kingdom
- The Armor of God: 4 paragraphs on spiritual warfare equipment
- Demonic Deception: 4 paragraphs on wolves in sheep's clothing
- The Lake of Fire: 4 paragraphs on everlasting punishment

Each section now includes:
- Deeper theological exposition
- More biblical cross-references and connections
- Practical applications for believers
- Original language insights where relevant
- Historical and eschatological context

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 22:33:00 -05:00
kennethreitz 5a9fddd3e7 Remove 'Reformed' reference from Jeremiah book summary
Replace "Reformed understanding" with direct teaching statement:
- "This anticipates the Reformed understanding that even repentance is God's gift"
- → "This teaches that even repentance is God's gift"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 21:43:45 -05:00
kennethreitz d77c45f7b7 Remove remaining 'Reformed' references from systematic theology resources
Replace 5 additional instances that used "Reformed tradition," "Reformed faith,"
and "Reformed worship":

- Bibliology introduction: "The Reformed tradition holds" → "Scripture is"
- Divine Existence: "The Reformed faith confesses" → direct statement
- Middle Knowledge Rejected: "The Reformed tradition rejects" → passive voice
- Regulative Principle: "The Reformed tradition holds" → direct statement
- Word and Sacrament: "Reformed worship" → "biblical worship"

Note: "reformed governments" on line 1563 uses "reformed" as a verb
(meaning "changed"), not as theological terminology, so it remains unchanged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 21:40:53 -05:00
kennethreitz 0956c3776f Remove explicit 'Reformed theology' references from systematic theology resources
Replace all 12 instances of "Reformed theology" with alternative phrasing that
preserves the theological substance while removing the explicit label:

- Introduction sections: Use "Scripture teaches/emphasizes"
- Verbal Plenary Inspiration: "Historic Christian orthodoxy confesses"
- Scripture and Tradition: Remove attribution, state doctrine directly
- Compatibilism: "Scripture affirms"
- Cessation Question: State position directly
- No Sinless Perfection: "Scripture uniformly rejects"
- Simul Justus et Peccator: "This biblical truth"

Also includes previously staged template changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 21:39:31 -05:00
kennethreitz 64b63a5b8d Add systematic theology resources and update server routes
- Introduced new routes for systematic theology topics including Bibliology, Theology Proper, Anthropology, Hamartiology, Providence, Grace, Justification, Sanctification, Law and Gospel, and Worship.
- Each topic includes HTML and PDF endpoints for resource index and detail pages.
- Updated the resources page to include descriptions and counts for the new theology topics.
2025-11-26 21:08:50 -05:00
kennethreitz 2d3bb2245b Add family tree autocomplete and verse text 2025-11-26 20:02:07 -05:00
kennethreitz bda0c8291e Remove parenting resource card 2025-11-26 19:46:07 -05:00
kennethreitz f2102a3992 Tidy stories index TOC layout 2025-11-26 19:42:49 -05:00
kennethreitz 9303f1b78c updates to book summaries 2025-11-26 19:14:26 -05:00
kennethreitz 008a838ec2 Make homepage study cards fully clickable 2025-11-26 18:56:36 -05:00
kennethreitz 22f934beeb Support cross-chapter verse linking on book pages 2025-11-26 18:47:08 -05:00
kennethreitz 621df3ae9d Remove duplicate chapter refs in Malachi outline 2025-11-26 17:14:30 -05:00
kennethreitz a27c0c639f Deepen Malachi introduction 2025-11-26 17:12:57 -05:00
kennethreitz 13a1bb2365 Expand data entries for key pastoral/minor prophet books 2025-11-26 17:10:32 -05:00
kennethreitz f6cb14ab71 Fix Hosea & Jonah data json formatting 2025-11-26 17:00:01 -05:00
kennethreitz e16819f970 Move study guide pdf download to detail pages 2025-11-26 16:54:41 -05:00
kennethreitz f7d871607e Expand Haggai with comprehensive study content
Add extensive theological analysis, key themes, verses with significance,
and practical applications for in-depth Bible study.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 16:12:43 -05:00
kennethreitz 2fcc5932a3 updates to book summaries 2025-11-26 16:10:59 -05:00
kennethreitz 2483e57c98 updates to book summaries 2025-11-26 16:09:39 -05:00
kennethreitz c09019adee Add book introduction content to PDF exports
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 <noreply@anthropic.com>
2025-11-26 16:08:28 -05:00
kennethreitz a596d5bc47 Apply inline markdown filter to Book Outline descriptions
Complete markdown rendering coverage for all book sections.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 16:06:23 -05:00
kennethreitz 14e5536d3d Apply inline markdown filter to Key Verses section
Add markdown rendering to verse text and significance fields
to properly display bold and italic formatting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 16:04:50 -05:00
kennethreitz 08a7b8dc36 Add inline markdown filter for Key Themes descriptions
Create new 'mdi' filter for inline markdown (bold/italic only)
without paragraph wrapping. Apply to Key Themes descriptions
to properly render markdown formatting within list items.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 16:04:03 -05:00
kennethreitz cbaa498dba Add italic text support to markdown filter
Update markdown filter to convert *italic* to <em>italic</em>
in addition to existing **bold** support. Processes bold first
to avoid conflicts with italic markers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 16:02:39 -05:00
kennethreitz d25db83ea0 Fix markdown rendering in Introduction and Historical Context sections
Apply markdown filter to Introduction and Historical Context sections
to properly render bold text and other markdown formatting.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 16:00:47 -05:00
kennethreitz 9388c8733c Fix markdown rendering in book Literary Style section
Apply markdown filter to Literary Style section to properly render
bold text and other markdown formatting. Makes it consistent with
other sections like Theological Significance.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 16:00:01 -05:00
kennethreitz d15d2309e8 Add 10 new Bible story collections and reorganize in chronological order
Add comprehensive story files for missing Bible narratives:
- Job's Suffering (7 stories)
- Samson's Strength (5 stories)
- Ruth & Redemption (4 stories)
- Samuel the Prophet (8 stories)
- Jonah & God's Mercy (4 stories)
- Daniel & Friends (6 stories)
- Esther & Deliverance (5 stories)
- Nehemiah Rebuilds (7 stories)
- Paul's Missions (5 stories)
- Revelation & Hope (10 stories)

Reorganize all story files in biblical chronological order:
- Old Testament stories: 01-15 (Creation through Nehemiah)
- New Testament stories: 16-23 (Jesus Birth through Revelation)
- Thematic collection: 24 (Heroes of Faith)

Each story includes comprehensive adult narratives (400-600 words) and
engaging kids narratives (200-400 words), with proper themes, verses,
and character lists. All content is theologically rich and biblically
faithful.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 15:41:10 -05:00
kennethreitz 855565997d Fix large font on chapter links in other sections
Scope the 1.8rem font-size rule to only the .chapters-section
so parenthetical chapter references in other sections don't
get enlarged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 15:14:55 -05:00
kennethreitz 8402e3d948 Fix markdown filter to always wrap content in p tags
Previously single-paragraph content was returned unwrapped,
causing missing paragraph styling on sections like "Christ in Acts".

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 15:12:19 -05:00
kennethreitz 9388de679f Add support for cross-book chapter references without verses
Handle patterns like "Hebrews 5-7" (chapter range) and "Hebrews 11"
(single chapter) that don't include verse numbers (no colon).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 15:10:07 -05:00
kennethreitz 49fb98c3ee Fix single verse links to use /verse/ path for tooltip support
Single verses now use /book/{book}/chapter/{ch}/verse/{v} format
which matches the tooltip parser pattern in base.html.
Verse ranges continue to use #verse-{start}-{end} anchor format.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 15:09:00 -05:00
kennethreitz 3ae1182266 Fix cross-book verse range inheritance in parentheticals
Track both currentBook and currentChapter context so abbreviated
ranges like "45-49" in "(1 Corinthians 15:21-22, 45-49)" correctly
inherit the book (1 Corinthians) and chapter (15) from the preceding
reference.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 15:06:56 -05:00
kennethreitz 9aca368cb2 Improve verse reference linking to handle complex patterns
- Add cross-book reference support (e.g., Romans 5:12-21)
- Handle comma-separated verse ranges with inherited chapter context
  (e.g., 27:27-29, 39-40 where 39-40 inherits chapter 27)
- Support semicolon-separated references (e.g., 48:15-16; 49:1-27)
- Fix verse range linking to use #verse-start-end anchor format

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 15:05:22 -05:00
kennethreitz cd2f83d9c1 Expand Pentateuch book introductions with rich theological content
- Genesis, Exodus, Leviticus, Numbers, Deuteronomy fully expanded
- Each book now includes: multi-paragraph introductions, key themes with
  descriptions, key verses with significance, detailed outlines, historical
  context, literary style, theological significance, Christ in book,
  relationship to NT, and practical application
- Update book.html template to handle new data structure
- Add markdown filter for bold text conversion
- Template now supports both old and new data formats

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 14:41:35 -05:00