Several changes to meta handling and rendering:

1) Translation metadata has move from t9nmeta.js to meta.js.
2) Translation metadata is now going to be generated by
   tools/genbooks.py (incomplete)
3) Translation metadata now includes a default translation to use via
   the helloao.org API.
4) Link to Bible Gateway has been removed from the scripture dialog.
This commit is contained in:
Benjamin A. Shelton 2026-08-17 19:43:54 -06:00
commit 558dd6b3ac
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01
4 changed files with 15 additions and 247 deletions

View file

@ -1,4 +1,4 @@
import { books } from './t9nmeta.js';
import { aliases, meta } from './meta.js';
export const modal = (el) => {
@ -18,12 +18,11 @@ function parseRef(ref) {
console.log(m);
const book = m[1];
const book = m[1].toLowerCase();
const chapter = m[5];
const verses = m[6]?.replaceAll(/–/g, '-');
console.log(`parseRef: ${book}, ${chapter}, ${verses}`);
console.log(books);
if (book === undefined) {
return {};
@ -32,12 +31,10 @@ function parseRef(ref) {
let refdata = {
ref: ref
};
if (book in books) {
refdata.book = book;
} else if (book in _map) {
refdata.book = _map[book];
if (book in aliases) {
refdata.book = aliases[book];
}
refdata.meta = books[refdata.book];
refdata.meta = meta[refdata.book];
refdata.fullTitle = () => {
let title = refdata.meta.title+' ';
title += refdata.chapter;
@ -99,9 +96,6 @@ function render(dialog, response, refs) {
const article = dialog?.querySelector('article');
let para = document.createElement('p');
dialog.querySelector('a.bg').href = `https://www.biblegateway.com/passage/?search=${refs.ref}&version=ESV`
dialog.querySelector('a.bg span.scripture').insertAdjacentText('beforeend', refs.fullTitle());
const heading = document.createElement('h1');
heading.insertAdjacentText('beforeend',
`${refs.fullTitle()}`);
@ -179,10 +173,11 @@ export const bindModals = () => {
e.addEventListener('click', (evt) => {
const scripture = e.attributes.getNamedItem('data-scripture');
const refs = parseRef(scripture.value);
const tx = refs.meta?.tx || 'BSB';
evt.preventDefault();
console.log('scripture:', scripture);
console.log('refs:', refs);
const uri = `https://bible.helloao.org/api/BSB/${refs.book.toUpperCase()}/${refs.chapter}.json`;
const uri = `https://bible.helloao.org/api/${tx}/${refs.book.toUpperCase()}/${refs.chapter}.json`;
dialog[0]?.showModal();
dialog[0]?.setAttribute('data-scripture', scripture);
dialog[0]?.classList.remove("hidden");
@ -205,7 +200,6 @@ export const bindModals = () => {
dialog[0]?.close();
dialog[0]?.classList.add('hidden');
dialog[0]?.querySelector('article')?.replaceChildren();
dialog[0]?.querySelector('a.bg span.scripture').replaceChildren();
}
});
dialog[0]?.querySelector('button[data-close]')?.addEventListener('click', (evt) => {
@ -213,22 +207,5 @@ export const bindModals = () => {
dialog[0]?.close();
dialog[0]?.classList.add('hidden');
dialog[0]?.querySelector('article')?.replaceChildren();
dialog[0]?.querySelector('a.bg span.scripture').replaceChildren();
});
};
function buildBookMap() {
let mp = {};
for (const book in books) {
if (!("aliases" in books[book])) {
continue;
}
for (const alias of books[book]?.aliases) {
mp[alias] = book;
}
mp[books[book]["title"].toLowerCase()] = book;
}
console.log(mp.length);
return mp;
}
const _map = buildBookMap();
};