-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
127 lines (120 loc) · 6.17 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
const {slideTypes, partTypes} = require('./slide-types');
// Mapping functions
function mapToSlide(part, ochtend, collectenGKv, collectenNGK) {
switch (part.type) {
case partTypes.titel:
return [{type: slideTypes.titel, title: part.title}];
case partTypes.votum:
return [{type: slideTypes.votum, title: part.title || 'Votum en vredegroet', vredegroet: part.vredegroet || 'vredegroet'}];
case partTypes.lied:
if (part.verses.length) {
return part.verses.map((verse) => {
return {type: slideTypes.notenbalk, title: part.title || 'Zingen', song: part.song || '', verses: part.verses, active: verse};
});
} else {
return [{type: slideTypes.notenbalk, title: part.title || 'Zingen', song: part.song || '', verses: []}];
}
case partTypes.bijbeltekst:
return [{type: slideTypes.bijbeltekst, title: part.title || 'Lezen', book: part.book,
fromChapter: part.fromChapter, toChapter: part.toChapter, fromVerse: part.fromVerse, toVerse: part.toVerse}];
case partTypes.collecte:
return [{type: slideTypes.collecteMiddag, collectenGKv: collectenGKv, collectenNGK: collectenNGK}];
case partTypes.zegen:
return [{type: slideTypes.zegen, title: part.zegen || 'Zegen'}];
case partTypes.ondertiteling:
const split = part.text.split(/\n/);
let curTexts = [];
let slides = [[]];
for (let text of split) {
// noinspection EqualityComparisonWithCoercionJS
if (text == false) {
slides.push(curTexts);
curTexts = [];
} else {
if (curTexts.length >= 2) {
slides.push(curTexts);
curTexts = [];
}
curTexts.push(text);
}
}
if (curTexts.length) {
slides.push(curTexts);
}
slides.push([]);
return [{type: slideTypes.ondertitelingTitel, title: part.title, subTitle: part.subTitle}].concat(
slides.map(s => { return {type: slideTypes.ondertiteling, texts: s} })
);
default:
return [];
}
}
function mapWithEmpty(part, ochtend, collectenGKv, collectenNGK) {
return [{type: slideTypes.liturgie}, ...mapToSlide(part, ochtend, collectenGKv, collectenNGK)];
}
function mapToLiturgie(part) {
if (part.liturgie) {
if (Array.isArray(part.liturgie)) {
return part.liturgie;
} else {
return [part.liturgie];
}
}
switch (part.type) {
case partTypes.titel:
return [part.title];
case partTypes.votum:
return [part.title || 'Votum en vredegroet'];
case partTypes.lied:
let title = '';
if (part.title && part.title !== 'Zingen') {
title += part.title;
if (part.song) title += ': ';
}
if (part.song) title += part.song;
if (part.verses.length) title += ' : ' + part.verses.join(', ');
return [title];
case partTypes.bijbeltekst:
const text = createTextName(part);
return [(part.title || 'Lezen') + (text ? ': ' + text : '')];
case partTypes.collecte:
return [part.title || 'Collecte'];
case partTypes.zegen:
return [part.zegen || 'Zegen'];
case partTypes.ondertiteling:
return [part.title];
default:
return [];
}
}
const boeken = JSON.parse(`{"GEN":"Genesis","EXO":"Exodus","LEV":"Leviticus","NUM":"Numeri","DEU":"Deuteronomium","JOS":"Jozua","JDG":"Rechters","RUT":"Ruth","1SA":"1 Samuel","2SA":"2 Samuel","1KI":"1 Koningen","2KI":"2 Koningen","1CH":"1 Kronieken","2CH":"2 Kronieken","EZR":"Ezra","NEH":"Nehemia","EST":"Ester","JOB":"Job","PSA":"Psalmen","PRO":"Spreuken","ECC":"Prediker","SNG":"Hooglied","ISA":"Jesaja","JER":"Jeremia","LAM":"Klaagliederen","EZK":"Ezechiël","DAN":"Daniël","HOS":"Hosea","JOL":"Joël","AMO":"Amos","OBA":"Obadja","JON":"Jona","MIC":"Micha","NAM":"Nahum","HAB":"Habakuk","ZEP":"Sefanja","HAG":"Haggai","ZEC":"Zacharia","MAL":"Maleachi","TOB":"Tobit","JDT":"Judit","ESG":"Ester (Gr.)","1MA":"1 Makkabeeën","2MA":"2 Makkabeeën","WIS":"Wijsheid","SIR":"Sirach","BAR":"Baruch","LJE":"Brief van Jeremia","DAG":"Daniël (Gr.)","MAN":"Manasse","MAT":"Matteüs","MRK":"Marcus","LUK":"Lucas","JHN":"Johannes","ACT":"Handelingen","ROM":"Romeinen","1CO":"1 Korintiërs","2CO":"2 Korintiërs","GAL":"Galaten","EPH":"Efeziërs","PHP":"Filippenzen","COL":"Kolossenzen","1TH":"1 Tessalonicenzen","2TH":"2 Tessalonicenzen","1TI":"1 Timoteüs","2TI":"2 Timoteüs","TIT":"Titus","PHM":"Filemon","HEB":"Hebreeën","JAS":"Jakobus","1PE":"1 Petrus","2PE":"2 Petrus","1JN":"1 Johannes","2JN":"2 Johannes","3JN":"3 Johannes","JUD":"Judas","REV":"Openbaring"}`);
function createTextName(part) {
if (!part.book) {
return '';
}
return boeken[part.book].replace('Psalmen', 'Psalm') + ' '
+ part.fromChapter + ' : ' + part.fromVerse
+ (parseInt(part.fromChapter, 10) !== parseInt(part.toChapter, 10) || parseInt(part.fromVerse, 10) !== parseInt(part.toVerse, 10) ?
' - '
+ (parseInt(part.fromChapter, 10) !== parseInt(part.toChapter, 10) ? part.toChapter + ' : ' : '')
+ part.toVerse : ''
);
}
// Map it
function createConfig(expandable, ochtend, thema, collectenGKv, collectenNGK) {
return {
thema: thema,
slides: [
{type: slideTypes.welkom, vooraf: true},
{type: slideTypes.liturgie, vooraf: true},
// {type: slideTypes.kerkdienstgemist, vooraf: true},
// {type: slideTypes.parkeren, vooraf: true},
...expandable.flatMap(x => mapWithEmpty(x, ochtend, collectenGKv, collectenNGK)),
{type: /*ochtend ? slideTypes.totZiensOchtend :*/ slideTypes.totZiensMiddag, vooraf: false}
],
liturgie: [
...expandable.flatMap(mapToLiturgie),
]
};
}
exports.createConfig = createConfig;