Change VOTD to use date in URL path for bookmarking

- /verse-of-the-day now redirects (302) to /verse-of-the-day/YYYY-MM-DD
- Prevents caching issues since URL changes daily
- Allows bookmarking specific dates
- Archive table dates now link to devotional pages

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-06 14:25:36 -05:00
parent dad8e2d1ce
commit c539e4995a
2 changed files with 19 additions and 17 deletions
+16 -14
View File
@@ -218,22 +218,24 @@ async def random_verse(request: Request):
return response
@router.get("/verse-of-the-day", response_class=HTMLResponse)
async def verse_of_the_day_page(
request: Request,
date: Optional[str] = Query(None, description="Date in YYYY-MM-DD format")
):
"""Verse of the day page with optional date parameter for navigation."""
@router.get("/verse-of-the-day")
async def verse_of_the_day_redirect():
"""Redirect to today's verse of the day (prevents caching, allows bookmarking)."""
today_str = datetime.now().strftime("%Y-%m-%d")
return RedirectResponse(url=f"/verse-of-the-day/{today_str}", status_code=302)
@router.get("/verse-of-the-day/{date}", response_class=HTMLResponse)
async def verse_of_the_day_page(request: Request, date: str):
"""Verse of the day page for a specific date."""
books = bible.get_books()
# Use provided date or default to today
if date:
try:
current_date = datetime.strptime(date, "%Y-%m-%d")
except ValueError:
current_date = datetime.now()
else:
current_date = datetime.now()
# Parse the date
try:
current_date = datetime.strptime(date, "%Y-%m-%d")
except ValueError:
# Invalid date format, redirect to today
return RedirectResponse(url="/verse-of-the-day", status_code=302)
date_str = current_date.strftime("%Y-%m-%d")
daily_verse = get_daily_verse(date_str)
+3 -3
View File
@@ -370,7 +370,7 @@
<tbody>
{% for verse in past_verses %}
<tr>
<td>{{ verse.date }}</td>
<td><a href="/verse-of-the-day/{{ verse.date }}">{{ verse.date }}</a></td>
<td><a href="/book/{{ verse.book }}/chapter/{{ verse.chapter }}/verse/{{ verse.verse }}">{{ verse.reference }}</a></td>
</tr>
{% endfor %}
@@ -461,12 +461,12 @@
} else if (e.key === '[') {
// Previous day
e.preventDefault();
window.location.href = '/verse-of-the-day?date={{ prev_date }}';
window.location.href = '/verse-of-the-day/{{ prev_date }}';
} else if (e.key === ']') {
// Next day (only if not viewing future)
e.preventDefault();
{% if next_date %}
window.location.href = '/verse-of-the-day?date={{ next_date }}';
window.location.href = '/verse-of-the-day/{{ next_date }}';
{% endif %}
} else if (e.key === 't') {
// Jump to today