Render KJV footnotes and lemma margin line
This commit is contained in:
+49
-1
@@ -1,5 +1,5 @@
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
import type { LibraryState, StrongLink, Tag, Verse } from './types'
|
||||
import type { Footnote, LibraryState, StrongLink, Tag, Verse } from './types'
|
||||
|
||||
type TauriWindow = Window &
|
||||
typeof globalThis & {
|
||||
@@ -24,6 +24,15 @@ type ImportedStrongLink = {
|
||||
strong: string
|
||||
}
|
||||
|
||||
type ImportedFootnote = {
|
||||
id: number
|
||||
verse_id: string
|
||||
note_index: number
|
||||
caller: string
|
||||
reference: string
|
||||
text: string
|
||||
}
|
||||
|
||||
type ImportedStrongEntry = {
|
||||
strongs_number: string
|
||||
language: 'hebrew' | 'greek'
|
||||
@@ -48,6 +57,7 @@ type BrowserStrongData = {
|
||||
|
||||
let browserLibraryCache: Promise<Verse[]> | null = null
|
||||
let browserStrongDataCache: Promise<BrowserStrongData> | null = null
|
||||
let browserFootnotesCache: Promise<Map<string, Footnote[]>> | null = null
|
||||
const browserVerseSourceIds = new Map<number, string>()
|
||||
|
||||
const fallbackBrowserVerses: Verse[] = [
|
||||
@@ -58,6 +68,7 @@ const fallbackBrowserVerses: Verse[] = [
|
||||
verse: 1,
|
||||
text: 'In the beginning God created the heaven and the earth.',
|
||||
tags: [],
|
||||
footnotes: [],
|
||||
strongs: [
|
||||
{
|
||||
strong: 'H7225',
|
||||
@@ -86,6 +97,7 @@ const fallbackBrowserVerses: Verse[] = [
|
||||
verse: 1,
|
||||
text: 'The LORD is my shepherd; I shall not want.',
|
||||
tags: [],
|
||||
footnotes: [],
|
||||
strongs: [
|
||||
{
|
||||
strong: 'H3068',
|
||||
@@ -114,6 +126,7 @@ const fallbackBrowserVerses: Verse[] = [
|
||||
verse: 16,
|
||||
text: 'For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life.',
|
||||
tags: [],
|
||||
footnotes: [],
|
||||
strongs: [
|
||||
{
|
||||
strong: 'G25',
|
||||
@@ -142,6 +155,7 @@ const fallbackBrowserVerses: Verse[] = [
|
||||
verse: 28,
|
||||
text: 'And we know that all things work together for good to them that love God, to them who are the called according to his purpose.',
|
||||
tags: [],
|
||||
footnotes: [],
|
||||
strongs: [
|
||||
{
|
||||
strong: 'G2822',
|
||||
@@ -195,10 +209,15 @@ async function loadBrowserVerses() {
|
||||
console.warn('Unable to load browser Strong data.', error)
|
||||
return null
|
||||
})
|
||||
const footnotes = await loadBrowserFootnotes().catch((error) => {
|
||||
console.warn('Unable to load browser footnotes.', error)
|
||||
return new Map<string, Footnote[]>()
|
||||
})
|
||||
const tagsByVerse = readBrowserTags()
|
||||
return verses.map((verse) => ({
|
||||
...verse,
|
||||
strongs: strongData?.linksByVerse.get(browserVerseKey(verse)) ?? verse.strongs,
|
||||
footnotes: footnotes.get(browserVerseKey(verse)) ?? verse.footnotes ?? [],
|
||||
tags: tagsByVerse[verse.id] ?? [],
|
||||
}))
|
||||
}
|
||||
@@ -288,11 +307,40 @@ async function loadLibreBibleDevVerses(): Promise<Verse[]> {
|
||||
verse: verse.verse,
|
||||
text: verse.text,
|
||||
strongs: [],
|
||||
footnotes: [],
|
||||
tags: [],
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function loadBrowserFootnotes(): Promise<Map<string, Footnote[]>> {
|
||||
browserFootnotesCache ??= loadLibreBibleDevFootnotes()
|
||||
|
||||
return browserFootnotesCache
|
||||
}
|
||||
|
||||
async function loadLibreBibleDevFootnotes(): Promise<Map<string, Footnote[]>> {
|
||||
const importedFootnotes = await fetchJsonl<ImportedFootnote>(
|
||||
`${libreBibleDevRoot}/kjv-eng-kjv2006/footnotes.jsonl`,
|
||||
)
|
||||
const footnotes = new Map<string, Footnote[]>()
|
||||
|
||||
for (const note of importedFootnotes) {
|
||||
const current = footnotes.get(note.verse_id) ?? []
|
||||
current.push({
|
||||
id: note.id,
|
||||
verseId: note.verse_id,
|
||||
noteIndex: note.note_index,
|
||||
caller: note.caller,
|
||||
reference: note.reference,
|
||||
text: note.text,
|
||||
})
|
||||
footnotes.set(note.verse_id, current)
|
||||
}
|
||||
|
||||
return footnotes
|
||||
}
|
||||
|
||||
async function loadBrowserStrongData(): Promise<BrowserStrongData> {
|
||||
browserStrongDataCache ??= loadLibreBibleDevStrongData()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user