From 22e9f03a5baf7dd9ef76b88d012575d7f971c7d8 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Fri, 30 May 2025 16:12:00 -0400 Subject: [PATCH] Add Scofield commentary loading for Bible chapters --- kjvstudy_org/server.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/kjvstudy_org/server.py b/kjvstudy_org/server.py index 666c34e..f242e37 100644 --- a/kjvstudy_org/server.py +++ b/kjvstudy_org/server.py @@ -1,4 +1,5 @@ import hashlib +import json import re import random from datetime import datetime @@ -1729,6 +1730,18 @@ def read_chapter(request: Request, book: str, chapter: int): detail=f"Chapter {chapter} of {book} was not found. This book has {len(chapters)} chapters." ) + # Load Scofield commentary data + scofield_commentary = {} + try: + static_dir = Path(__file__).parent / "static" + commentary_path = static_dir / "scofield_commentary.json" + if commentary_path.exists(): + with open(commentary_path, 'r', encoding='utf-8') as f: + scofield_commentary = json.load(f) + except Exception as e: + print(f"Error loading Scofield commentary: {e}") + scofield_commentary = {} + # Generate AI commentary for the chapter commentaries = {} for verse in verses: @@ -1747,8 +1760,9 @@ def read_chapter(request: Request, book: str, chapter: int): "books": books, "chapters": chapters, "commentaries": commentaries, - "chapter_overview": chapter_overview - }, + "chapter_overview": chapter_overview, + "scofield_commentary": scofield_commentary + } )