Group cross-references by description

Cross-references are now organized by their thematic description
instead of being listed individually. This creates a cleaner display:

Before:
Colossians 3:10 — Parallel theme; Ephesians 4:24 — References God;
Genesis 3:22 — References God; Psalms 100:3 — References God...

After:
**References God:** Ephesians 4:24; Genesis 3:22; Psalms 100:3
**Parallel theme:** Colossians 3:10; 2 Corinthians 3:18

Much more readable and scannable!

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-28 16:21:05 -05:00
parent 0618c71b66
commit 46fb97dd97
2 changed files with 23 additions and 10 deletions
+16 -7
View File
@@ -2148,15 +2148,24 @@ def read_chapter(request: Request, book: str, chapter: int):
# Track which words were shown
for study in word_studies:
shown_words.add(study['word'].lower())
# Add cross-references with proper URLs
# Add cross-references with proper URLs, grouped by description
cross_refs = get_cross_references(book, chapter, verse.verse)
commentary['cross_references'] = [
{
# Group cross-references by their description/note
from collections import defaultdict
grouped_refs = defaultdict(list)
for ref in cross_refs:
description = ref['note'] if ref['note'] else 'Related'
url = f"/book/{ref['ref'].rsplit(' ', 1)[0]}/chapter/{ref['ref'].rsplit(' ', 1)[1].split(':')[0]}/verse/{ref['ref'].rsplit(' ', 1)[1].split(':')[1]}" if ' ' in ref['ref'] and ':' in ref['ref'] else '#'
grouped_refs[description].append({
'text': ref['ref'],
'url': f"/book/{ref['ref'].rsplit(' ', 1)[0]}/chapter/{ref['ref'].rsplit(' ', 1)[1].split(':')[0]}/verse/{ref['ref'].rsplit(' ', 1)[1].split(':')[1]}" if ' ' in ref['ref'] and ':' in ref['ref'] else '#',
'context': ref['note']
}
for ref in cross_refs
'url': url
})
# Convert to list of groups for template
commentary['cross_reference_groups'] = [
{'description': desc, 'refs': refs}
for desc, refs in grouped_refs.items()
]
commentaries[verse.verse] = commentary
+7 -3
View File
@@ -266,12 +266,16 @@ hr::before {
<p id="verse-{{ verse.verse }}">
<a href="/book/{{ book }}/chapter/{{ chapter }}/verse/{{ verse.verse }}" class="verse-number-link{% if commentary and commentary['is_enhanced'] == True %} has-commentary{% endif %}">{{ verse.verse }}</a> {{ verse.text | red_letter(book, chapter, verse.verse) | inject_word_markers(commentary.word_studies if commentary else [], verse.verse) | link_names | safe }}
{% if commentary %}
{% if commentary.cross_references %}
{% if commentary.cross_reference_groups %}
<label for="sn-{{ verse.verse }}-xrefs" class="margin-toggle sidenote-number"></label>
<input type="checkbox" id="sn-{{ verse.verse }}-xrefs" class="margin-toggle"/>
<span class="sidenote">
{% for ref in commentary.cross_references %}
<strong><a href="{{ ref.url }}">{{ ref.text }}</a></strong>{% if ref.context %} — {{ ref.context }}{% endif %}{% if not loop.last %}; {% endif %}
{% for group in commentary.cross_reference_groups %}
<strong>{{ group.description }}:</strong>
{% for ref in group.refs %}
<a href="{{ ref.url }}">{{ ref.text }}</a>{% if not loop.last %}; {% endif %}
{% endfor %}
{% if not loop.last %}<br>{% endif %}
{% endfor %}
</span>
{% endif %}