mirror of
https://github.com/kennethreitz/kjvstudy.org.git
synced 2026-06-05 23:00:16 +00:00
Show first 3 cross-refs collapsed, expand for more
Cross-references now show first 3 refs by default with "+N" indicator. Clicking expands to show all references. Simplifies the template by flattening grouped refs into a single list. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -255,13 +255,13 @@ async def read_chapter(request: Request, book: str, chapter: int):
|
||||
|
||||
commentaries[verse.verse] = commentary
|
||||
|
||||
# Cross-refs: always expanded (word studies are handled per-study above)
|
||||
# Cross-refs: collapsed by default, shows first 3 refs with "+N" to expand
|
||||
for verse_num in [v.verse for v in verses]:
|
||||
commentary = commentaries.get(verse_num)
|
||||
if not commentary:
|
||||
continue
|
||||
if commentary.get('cross_reference_groups'):
|
||||
commentary['xref_auto_expand'] = True
|
||||
commentary['xref_auto_expand'] = False
|
||||
|
||||
# Generate chapter overview
|
||||
chapter_overview = generate_chapter_overview(book, chapter, verses)
|
||||
|
||||
@@ -464,12 +464,19 @@ document.body.dataset.resourceReader = 'false';
|
||||
<a href="/book/{{ book }}/chapter/{{ chapter }}/verse/{{ verse.verse }}" class="verse-number-link{% if has_commentary %} 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, commentary.word_study_auto_expand if commentary else false) | link_names | safe }}
|
||||
{% if commentary %}
|
||||
{% if commentary.cross_reference_groups %}
|
||||
{% set total_refs = commentary.cross_reference_groups | sum(attribute='refs', start=[]) | length %}
|
||||
{% set preview_count = [commentary.cross_reference_groups|length, 3]|min %}
|
||||
{% set hidden_count = total_refs - preview_count %}
|
||||
{# Flatten all refs into a single list #}
|
||||
{% set ns = namespace(all_refs=[]) %}
|
||||
{% for group in commentary.cross_reference_groups %}
|
||||
{% for ref in group.refs %}
|
||||
{% set ns.all_refs = ns.all_refs + [ref] %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% set total_refs = ns.all_refs | length %}
|
||||
{% set preview_refs = ns.all_refs[:3] %}
|
||||
{% set extra_refs = ns.all_refs[3:] %}
|
||||
<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 cross-refs{% if commentary.xref_auto_expand %} expanded{% endif %}">{% for group in commentary.cross_reference_groups[:3] %}<strong>{{ group.description }}:</strong> <a href="{{ group.refs[0].url }}">{{ group.refs[0].text }}</a>{% if group.refs|length > 1 %}{% if hidden_count >= 3 %}<span class="xref-extra">; {% for ref in group.refs[1:] %}<a href="{{ ref.url }}">{{ ref.text }}</a>{% if not loop.last %}; {% endif %}{% endfor %}</span>{% else %}; {% for ref in group.refs[1:] %}<a href="{{ ref.url }}">{{ ref.text }}</a>{% if not loop.last %}; {% endif %}{% endfor %}{% endif %}{% endif %}{% if not loop.last %}. {% endif %}{% endfor %}{% if commentary.cross_reference_groups|length > 3 %}{% if hidden_count >= 3 %}<span class="xref-extra">. {% for group in commentary.cross_reference_groups[3:] %}<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 %}. {% endif %}{% endfor %}</span>{% else %}. {% for group in commentary.cross_reference_groups[3:] %}<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 %}. {% endif %}{% endfor %}{% endif %}{% endif %}{% if hidden_count >= 3 %}<span class="xref-more"> +{{ hidden_count }}</span>{% endif %}</span>
|
||||
<span class="sidenote cross-refs{% if commentary.xref_auto_expand %} expanded{% endif %}">{% for ref in preview_refs %}<a href="{{ ref.url }}">{{ ref.text }}</a>{% if not loop.last %}; {% endif %}{% endfor %}{% if extra_refs %}<span class="xref-extra">; {% for ref in extra_refs %}<a href="{{ ref.url }}">{{ ref.text }}</a>{% if not loop.last %}; {% endif %}{% endfor %}</span><span class="xref-more"> +{{ extra_refs|length }}</span>{% endif %}</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user