mirror of
https://github.com/kennethreitz/kjvstudy.org.git
synced 2026-06-05 23:00:16 +00:00
Auto-expand cross-refs when not crowded, collapse when cramped
Cross-references now auto-expand when there's room (3+ verses since last xref), but stay collapsed when verses are close together to prevent margin overload. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -218,11 +218,13 @@ async def read_chapter(request: Request, book: str, chapter: int):
|
||||
# Add cross-references with cooldown to prevent margin overload
|
||||
cross_refs = get_cross_references(book, chapter, verse.verse)
|
||||
|
||||
# Skip if within cooldown period (show condensed count instead)
|
||||
# If within cooldown period, keep collapsed; otherwise auto-expand
|
||||
if cross_refs and verse.verse - last_xref_verse < xref_cooldown:
|
||||
commentary['cross_reference_groups'] = []
|
||||
commentary['cross_ref_count'] = len(cross_refs) # Just show "+N refs"
|
||||
commentary['xref_auto_expand'] = False # Stay collapsed
|
||||
elif cross_refs:
|
||||
commentary['xref_auto_expand'] = True # Auto-expand when there's room
|
||||
|
||||
if cross_refs:
|
||||
# Group cross-references by their description/note
|
||||
grouped_refs = defaultdict(list)
|
||||
for ref in cross_refs:
|
||||
|
||||
@@ -469,11 +469,7 @@ document.body.dataset.resourceReader = 'false';
|
||||
{% set hidden_count = total_refs - preview_count %}
|
||||
<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">{% 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>
|
||||
{% elif commentary.cross_ref_count %}
|
||||
<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"><span class="xref-more">+{{ commentary.cross_ref_count }} refs</span></span>
|
||||
<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>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user