Skip to content

Commit

Permalink
Pick up the memo from candle-lighting and Havdalah
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Jun 21, 2021
1 parent d9a5e89 commit 8567ec0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/icalendar",
"version": "4.6.0",
"version": "4.6.1",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"keywords": [
"ical",
Expand All @@ -24,8 +24,8 @@
"url": "https://github.com/hebcal/hebcal-icalendar/issues"
},
"dependencies": {
"@hebcal/core": "^3.12.0",
"@hebcal/rest-api": "^3.3.3"
"@hebcal/core": "^3.17.5",
"@hebcal/rest-api": "^3.6.0"
},
"scripts": {
"build": "rollup -c",
Expand Down Expand Up @@ -55,20 +55,20 @@
},
"devDependencies": {
"@ava/babel": "^1.0.1",
"@babel/core": "^7.13.10",
"@babel/core": "^7.14.6",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.13.12",
"@babel/register": "^7.13.8",
"@babel/preset-env": "^7.14.5",
"@babel/register": "^7.14.5",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-commonjs": "^19.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"ava": "^3.15.0",
"eslint": "^7.22.0",
"eslint": "^7.29.0",
"eslint-config-google": "^0.14.0",
"jsdoc": "^3.6.6",
"jsdoc": "^3.6.7",
"jsdoc-to-markdown": "^6.0.1",
"murmurhash-js": "^1.0.0",
"rollup": "^2.42.3"
"rollup": "^2.52.2"
}
}
20 changes: 8 additions & 12 deletions src/icalendar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {flags, Locale} from '@hebcal/core';
import {murmur3} from 'murmurhash-js';
import {pad2, pad4, getCalendarTitle, makeAnchor, getEventCategories,
getHolidayDescription, makeTorahMemoText} from '@hebcal/rest-api';
getHolidayDescription, makeTorahMemoText, appendIsraelAndTracking} from '@hebcal/rest-api';
import {promises as fs} from 'fs';
import {version} from '../package.json';

Expand Down Expand Up @@ -41,15 +41,7 @@ function addOptional(arr, key, val) {
* @return {string}
*/
function appendTrackingToUrl(url, il) {
if (!url) {
return url;
} else if (url.startsWith('https://www.hebcal.com')) {
const suffix = il ? 'i=on&' : '';
return `${url}?${suffix}utm_source=js&utm_medium=icalendar`;
} else {
const sep = url.indexOf('?') == -1 ? '?' : '&';
return url + sep + 'utm_source=hebcal.com&utm_medium=icalendar';
}
return url ? appendIsraelAndTracking(url, il, 'js', 'icalendar') : url;
}

const char74re = /(.{1,74})/g;
Expand Down Expand Up @@ -147,8 +139,7 @@ export class IcalEvent {
}

// create memo (holiday descr, Torah, etc)
const candles = (desc === 'Havdalah' || desc === 'Candle lighting');
const memo = candles ? '' : createMemo(ev, options.il);
const memo = createMemo(ev, options.il);
addOptional(arr, 'DESCRIPTION', memo);
addOptional(arr, 'LOCATION', location);
if (timed && options.location) {
Expand Down Expand Up @@ -269,6 +260,11 @@ export function eventToIcal(ev, options) {
* @return {string}
*/
function createMemo(e, il) {
const desc = e.getDesc();
const candles = (desc === 'Havdalah' || desc === 'Candle lighting');
if (candles) {
return e.memo || '';
}
const url = appendTrackingToUrl(e.url(), il);
const torahMemo = makeTorahMemoText(e, il).replace(/\n/g, '\\n');
if (e.getFlags() & flags.PARSHA_HASHAVUA) {
Expand Down

0 comments on commit 8567ec0

Please sign in to comment.