← Projects
Parsha icon

Parsha

LaunchedDeprecated

A small web app that works out which Torah portion is being read this week and serves it — the last thing I built before Amazon.

nodeexpresshandlebarshebcalweb

The weekly Torah portion — the parsha — is read on the same schedule by Jewish communities worldwide. Working out which one is current sounds like a lookup and isn't: the Hebrew calendar is lunisolar, festivals displace readings, and portions double up in some years and not others to keep the cycle aligned.

Parsha was a small Node app that answered the question and then served the reading.

The interesting part is the date logic

The app asks the Hebrew calendar for today, and then walks forward:

let getParshaName = () => {
    let parshaName = '';
    let hDate = new Hebcal.HDate();
    while (!parshaName) {
      if (hDate.holidays().length) {
        hDate = hDate.next();
      } else {
        parshaName = hDate.getParsha()[0];
      }
    }
    return parshaName;
}

Step forward a day at a time until you land on a date that is not a holiday, and take that date's portion. It is a loop rather than a formula because the exceptions are the rule — a festival falling on Shabbat has its own reading, and the weekly cycle resumes after it.

Everything downstream is ordinary: normalize the portion name into a slug, look it up in a table of portions, and render the page with its display name, text, and video. Express, Handlebars, EJS views, Helmet for headers, static assets from public.

It is a few hundred lines and a content table, built in October 2016.