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:
parent
792de1ef7e
commit
558dd6b3ac
4 changed files with 15 additions and 247 deletions
7
src/utils/meta.js
Normal file
7
src/utils/meta.js
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -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();
|
||||
};
|
||||
|
|
@ -1,207 +0,0 @@
|
|||
// Translation metadata.
|
||||
|
||||
|
||||
export const books = {
|
||||
"gen": {"title": "Genesis", "start": 1, "stop": 50, "count": 50,
|
||||
"aliases": ["gn"],
|
||||
},
|
||||
"exo": {"title": "Exodus", "start": 1, "stop": 40, "count": 40,
|
||||
"aliases": ["ex"],
|
||||
},
|
||||
"lev": {"title": "Leviticus", "start": 1, "stop": 27, "count": 27,
|
||||
"aliases": ["lv"],
|
||||
},
|
||||
"num": {"title": "Numbers", "start": 1, "stop": 36, "count": 36,
|
||||
"aliases": ["nm", "numb", "nmb", "nmbs"],
|
||||
},
|
||||
"deu": {"title": "Deuteronomy", "start": 1, "stop": 34, "count": 34,
|
||||
"aliases": ["dt", "deut", "deuter"],
|
||||
},
|
||||
"jos": {"title": "Joshua", "start": 1, "stop": 24, "count": 24,
|
||||
"aliases": ["js", "josh"],
|
||||
},
|
||||
"jdg": {"title": "Judges", "start": 1, "stop": 21, "count": 21,
|
||||
"aliases": ["jd", "jdgs"],
|
||||
},
|
||||
"rut": {"title": "Ruth", "start": 1, "stop": 4, "count": 4,
|
||||
"aliases": ["rt"],
|
||||
},
|
||||
"1sa": {"title": "1 Samuel", "start": 1, "stop": 31, "count": 31,
|
||||
"aliases": ["1s", "1sam", "1 s", "1 sa", "1 sam"],
|
||||
},
|
||||
"2sa": {"title": "2 Samuel", "start": 1, "stop": 24, "count": 24,
|
||||
"aliases": ["2s", "2sam", "2 s", "2 sa", "2 sam"],
|
||||
},
|
||||
"1ki": {"title": "1 Kings", "start": 1, "stop": 22, "count": 22,
|
||||
"aliases": ["1k", "1kgs", "1king", "1 k", "1 ki", "1 kgs", "1 king"],
|
||||
},
|
||||
"2ki": {"title": "2 Kings", "start": 1, "stop": 25, "count": 25,
|
||||
"aliases": ["2k", "2kgs", "2king", "2 k", "2 ki", "2 kgs", "2 king"],
|
||||
|
||||
},
|
||||
"1ch": {"title": "1 Chronicles", "start": 1, "stop": 29, "count": 29,
|
||||
"aliases": ["1c", "1chr", "1chron", "1 c", "1 ch", "1 chr", "1 chron"],
|
||||
},
|
||||
"2ch": {"title": "2 Chronicles", "start": 1, "stop": 36, "count": 36,
|
||||
"aliases": ["2c", "2chr", "2chron", "2 c", "2 ch", "2 chr", "2 chron"],
|
||||
|
||||
},
|
||||
"ezr": {"title": "Ezra", "start": 1, "stop": 10, "count": 10,
|
||||
"aliases": ["ez"],
|
||||
},
|
||||
"neh": {"title": "Nehemiah", "start": 1, "stop": 13, "count": 13,
|
||||
"aliases": ["nh"],
|
||||
},
|
||||
"est": {"title": "Esther", "start": 1, "stop": 10, "count": 10,
|
||||
"aliases": ["es"],
|
||||
},
|
||||
"job": {"title": "Job", "start": 1, "stop": 42, "count": 42,
|
||||
"aliases": ["jo"],
|
||||
},
|
||||
"psa": {"title": "Psalms", "start": 1, "stop": 150, "count": 150,
|
||||
"aliases": ["ps", "psalm", "pss"],
|
||||
},
|
||||
"pro": {"title": "Proverbs", "start": 1, "stop": 31, "count": 31,
|
||||
"aliases": ["pr", "prov"],
|
||||
},
|
||||
"ecc": {"title": "Ecclesiastes", "start": 1, "stop": 12, "count": 12,
|
||||
"aliases": ["ec", "eccl", "eccle"],
|
||||
},
|
||||
"sng": {"title": "Song of Solomon", "start": 1, "stop": 8, "count": 8,
|
||||
"aliases": ["sn", "son", "song", "sol"],
|
||||
},
|
||||
"isa": {"title": "Isaiah", "start": 1, "stop": 66, "count": 66,
|
||||
"aliases": ["is", "isai"],
|
||||
},
|
||||
"jer": {"title": "Jeremiah", "start": 1, "stop": 52, "count": 52,
|
||||
"aliases": ["jr", "jere", "jerem"],
|
||||
},
|
||||
"lam": {"title": "Lamentations", "start": 1, "stop": 5, "count": 5,
|
||||
"aliases": ["lm", "lamen"],
|
||||
},
|
||||
"ezk": {"title": "Ezekiel", "start": 1, "stop": 48, "count": 48,
|
||||
"aliases": ["eze", "ezek"],
|
||||
},
|
||||
"dan": {"title": "Daniel", "start": 1, "stop": 12, "count": 12,
|
||||
"aliases": ["dn"],
|
||||
},
|
||||
"hos": {"title": "Hosea", "start": 1, "stop": 14, "count": 14,
|
||||
"aliases": ["hs"],
|
||||
},
|
||||
"jol": {"title": "Joel", "start": 1, "stop": 3, "count": 3,
|
||||
"aliases": ["jl"],
|
||||
},
|
||||
"amo": {"title": "Amos", "start": 1, "stop": 9, "count": 9,
|
||||
"aliases": ["am"],
|
||||
},
|
||||
"oba": {"title": "Obadiah", "start": 1, "stop": 1, "count": 1,
|
||||
"aliases": ["ob", "obd", "obad"],
|
||||
},
|
||||
"jon": {"title": "Jonah", "start": 1, "stop": 4, "count": 4,
|
||||
"aliases": ["jo"],
|
||||
},
|
||||
"mic": {"title": "Micah", "start": 1, "stop": 7, "count": 7,
|
||||
"aliases": ["mc"],
|
||||
},
|
||||
"nam": {"title": "Nahum", "start": 1, "stop": 3, "count": 3,
|
||||
"aliases": ["na"],
|
||||
},
|
||||
"hab": {"title": "Habakkuk", "start": 1, "stop": 3, "count": 3,
|
||||
"aliases": ["hb", "haba", "habak"],
|
||||
},
|
||||
"zep": {"title": "Zephaniah", "start": 1, "stop": 3, "count": 3,
|
||||
"aliases": ["ze", "zf", "zef"],
|
||||
},
|
||||
"hag": {"title": "Haggai", "start": 1, "stop": 2, "count": 2,
|
||||
"aliases": ["hg"],
|
||||
},
|
||||
"zec": {"title": "Zechariah", "start": 1, "stop": 14, "count": 14,
|
||||
"aliases": ["ze", "zech"],
|
||||
},
|
||||
"mal": {"title": "Malachi", "start": 1, "stop": 4, "count": 4,
|
||||
"aliases": ["ml", "mala"],
|
||||
},
|
||||
"mat": {"title": "Matthew", "start": 1, "stop": 28, "count": 28,
|
||||
"aliases": ["mt", "matt"],
|
||||
},
|
||||
"mrk": {"title": "Mark", "start": 1, "stop": 16, "count": 16,
|
||||
"aliases": ["mk"],
|
||||
},
|
||||
"luk": {"title": "Luke", "start": 1, "stop": 24, "count": 24,
|
||||
"aliases": ["lk"],
|
||||
},
|
||||
"jhn": {"title": "John", "start": 1, "stop": 21, "count": 21,
|
||||
"aliases": ["jn"],
|
||||
},
|
||||
"act": {"title": "Acts", "start": 1, "stop": 28, "count": 28,
|
||||
"aliases": ["ac"],
|
||||
},
|
||||
"rom": {"title": "Romans", "start": 1, "stop": 16, "count": 16,
|
||||
"aliases": ["rm", "rms"],
|
||||
},
|
||||
"1co": {"title": "1 Corinthians", "start": 1, "stop": 16, "count": 16,
|
||||
"aliases": ["1cor", "1corin", "1 co", "1 cor", "1 corin"],
|
||||
},
|
||||
"2co": {"title": "2 Corinthians", "start": 1, "stop": 13, "count": 13,
|
||||
"aliases": ["2cor", "2corin", "2 co", "2 cor", "2 corin"],
|
||||
},
|
||||
"gal": {"title": "Galatians", "start": 1, "stop": 6, "count": 6,
|
||||
"aliases": ["gl"],
|
||||
},
|
||||
"eph": {"title": "Ephesians", "start": 1, "stop": 6, "count": 6,
|
||||
"aliases": ["ep", "ef"],
|
||||
},
|
||||
"php": {"title": "Philippians", "start": 1, "stop": 4, "count": 4,
|
||||
"aliases": ["ph", "phil"],
|
||||
},
|
||||
"col": {"title": "Colossians", "start": 1, "stop": 4, "count": 4,
|
||||
"aliases": ["cl", "colo"],
|
||||
},
|
||||
"1th": {"title": "1 Thessalonians", "start": 1, "stop": 5, "count": 5,
|
||||
"aliases": ["1thes", "1thess", "1 thes", "1 thess"],
|
||||
},
|
||||
"2th": {"title": "2 Thessalonians", "start": 1, "stop": 3, "count": 3,
|
||||
"aliases": ["2thes", "2thess", "2 thes", "2 thess"],
|
||||
},
|
||||
"1ti": {"title": "1 Timothy", "start": 1, "stop": 6, "count": 6,
|
||||
"aliases": ["1tim", "1 ti", "1 tim"],
|
||||
},
|
||||
"2ti": {"title": "2 Timothy", "start": 1, "stop": 4, "count": 4,
|
||||
"aliases": ["2tim", "2 ti", "2 tim"],
|
||||
},
|
||||
"tit": {"title": "Titus", "start": 1, "stop": 3, "count": 3,
|
||||
"aliases": ["ti"],
|
||||
},
|
||||
"phm": {"title": "Philemon", "start": 1, "stop": 1, "count": 1,
|
||||
"aliases": ["pi", "philm", "philem"],
|
||||
},
|
||||
"heb": {"title": "Hebrews", "start": 1, "stop": 13, "count": 13,
|
||||
"aliases": ["he"],
|
||||
},
|
||||
"jas": {"title": "James", "start": 1, "stop": 5, "count": 5,
|
||||
"aliases": ["ja", "jam"],
|
||||
},
|
||||
"1pe": {"title": "1 Peter", "start": 1, "stop": 5, "count": 5,
|
||||
"aliases": ["1p", "1pt", "1pet", "1 p", "1 pe", "1 pt", "1 pet"],
|
||||
},
|
||||
"2pe": {"title": "2 Peter", "start": 1, "stop": 3, "count": 3,
|
||||
"aliases": ["2p", "2pt", "2pet", "2 p", "2 pe", "2 pt", "2 pet"],
|
||||
},
|
||||
"1jn": {"title": "1 John", "start": 1, "stop": 5, "count": 5,
|
||||
"aliases": ["1jon", "1 jn", "1 jon"],
|
||||
},
|
||||
"2jn": {"title": "2 John", "start": 1, "stop": 1, "count": 1,
|
||||
"aliases": ["2jon", "2 jn", "2 jon"],
|
||||
},
|
||||
"3jn": {"title": "3 John", "start": 1, "stop": 1, "count": 1,
|
||||
"aliases": ["3jon", "3 jn", "3 jon"],
|
||||
},
|
||||
"jud": {"title": "Jude", "start": 1, "stop": 1, "count": 1,
|
||||
"aliases": ["ju"],
|
||||
},
|
||||
"rev": {"title": "Revelation", "start": 1, "stop": 22, "count": 22,
|
||||
"aliases": ["rv", "reve"],
|
||||
},
|
||||
}
|
||||
|
||||
export const aliases = {"gn": "gen", "ex": "exo", "lv": "lev", "nm": "num", "numb": "num", "nmb": "num", "nmbs": "num", "dt": "deu", "deut": "deu", "deuter": "deu", "js": "jos", "josh": "jos", "jd": "jdg", "jdgs": "jdg", "rt": "rut", "1s": "1sa", "1sam": "1sa", "1 s": "1sa", "1 sa": "1sa", "1 sam": "1sa", "2s": "2sa", "2sam": "2sa", "2 s": "2sa", "2 sa": "2sa", "2 sam": "2sa", "1k": "1ki", "1kgs": "1ki", "1king": "1ki", "1 k": "1ki", "1 ki": "1ki", "1 kgs": "1ki", "1 king": "1ki", "2k": "2ki", "2kgs": "2ki", "2king": "2ki", "2 k": "2ki", "2 ki": "2ki", "2 kgs": "2ki", "2 king": "2ki", "1c": "1ch", "1chr": "1ch", "1chron": "1ch", "1 c": "1ch", "1 ch": "1ch", "1 chr": "1ch", "1 chron": "1ch", "2c": "2ch", "2chr": "2ch", "2chron": "2ch", "2 c": "2ch", "2 ch": "2ch", "2 chr": "2ch", "2 chron": "2ch", "ez": "ezr", "nh": "neh", "es": "est", "jo": "jon", "ps": "psa", "psalm": "psa", "pss": "psa", "pr": "pro", "prov": "pro", "ec": "ecc", "eccl": "ecc", "eccle": "ecc", "sn": "sng", "son": "sng", "song": "sng", "sol": "sng", "is": "isa", "isai": "isa", "jr": "jer", "jere": "jer", "jerem": "jer", "lm": "lam", "lamen": "lam", "eze": "ezk", "ezek": "ezk", "dn": "dan", "hs": "hos", "jl": "jol", "am": "amo", "ob": "oba", "obd": "oba", "obad": "oba", "mc": "mic", "na": "nam", "hb": "hab", "haba": "hab", "habak": "hab", "ze": "zec", "zf": "zep", "zef": "zep", "hg": "hag", "zech": "zec", "ml": "mal", "mala": "mal", "mt": "mat", "matt": "mat", "mk": "mrk", "lk": "luk", "jn": "jhn", "ac": "act", "rm": "rom", "rms": "rom", "1cor": "1co", "1corin": "1co", "1 co": "1co", "1 cor": "1co", "1 corin": "1co", "2cor": "2co", "2corin": "2co", "2 co": "2co", "2 cor": "2co", "2 corin": "2co", "gl": "gal", "ep": "eph", "ef": "eph", "ph": "php", "phil": "php", "cl": "col", "colo": "col", "1thes": "1th", "1thess": "1th", "1 thes": "1th", "1 thess": "1th", "2thes": "2th", "2thess": "2th", "2 thes": "2th", "2 thess": "2th", "1tim": "1ti", "1 ti": "1ti", "1 tim": "1ti", "2tim": "2ti", "2 ti": "2ti", "2 tim": "2ti", "ti": "tit", "pi": "phm", "philm": "phm", "philem": "phm", "he": "heb", "ja": "jas", "jam": "jas", "1p": "1pe", "1pt": "1pe", "1pet": "1pe", "1 p": "1pe", "1 pe": "1pe", "1 pt": "1pe", "1 pet": "1pe", "2p": "2pe", "2pt": "2pe", "2pet": "2pe", "2 p": "2pe", "2 pe": "2pe", "2 pt": "2pe", "2 pet": "2pe", "1jon": "1jn", "1 jn": "1jn", "1 jon": "1jn", "2jon": "2jn", "2 jn": "2jn", "2 jon": "2jn", "3jon": "3jn", "3 jn": "3jn", "3 jon": "3jn", "ju": "jud", "rv": "rev", "reve": "rev"};
|
||||
Loading…
Reference in a new issue