Skip to content

Commit

Permalink
fixed title on koh, wbc
Browse files Browse the repository at this point in the history
  • Loading branch information
Khen Solomon Lethil committed Jul 4, 2019
1 parent a49e56f commit 1531b83
Show file tree
Hide file tree
Showing 8 changed files with 98,927 additions and 25 deletions.
11 changes: 6 additions & 5 deletions book.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "Lai Siangtho",
"updated": "2019-07-01T18:48:20.914Z",
"version": 158,
"updated": "2019-07-04T09:37:17.250Z",
"version": 186,
"book": [
{
"identify": "ddb1931",
"name": "Det Danske Bibel. De Hellige Skrifter",
"name": "Det Danske Bibel",
"shortname": "Danske",
"year": "1931",
"language": {
Expand All @@ -15,7 +15,7 @@
},
"version": "1",
"description": "The electronic edition of this Bible comes from the Danish 1933 edition. The Old Testament is an update from the 1931 edition, and the New Testament is an update from the 1907 edition.",
"publisher": "Det Danske Bibelselskab",
"publisher": "Det Danske Bibelselskab, De Hellige Skrifter",
"copyright": "The New Testament is Public Domain."
},
{
Expand Down Expand Up @@ -227,7 +227,8 @@
"collection": {
"xml": [
"mcl2005",
"ostervald1877"
"ostervald1877",
"ddb1931"
],
"json": [
"ddb1931",
Expand Down
2 changes: 1 addition & 1 deletion json/348.json

Large diffs are not rendered by default.

98,839 changes: 98,838 additions & 1 deletion json/ddb1931.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion json/mara2011.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion json/matu2000.json

This file was deleted.

2 changes: 1 addition & 1 deletion json/matu2009.json

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions koh.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,22 @@ parseBookEach = function(data){
const verse = dumpVerse[index].replace(/\s+/g, ' ').trim();
// NOTE kachin version has some dot ended
var verseId = verse.split(" ")[0].trim().replace('.','');
// var verseTitel = titles.length?titles[0]:'';

if (isNaN(verseId) === false) {
verses[verseId]={
text:verse.substr(verse.indexOf(" ") + 1),
title:'',
ref:'',
merge:''
text:verse.substr(verse.indexOf(" ") + 1)
// title:'', ref:'', merge:''
};
if (titles.length){
verses[verseId].title=titles.pop();
}
} else if (verseId.includes("-")) {
// NOTE verse merge
var verseMergeId = verseId.split("-");
if (isNaN(verseMergeId[0]) === false && isNaN(verseMergeId[1]) === false) {
verses[verseMergeId[0]]={
text:verse.substr(verse.indexOf(" ") + 1),
title:'',
ref:'',
merge:verseMergeId[1]
};
console.log('merge?? -> ',bookName,chapterId,verseId);
Expand All @@ -139,7 +139,6 @@ parseBookEach = function(data){
// };
}
result[bookId].chapter[chapterId]={
title:titles,
verse:verses
};
}
Expand Down
82 changes: 74 additions & 8 deletions wbc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ initial = function(){
reject(e);
});
} else {
resolve(dataLocalJSON);
// resolve(dataLocalJSON);
parseFinalJSON(dataLocalJSON).then(function(e){
resolve(e);
},function(e){
reject(e);
});
}
},function(e){
reject(e);
Expand Down Expand Up @@ -294,9 +299,77 @@ writeJSON = function(data) {
});
} else {
settings.message.unknown('Required: info > identify,name,shortname,year for final output!');
if (typeof data === 'string'){
settings.message.unknown(data);
// console.log(data);
}
resolve();
}
});
},
parseFinalJSON = function(data){
return new Promise(function(resolve, reject) {
try {
var result={
info:data.info,
note:{},
digit:data.digit,
language:data.language,
testament:data.testament,
story:data.story,
book:parseBook(data.book)
};
return resolve(result);
} catch (e) {
return reject(e);
}
});
},
parseBook = function(data){
var result={};
for (const bId in data) {
if (data.hasOwnProperty(bId)) {
const book = data[bId];
if (book.hasOwnProperty('chapter')){
result[bId]={
chapter:{}
};
for (const cId in book.chapter) {
if (book.chapter.hasOwnProperty(cId)) {
const chapter = book.chapter[cId];
if (chapter.hasOwnProperty('verse')){
result[bId].chapter[cId]={
verse:{}
};
for (const vId in chapter.verse) {
if (chapter.verse.hasOwnProperty(vId)) {
var newVerse={};
const verse = chapter.verse[vId];
if (verse.text && verse.text !="") {
newVerse.text=verse.text;
} else {
console.log('verse has no text',bId,cId,vId);
}
if (verse.title && verse.title !="") newVerse.title=verse.title;
if (verse.merge && verse.merge !="") newVerse.merge=verse.merge;
if (verse.ref && verse.ref !="") newVerse.ref=verse.ref;
result[bId].chapter[cId].verse[vId]=newVerse;
}
}
} else {
console.log('has no verse');
}
}
}
} else {
console.log('has no chapter');
}
}
}
// data.forEach(function(bid){
// console.log('bookid',bid);
// });
return result;
};
// https://www.bible.com/json/bible/languages?filter=
// https://www.bible.com/json/bible/books/348?filter=
Expand Down Expand Up @@ -336,15 +409,8 @@ task.main = function(args) {
}

return new Promise(function(resolve, reject) {
// console.log('bookIdentify',settings.bookIdentify);
// console.log('apiDataOnlyOne',settings.apiDataOnlyOne);
// console.log('apiData',settings.apiData);
// console.log('apiURLChapter',settings.apiURLChapter);
// console.log('apiURLBookName',settings.apiURLBookName);
// resolve();
initial().then(function(result){
writeJSON(result).then(function(r){
// console.log(result.book);
resolve(r);
},function(e){
reject(e);
Expand Down

0 comments on commit 1531b83

Please sign in to comment.