Add random verse feature with keyboard shortcut

New random verse functionality:
- /random-verse route randomly selects a Bible verse
- Picks random book, chapter, and verse
- Redirects to the selected verse page
- Enables serendipitous Scripture discovery

Navigation integration:
- Added "Random Verse" link to sidebar navigation
- Placed between "Verse of the Day" and "Reading Plans"

Keyboard shortcut:
- Press 'r' anywhere on site to jump to random verse
- Added to keyboard shortcuts help (press '?')

This feature encourages exploration and discovery of
less-familiar Scripture passages. Each visit provides
a new, randomly selected verse from anywhere in the
66 books of the Bible.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-20 19:15:18 -05:00
parent 68e9d9bc9b
commit 29ce154387
2 changed files with 33 additions and 0 deletions
+25
View File
@@ -851,6 +851,31 @@ def study_guide_detail(request: Request, slug: str):
}
)
@app.get("/random-verse", response_class=HTMLResponse)
def random_verse(request: Request):
"""Redirect to a random Bible verse"""
# Get all books
all_books = list(bible.iter_books())
# Pick a random book
book = random.choice(all_books)
# Get all chapters for this book
chapters = [ch for bk, ch in bible.iter_chapters() if bk == book]
# Pick a random chapter
chapter = random.choice(chapters)
# Get all verses for this chapter
verses = list(bible.iter_verses(book, chapter))
# Pick a random verse
verse = random.choice(verses)
# Redirect to the verse page
return RedirectResponse(url=f"/book/{book}/chapter/{chapter}/verse/{verse.verse}")
@app.get("/verse-of-the-day", response_class=HTMLResponse)
def verse_of_the_day_page(request: Request):
"""Verse of the day page"""
+8
View File
@@ -726,6 +726,7 @@
<li><a href="/" {% if request.url.path == "/" %}class="current"{% endif %}>Home</a></li>
<li><a href="/books">Books</a></li>
<li><a href="/verse-of-the-day">Verse of the Day</a></li>
<li><a href="/random-verse">Random Verse</a></li>
<li><a href="/reading-plans">Reading Plans</a></li>
<li><a href="/topics">Topics</a></li>
<li><a href="/search">Search</a></li>
@@ -814,6 +815,12 @@
showVerseLookup();
}
// r: Random verse
if (e.key === 'r') {
e.preventDefault();
window.location.href = '/random-verse';
}
// ?: Show keyboard shortcuts help
if (e.key === '?' && !e.shiftKey) {
showKeyboardHelp();
@@ -859,6 +866,7 @@
function showKeyboardHelp() {
var helpText = 'Keyboard Shortcuts:\\n\\n' +
'g - Quick verse lookup\\n' +
'r - Random verse\\n' +
'Cmd/Ctrl + D - Toggle dark mode\\n' +
'Cmd/Ctrl + B - Toggle sidebar\\n' +
'Cmd/Ctrl + K - Go to search\\n' +