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:
2026-02-22 10:06:55 -05:00
parent bcba67a35f
commit 093e78a89e
2 changed files with 36 additions and 0 deletions

View File

@@ -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"""