Skip to content

Commit

Permalink
Use new longer Torah summary from leyning package
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Jul 16, 2021
1 parent 9b08321 commit 3478e1b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/rest-api",
"version": "3.7.1",
"version": "3.7.2",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"keywords": [
"hebcal"
Expand Down
2 changes: 1 addition & 1 deletion src/classic-rest-api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ test('eventToClassicApiObject', (t) => {
'3': 'Exodus 19:14 - 19:19',
'4': 'Exodus 19:20 - 20:14',
'5': 'Exodus 20:15 - 20:23',
'torah': 'Exodus 19:1-20:23; Numbers 28:26-28:31',
'torah': 'Exodus 19:1-20:23; Numbers 28:26-31',
'haftarah': 'Ezekiel 1:1 - 1:28; 3:12',
'maftir': 'Numbers 28:26 - 28:31',
},
Expand Down
38 changes: 10 additions & 28 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,41 +229,23 @@ export function makeTorahMemoText(ev, il) {
if (mask & HOLIDAY_IGNORE_MASK) {
return '';
}
let reading;
const reading = (mask & flags.PARSHA_HASHAVUA) ?
leyning.getLeyningForParshaHaShavua(ev, il) :
leyning.getLeyningForHoliday(ev, il);
let memo = '';
if (mask & flags.PARSHA_HASHAVUA) {
reading = leyning.getLeyningForParshaHaShavua(ev, il);
memo = `Torah: ${reading.summary}`;
if (reading.reason) {
['7', 'M'].forEach((num) => {
const special = reading.reason[num];
if (special) {
const aname = num === '7' ? '7th aliyah' : 'Maftir';
const verses = leyning.formatAliyahWithBook(reading.fullkriyah[num]);
memo += `\n${aname}: ${verses} | ${special}`;
}
});
if (reading && (reading.summary || reading.haftara)) {
if (reading.summary) {
memo += `Torah: ${reading.summary}`;
}
if (reading.summary && reading.haftara) {
memo += '\n';
}
if (reading.haftara) {
memo += '\nHaftarah: ' + reading.haftara;
memo += 'Haftarah: ' + reading.haftara;
if (reading.reason && reading.reason.haftara) {
memo += ' | ' + reading.reason.haftara;
}
}
} else {
reading = leyning.getLeyningForHoliday(ev, il);
if (reading && (reading.summary || reading.haftara)) {
if (reading.summary) {
memo += `Torah: ${reading.summary}`;
}
if (reading.summary && reading.haftara) {
memo += '\n';
}
if (reading.haftara) {
memo += 'Haftarah: ' + reading.haftara;
}
return memo;
}
}
if (reading && reading.sephardic) {
memo += '\nHaftarah for Sephardim: ' + reading.sephardic;
Expand Down
4 changes: 1 addition & 3 deletions src/common.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ test('makeTorahMemoText', (t) => {
});
const memo = makeTorahMemoText(events[0], false).split('\n');
const expected = [
'Torah: Exodus 21:1-24:18',
'7th aliyah: Numbers 28:9 - 28:15 | Shabbat Shekalim (on Rosh Chodesh)',
'Maftir: Exodus 30:11 - 30:16 | Shabbat Shekalim (on Rosh Chodesh)',
'Torah: Exodus 21:1-24:18; Numbers 28:9-15; Exodus 30:11-16',
'Haftarah: II Kings 12:1 - 12:17 | Shabbat Shekalim (on Rosh Chodesh)',
];
t.deepEqual(memo, expected);
Expand Down

0 comments on commit 3478e1b

Please sign in to comment.