mirror of
https://github.com/kennethreitz/kjvstudy.org.git
synced 2026-06-05 23:00:16 +00:00
Add verse text tooltips to book highlights and fix reference display
- Create get_verse_text() helper function to retrieve actual verse content - Add "text" field to all book highlight entries using verse lookup - Update tooltip display to show actual verse text instead of descriptions - Fix template field references from "text" to "verse_text" for consistency
This commit is contained in:
+34
-23
@@ -13,6 +13,17 @@ from datetime import datetime
|
||||
from .kjv import bible
|
||||
|
||||
|
||||
def get_verse_text(book, chapter, verse):
|
||||
"""Get the actual text of a specific verse"""
|
||||
try:
|
||||
verses = [v for v in bible.iter_verses() if v.book == book and v.chapter == chapter and v.verse == verse]
|
||||
if verses:
|
||||
return verses[0].text
|
||||
return f"{book} {chapter}:{verse} text not found"
|
||||
except:
|
||||
return f"{book} {chapter}:{verse}"
|
||||
|
||||
|
||||
app = FastAPI(
|
||||
title="KJV Study - Bible Commentary Platform",
|
||||
description="Study the King James Bible with AI-powered commentary and insights",
|
||||
@@ -1463,47 +1474,47 @@ def generate_book_highlights(book, chapters):
|
||||
|
||||
if book == "Genesis":
|
||||
highlights = [
|
||||
{"reference": "Genesis 1:1", "description": "The foundational statement of God's creative activity", "url": "/book/Genesis/chapter/1#verse-1"},
|
||||
{"reference": "Genesis 1:26-27", "description": "Creation of humanity in God's image", "url": "/book/Genesis/chapter/1#verse-26"},
|
||||
{"reference": "Genesis 3:15", "description": "First messianic prophecy (the protoevangelium)", "url": "/book/Genesis/chapter/3#verse-15"},
|
||||
{"reference": "Genesis 12:1-3", "description": "God's covenant call and promise to Abraham", "url": "/book/Genesis/chapter/12#verse-1"},
|
||||
{"reference": "Genesis 22:1-18", "description": "Abraham's faith demonstrated in offering Isaac", "url": "/book/Genesis/chapter/22#verse-1"},
|
||||
{"reference": "Genesis 1:1", "description": "The foundational statement of God's creative activity", "url": "/book/Genesis/chapter/1#verse-1", "text": get_verse_text("Genesis", 1, 1)},
|
||||
{"reference": "Genesis 1:26-27", "description": "Creation of humanity in God's image", "url": "/book/Genesis/chapter/1#verse-26", "text": get_verse_text("Genesis", 1, 26)},
|
||||
{"reference": "Genesis 3:15", "description": "First messianic prophecy (the protoevangelium)", "url": "/book/Genesis/chapter/3#verse-15", "text": get_verse_text("Genesis", 3, 15)},
|
||||
{"reference": "Genesis 12:1-3", "description": "God's covenant call and promise to Abraham", "url": "/book/Genesis/chapter/12#verse-1", "text": get_verse_text("Genesis", 12, 1)},
|
||||
{"reference": "Genesis 22:1-18", "description": "Abraham's faith demonstrated in offering Isaac", "url": "/book/Genesis/chapter/22#verse-1", "text": get_verse_text("Genesis", 22, 1)},
|
||||
]
|
||||
elif book == "Exodus":
|
||||
highlights = [
|
||||
{"reference": "Exodus 3:14", "description": "God's self-revelation as 'I AM WHO I AM'", "url": "/book/Exodus/chapter/3#verse-14"},
|
||||
{"reference": "Exodus 12:1-30", "description": "Institution of the Passover", "url": "/book/Exodus/chapter/12#verse-1"},
|
||||
{"reference": "Exodus 14:13-31", "description": "Crossing of the Red Sea", "url": "/book/Exodus/chapter/14#verse-13"},
|
||||
{"reference": "Exodus 20:1-17", "description": "The Ten Commandments", "url": "/book/Exodus/chapter/20#verse-1"},
|
||||
{"reference": "Exodus 25:8", "description": "Command to build the tabernacle", "url": "/book/Exodus/chapter/25#verse-8"},
|
||||
{"reference": "Exodus 34:6-7", "description": "Revelation of God's character and attributes", "url": "/book/Exodus/chapter/34#verse-6"}
|
||||
{"reference": "Exodus 3:14", "description": "God's self-revelation as 'I AM WHO I AM'", "url": "/book/Exodus/chapter/3#verse-14", "text": get_verse_text("Exodus", 3, 14)},
|
||||
{"reference": "Exodus 12:1-30", "description": "Institution of the Passover", "url": "/book/Exodus/chapter/12#verse-1", "text": get_verse_text("Exodus", 12, 1)},
|
||||
{"reference": "Exodus 14:13-31", "description": "Crossing of the Red Sea", "url": "/book/Exodus/chapter/14#verse-13", "text": get_verse_text("Exodus", 14, 13)},
|
||||
{"reference": "Exodus 20:1-17", "description": "The Ten Commandments", "url": "/book/Exodus/chapter/20#verse-1", "text": get_verse_text("Exodus", 20, 1)},
|
||||
{"reference": "Exodus 25:8", "description": "Command to build the tabernacle", "url": "/book/Exodus/chapter/25#verse-8", "text": get_verse_text("Exodus", 25, 8)},
|
||||
{"reference": "Exodus 34:6-7", "description": "Revelation of God's character and attributes", "url": "/book/Exodus/chapter/34#verse-6", "text": get_verse_text("Exodus", 34, 6)}
|
||||
]
|
||||
elif book == "Revelation":
|
||||
highlights = [
|
||||
{"reference": "Revelation 1:8", "description": "God as Alpha and Omega, encompassing all history", "url": "/book/Revelation/chapter/1#verse-8"},
|
||||
{"reference": "Revelation 4-5", "description": "Throne room vision with the Lamb who was slain", "url": "/book/Revelation/chapter/4#verse-1"},
|
||||
{"reference": "Revelation 12", "description": "Cosmic conflict between the woman and the dragon", "url": "/book/Revelation/chapter/12#verse-1"},
|
||||
{"reference": "Revelation 19:11-16", "description": "Christ's return as conquering King", "url": "/book/Revelation/chapter/19#verse-11"},
|
||||
{"reference": "Revelation 20:11-15", "description": "Final judgment at the great white throne", "url": "/book/Revelation/chapter/20#verse-11"},
|
||||
{"reference": "Revelation 21:1-5", "description": "New heaven and new earth with God dwelling with His people", "url": "/book/Revelation/chapter/21#verse-1"}
|
||||
{"reference": "Revelation 1:8", "description": "God as Alpha and Omega, encompassing all history", "url": "/book/Revelation/chapter/1#verse-8", "text": get_verse_text("Revelation", 1, 8)},
|
||||
{"reference": "Revelation 4-5", "description": "Throne room vision with the Lamb who was slain", "url": "/book/Revelation/chapter/4#verse-1", "text": get_verse_text("Revelation", 4, 1)},
|
||||
{"reference": "Revelation 12", "description": "Cosmic conflict between the woman and the dragon", "url": "/book/Revelation/chapter/12#verse-1", "text": get_verse_text("Revelation", 12, 1)},
|
||||
{"reference": "Revelation 19:11-16", "description": "Christ's return as conquering King", "url": "/book/Revelation/chapter/19#verse-11", "text": get_verse_text("Revelation", 19, 11)},
|
||||
{"reference": "Revelation 20:11-15", "description": "Final judgment at the great white throne", "url": "/book/Revelation/chapter/20#verse-11", "text": get_verse_text("Revelation", 20, 11)},
|
||||
{"reference": "Revelation 21:1-5", "description": "New heaven and new earth with God dwelling with His people", "url": "/book/Revelation/chapter/21#verse-1", "text": get_verse_text("Revelation", 21, 1)}
|
||||
]
|
||||
else:
|
||||
# Generate some general highlights based on chapter count
|
||||
chapter_count = len(chapters)
|
||||
if chapter_count > 0:
|
||||
highlights.append({"reference": f"{book} 1:1", "description": "Opening statement establishing key themes", "url": f"/book/{book}/chapter/1#verse-1"})
|
||||
highlights.append({"reference": f"{book} 1:1", "description": "Opening statement establishing key themes", "url": f"/book/{book}/chapter/1#verse-1", "text": get_verse_text(book, 1, 1)})
|
||||
|
||||
if chapter_count > 5:
|
||||
highlights.append({"reference": f"{book} {chapter_count//4}:1", "description": "Important development in the book's message", "url": f"/book/{book}/chapter/{chapter_count//4}#verse-1"})
|
||||
highlights.append({"reference": f"{book} {chapter_count//4}:1", "description": "Important development in the book's message", "url": f"/book/{book}/chapter/{chapter_count//4}#verse-1", "text": get_verse_text(book, chapter_count//4, 1)})
|
||||
|
||||
if chapter_count > 10:
|
||||
highlights.append({"reference": f"{book} {chapter_count//2}:1", "description": "Central teaching or turning point", "url": f"/book/{book}/chapter/{chapter_count//2}#verse-1"})
|
||||
highlights.append({"reference": f"{book} {chapter_count//2}:1", "description": "Central teaching or turning point", "url": f"/book/{book}/chapter/{chapter_count//2}#verse-1", "text": get_verse_text(book, chapter_count//2, 1)})
|
||||
|
||||
if chapter_count > 15:
|
||||
highlights.append({"reference": f"{book} {3*chapter_count//4}:1", "description": "Application of key principles", "url": f"/book/{book}/chapter/{3*chapter_count//4}#verse-1"})
|
||||
highlights.append({"reference": f"{book} {3*chapter_count//4}:1", "description": "Application of key principles", "url": f"/book/{book}/chapter/{3*chapter_count//4}#verse-1", "text": get_verse_text(book, 3*chapter_count//4, 1)})
|
||||
|
||||
if chapter_count > 0:
|
||||
highlights.append({"reference": f"{book} {chapter_count}:1", "description": "Concluding summary or final exhortation", "url": f"/book/{book}/chapter/{chapter_count}#verse-1"})
|
||||
highlights.append({"reference": f"{book} {chapter_count}:1", "description": "Concluding summary or final exhortation", "url": f"/book/{book}/chapter/{chapter_count}#verse-1", "text": get_verse_text(book, chapter_count, 1)})
|
||||
|
||||
return highlights
|
||||
|
||||
@@ -1744,7 +1755,7 @@ def generate_chapter_summaries(book, chapters):
|
||||
key_verses.append({
|
||||
"verse_num": 1,
|
||||
"brief": "Opening verse of the chapter",
|
||||
"text": f"[Text of {book} {ch}:1]",
|
||||
"text": get_verse_text(book, ch, 1),
|
||||
"url": f"/book/{book}/chapter/{ch}#verse-1",
|
||||
"comment": f"This verse begins chapter {ch} and establishes its context and direction."
|
||||
})
|
||||
|
||||
@@ -48,6 +48,22 @@
|
||||
<!-- Styles -->
|
||||
<link href="/static/style.css" rel="stylesheet">
|
||||
|
||||
<!-- Gauges Analytics -->
|
||||
<script type="text/javascript">
|
||||
var _gauges = _gauges || [];
|
||||
(function() {
|
||||
var t = document.createElement('script');
|
||||
t.type = 'text/javascript';
|
||||
t.async = true;
|
||||
t.id = 'gauges-tracker';
|
||||
t.setAttribute('data-site-id', '6834bd650d851064ae28dc13');
|
||||
t.setAttribute('data-track-path', 'https://track.gaug.es/track.gif');
|
||||
t.src = 'https://d2fuc4clr7gvcn.cloudfront.net/track.js';
|
||||
var s = document.getElementsByTagName('script')[0];
|
||||
s.parentNode.insertBefore(t, s);
|
||||
})();
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.testament-divider {
|
||||
border: none;
|
||||
|
||||
@@ -206,7 +206,7 @@
|
||||
<p style="margin: 0; color: white; line-height: 1.5; font-size: 1.2rem;">{{ highlight.description }}</p>
|
||||
<span style="color: rgba(255, 255, 255, 0.7); font-size: 0.9rem; margin-top: 0.5rem; display: block;">Click to read passage →</span>
|
||||
</div>
|
||||
<span class="verse-tooltip">{{ highlight.description }} - Click to read the full passage in context</span>
|
||||
<span class="verse-tooltip">{{ highlight.text|default(highlight.description) }}</span>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
@@ -744,7 +744,7 @@ h1, h2, h3, h4, h5, h6 {
|
||||
{% if item.reference %}
|
||||
(<a href="{{ item.url }}" class="verse-reference">
|
||||
{{ item.reference }}
|
||||
<span class="verse-tooltip">{{ item.text|default("See " + item.reference + " for details") }}</span>
|
||||
<span class="verse-tooltip">{{ item.verse_text|default("See " + item.reference + " for details") }}</span>
|
||||
</a>)
|
||||
{% endif %}
|
||||
|
||||
@@ -756,7 +756,7 @@ h1, h2, h3, h4, h5, h6 {
|
||||
{% if subitem.reference %}
|
||||
(<a href="{{ subitem.url }}" class="verse-reference">
|
||||
{{ subitem.reference }}
|
||||
<span class="verse-tooltip">{{ subitem.text|default("See " + subitem.reference + " for details") }}</span>
|
||||
<span class="verse-tooltip">{{ subitem.verse_text|default("See " + subitem.reference + " for details") }}</span>
|
||||
</a>)
|
||||
{% endif %}
|
||||
</li>
|
||||
@@ -786,7 +786,7 @@ h1, h2, h3, h4, h5, h6 {
|
||||
<li>
|
||||
<a href="{{ ref.url }}" class="verse-reference">
|
||||
{{ ref.reference }}
|
||||
<span class="verse-tooltip">{{ ref.text|default("Cross-reference: " + ref.description) }}</span>
|
||||
<span class="verse-tooltip">{{ ref.verse_text|default("Cross-reference: " + ref.description) }}</span>
|
||||
</a> - {{ ref.description }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
@@ -809,7 +809,7 @@ h1, h2, h3, h4, h5, h6 {
|
||||
<li>
|
||||
<a href="{{ verse.url }}" class="verse-reference">
|
||||
{{ book }} {{ chapter_num }}:{{ verse.verse_num }}
|
||||
<span class="verse-tooltip">{{ verse.text|default("Verse text not available") }}</span>
|
||||
<span class="verse-tooltip">{{ verse.text }}</span>
|
||||
</a> - {{ verse.brief }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
@@ -165,12 +165,72 @@
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
.verse-reference {
|
||||
position: relative;
|
||||
color: var(--primary-color);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.verse-reference:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.verse-tooltip {
|
||||
position: absolute;
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: rgba(0, 0, 0, 0.95);
|
||||
color: white;
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: 6px;
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.4;
|
||||
max-width: 300px;
|
||||
white-space: normal;
|
||||
z-index: 1000;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition: opacity 0.3s ease, visibility 0.3s ease;
|
||||
pointer-events: none;
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
font-family: 'EB Garamond', Georgia, serif;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.verse-tooltip::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
border: 6px solid transparent;
|
||||
border-top-color: rgba(0, 0, 0, 0.95);
|
||||
}
|
||||
|
||||
.verse-reference:hover .verse-tooltip {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.verse-text {
|
||||
font-size: 1.25rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
}
|
||||
</edits>
|
||||
|
||||
<edits>
|
||||
|
||||
<old_text>
|
||||
<li>
|
||||
<a href="{{ ref.url }}" class="verse-reference" style="color: var(--primary-color); text-decoration: none;">
|
||||
{{ ref.text }}
|
||||
<span class="verse-tooltip">{{ ref.verse_text|default("Click to view " + ref.text) }}</span>
|
||||
</a> - {{ ref.context }}
|
||||
</li>
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
@@ -361,7 +421,10 @@
|
||||
<ul style="margin: 0; padding-left: 1.25rem;">
|
||||
{% for ref in commentaries[verse.verse].cross_references %}
|
||||
<li>
|
||||
<a href="{{ ref.url }}" style="color: var(--primary-color); text-decoration: none;">{{ ref.text }}</a> - {{ ref.context }}
|
||||
<a href="{{ ref.url }}" class="verse-reference" style="color: var(--primary-color); text-decoration: none;">
|
||||
{{ ref.text }}
|
||||
<span class="verse-tooltip">{{ ref.verse_text|default("Click to view " + ref.text) }}</span>
|
||||
</a> - {{ ref.context }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user