Skip to content

Commit

Permalink
Correctly display verses on Salkin JPS Study Bible for doubled parshiyot
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Aug 4, 2024
1 parent 5808337 commit 0712b99
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/parshaCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function lookupParshaMeta(parshaName) {
name: parshaName,
bookName: torahBookNames[parsha0.book - 1],
anchor: makeAnchor(parshaName),
verses: parsha0.fullkriyah['1'][0] + '-' + parsha0.fullkriyah['7'][1],
verses: parshaVerses(parsha0),
...parsha0,
};
if (parsha.combined) {
Expand All @@ -164,6 +164,8 @@ export function lookupParshaMeta(parshaName) {
parsha.p2anchor = makeAnchor(p2);
const haftKey = p1 === 'Nitzavim' ? p1 : p2;
parsha.haft = lookupParsha(haftKey).haft;
const p1meta = lookupParsha(p1);
parsha.p1verses = parshaVerses(p1meta);
} else {
parsha.ordinal = Locale.ordinal(parsha.num, 'en');
}
Expand All @@ -178,6 +180,11 @@ export function lookupParshaMeta(parshaName) {
return parsha;
}

function parshaVerses(parshaMeta) {
const fk = parshaMeta.fullkriyah;
return fk['1'][0] + '-' + fk['7'][1];
}

/**
* @param {any} parsha
* @return {any}
Expand Down
20 changes: 18 additions & 2 deletions src/sedrot.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,25 @@ function doIsraelDiasporaDiffer(parsha, il, hd, triennial) {
return [false, '', ''];
}

/** @return {number} */
function nextParshaNum(parsha) {
if (parsha.num === 54) {
return 0;
}
return parsha.combined ? parshaNum.get(parsha.p2) : parsha.num;
}

/** @return {number} */
function prevParshaNum(parsha) {
if (parsha.num === 1) {
return 53;
}
return parsha.combined ? parshaNum.get(parsha.p1) - 2 : parsha.num - 2;
}

function makePrevNext(parsha, date, hd, il) {
const prevNum = parsha.num === 1 ? 53 : parsha.combined ? parshaNum.get(parsha.p1) - 2 : parsha.num - 2;
const nextNum = parsha.num === 54 ? 0 : parsha.combined ? parshaNum.get(parsha.p2) : parsha.num;
const prevNum = prevParshaNum(parsha);
const nextNum = nextParshaNum(parsha);
const prevName = parshiot54[prevNum];
const nextName = parshiot54[nextNum];
if (date) {
Expand Down
4 changes: 2 additions & 2 deletions views/parsha-detail.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Some congregations read the entire parsha every year (“Option A”).</div>
</ul>
</div><!-- .col -->
<% if (commentary['asin']) {
const altText = parsha.p1||parshaName + ': The JPS B’nai Mitzvah Torah Commentary (JPS Study Bible)';
const altText = (parsha.p1||parshaName) + ': The JPS B’nai Mitzvah Torah Commentary (JPS Study Bible)';
%><div class="col-lg-4 mb-3">
<div class="card">
<div class="row">
Expand Down Expand Up @@ -277,7 +277,7 @@ Parashat <%=parshaName%> is read in <%=locationName%> on:
<% if (commentary['asin']) { %>
<dt><a rel="sponsored"
href="https://www.amazon.com/o/ASIN/<%=commentary['asin']%>/hebcal-20"><em><%=parsha.p1||parshaName%>
(<%=parsha.bookName%> <%=parsha.verses%>) and Haftarah (<%=parsha.haftara%>):
(<%=parsha.bookName%> <%=parsha.combined ? parsha.p1verses : parsha.verses%>) and Haftarah (<%=parsha.haftara%>):
The JPS B’nai Mitzvah Torah Commentary (JPS Study Bible)</em></a>
<small class="text-body-secondary">(paid link)</small>
<dd>Rabbi Jeffrey K. Salkin, Jewish Publication Society, 2017
Expand Down

0 comments on commit 0712b99

Please sign in to comment.