From 2b1738668d3dbaadc32cac178691b87aa71c13bc Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 24 Apr 2025 15:51:12 -0400 Subject: [PATCH] Add CSS styling and HTML templates for Bible browsing interface --- static/style.css | 55 ++++++++++++++++++++++++++++ t.py | 16 +++++++-- templates/base.html | 18 ++++++++++ templates/book.html | 78 +++++++++++++++++++++++++++++++++++----- templates/chapter.html | 82 +++++++++++++++++++++++++++++++++++++----- templates/index.html | 54 +++++++++++++++++++++++----- 6 files changed, 275 insertions(+), 28 deletions(-) create mode 100644 static/style.css create mode 100644 templates/base.html diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..cda0876 --- /dev/null +++ b/static/style.css @@ -0,0 +1,55 @@ +body { + font-family: 'Palatino Linotype', serif; + margin: 0; + padding: 0; + display: flex; + height: 100vh; + background-color: #f6f4ef; +} + +.sidebar { + width: 250px; + background-color: #2e2e2e; + color: white; + overflow-y: auto; + padding: 1rem; + border-right: 1px solid #ccc; +} + +.sidebar h2 { + font-size: 1.2rem; + margin-top: 0; + color: #ccc; +} + +.sidebar a { + display: block; + color: #ddd; + padding: 4px 0; + text-decoration: none; +} + +.sidebar a:hover { + text-decoration: underline; +} + +.main { + flex-grow: 1; + padding: 2rem; + overflow-y: auto; +} + +h1, h2 { + color: #4b2e83; +} + +.verse-block { + margin-bottom: 1.2rem; +} + +.verse-block strong { + display: inline-block; + width: 4rem; + font-weight: normal; + color: #888; +} diff --git a/t.py b/t.py index b687ac2..3e55148 100644 --- a/t.py +++ b/t.py @@ -16,6 +16,7 @@ bible = kjv.Bible() @app.get("/", response_class=HTMLResponse) def read_root(request: Request): books = list(bible.iter_books()) + return templates.TemplateResponse( "index.html", {"request": request, "books": books} ) @@ -23,22 +24,33 @@ def read_root(request: Request): @app.get("/book/{book}", response_class=HTMLResponse) def read_book(request: Request, book: str): + books = list(bible.iter_books()) chapters = [ch for bk, ch in bible.iter_chapters() if bk == book] + if not chapters: raise HTTPException(status_code=404, detail="Book not found") return templates.TemplateResponse( - "book.html", {"request": request, "book": book, "chapters": chapters} + "book.html", + {"request": request, "book": book, "chapters": chapters, "books": books}, ) @app.get("/book/{book}/chapter/{chapter}", response_class=HTMLResponse) def read_chapter(request: Request, book: str, chapter: int): + books = list(bible.iter_books()) verses = [v for v in bible.iter_verses() if v.book == book and v.chapter == chapter] + if not verses: raise HTTPException(status_code=404, detail="Chapter not found") return templates.TemplateResponse( "chapter.html", - {"request": request, "book": book, "chapter": chapter, "verses": verses}, + { + "request": request, + "book": book, + "chapter": chapter, + "verses": verses, + "books": books, + }, ) diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..f55c049 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,18 @@ + + + + {% block title %}Bible Study{% endblock %} + + + + +
+ {% block content %}{% endblock %} +
+ + diff --git a/templates/book.html b/templates/book.html index eb8a474..4a6f90c 100644 --- a/templates/book.html +++ b/templates/book.html @@ -1,15 +1,75 @@ - + - {{ book }} + + {{ book }} – Chapters + + + -

{{ book }}

- - Back to Books +
+
{{ book }}
+
+ {% for chapter in chapters %} + {{ chapter }} + {% endfor %} +
+ +
diff --git a/templates/chapter.html b/templates/chapter.html index c992089..5c6fd48 100644 --- a/templates/chapter.html +++ b/templates/chapter.html @@ -1,16 +1,80 @@ - + - {{ book }} {{ chapter }} + + {{ book }} {{ chapter }} – KJV Bible + + + -

{{ book }} {{ chapter }}

- {% for verse in verses %} -
-

{{ verse.verse }} {{ verse.text }}

- +
+
{{ book }} {{ chapter }}
+ +
+ {% for verse in verses %} +
+ {{ verse.verse }}{{ verse.text }} +
+ {% endfor %}
- {% endfor %} - Back to {{ book }} + + +
diff --git a/templates/index.html b/templates/index.html index 9691a65..73437ad 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,14 +1,52 @@ - + - Bible Browser + + Bible Browser – KJV + + + -

Select a Book

- +
+
📖 Select a Book
+
+ {% for book in books %} + {{ book }} + {% endfor %} +
+