diff --git a/story/bible_tracker.py b/story/bible_tracker.py index 687bb6d..b0d4736 100644 --- a/story/bible_tracker.py +++ b/story/bible_tracker.py @@ -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""" diff --git a/templates/read_book.html b/templates/read_book.html index 92429fc..fbec003 100644 --- a/templates/read_book.html +++ b/templates/read_book.html @@ -48,6 +48,27 @@ + +
+