Add chapter backward/forward navigation in read_book UI
- Each chapter card now has a footer with Prev/Next chapter anchor links - First chapter shows only Next; last chapter shows 'End of Book' - Back to Top link on every chapter footer - Added get_chapter_neighbours() helper in story/bible_tracker.py for programmatic chapter sequence navigation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -157,6 +157,21 @@ def harvest_metadata(bp, folder, full_manuscript):
|
||||
return bp
|
||||
|
||||
|
||||
def get_chapter_neighbours(manuscript, current_num):
|
||||
"""Return (prev_num, next_num) chapter numbers adjacent to current_num.
|
||||
|
||||
manuscript: list of chapter dicts each with a 'num' key.
|
||||
Returns None for prev/next when at the boundary.
|
||||
"""
|
||||
nums = sorted({ch.get('num') for ch in manuscript if ch.get('num') is not None})
|
||||
if current_num not in nums:
|
||||
return None, None
|
||||
idx = nums.index(current_num)
|
||||
prev_num = nums[idx - 1] if idx > 0 else None
|
||||
next_num = nums[idx + 1] if idx < len(nums) - 1 else None
|
||||
return prev_num, next_num
|
||||
|
||||
|
||||
def refine_bible(bible, instruction, folder):
|
||||
utils.log("SYSTEM", f"Refining Bible with instruction: {instruction}")
|
||||
prompt = f"""
|
||||
|
||||
@@ -48,6 +48,27 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Chapter Navigation Footer -->
|
||||
<div class="card-footer bg-transparent d-flex justify-content-between align-items-center py-2">
|
||||
{% if not loop.first %}
|
||||
{% set prev_ch = manuscript[loop.index0 - 1] %}
|
||||
<a href="#ch-{{ prev_ch.num }}" class="btn btn-sm btn-outline-secondary">
|
||||
<i class="fas fa-arrow-up me-1"></i>Ch {{ prev_ch.num }}
|
||||
</a>
|
||||
{% else %}
|
||||
<span></span>
|
||||
{% endif %}
|
||||
<a href="#" class="btn btn-sm btn-link text-muted small py-0">Back to Top</a>
|
||||
{% if not loop.last %}
|
||||
{% set next_ch = manuscript[loop.index0 + 1] %}
|
||||
<a href="#ch-{{ next_ch.num }}" class="btn btn-sm btn-outline-secondary">
|
||||
Ch {{ next_ch.num }}<i class="fas fa-arrow-down ms-1"></i>
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="text-muted small fst-italic">End of Book</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Rewrite Modal -->
|
||||
<div class="modal fade" id="rewriteModal{{ ch.num|string|replace(' ', '') }}" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
|
||||
Reference in New Issue
Block a user