-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Partial implementation of Tanakh Yomi
- Loading branch information
Showing
8 changed files
with
1,064 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {Locale, gematriya} from '@hebcal/core'; | ||
|
||
/** | ||
* Represents a tractate and page number | ||
*/ | ||
export class DafPage { | ||
/** | ||
* Initializes a daf yomi instance | ||
* @param {string} name | ||
* @param {number} blatt | ||
*/ | ||
constructor(name, blatt) { | ||
this.name = name; | ||
this.blatt = blatt; | ||
} | ||
/** | ||
* @return {number} | ||
*/ | ||
getBlatt() { | ||
return this.blatt; | ||
} | ||
/** | ||
* @return {string} | ||
*/ | ||
getName() { | ||
return this.name; | ||
} | ||
/** | ||
* Formats (with translation) the dafyomi result as a string like "Pesachim 34" | ||
* @param {string} [locale] Optional locale name (defaults to active locale). | ||
* @return {string} | ||
*/ | ||
render(locale) { | ||
locale = locale || Locale.getLocaleName(); | ||
if (typeof locale === 'string') { | ||
locale = locale.toLowerCase(); | ||
} | ||
if (locale === 'he' || locale === 'he-x-nonikud') { | ||
return Locale.gettext(this.name, locale) + ' דף ' + | ||
gematriya(this.blatt); | ||
} | ||
return Locale.gettext(this.name, locale) + ' ' + this.blatt; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import {Event} from '@hebcal/core'; | ||
|
||
export const dafYomiSefaria = { | ||
'Berachot': 'Berakhot', | ||
'Rosh Hashana': 'Rosh Hashanah', | ||
'Gitin': 'Gittin', | ||
'Baba Kamma': 'Bava Kamma', | ||
'Baba Metzia': 'Bava Metzia', | ||
'Baba Batra': 'Bava Batra', | ||
'Bechorot': 'Bekhorot', | ||
'Arachin': 'Arakhin', | ||
'Midot': 'Middot', | ||
'Shekalim': 'Jerusalem_Talmud_Shekalim', | ||
}; | ||
|
||
/** | ||
* Event wrapper around a DafPage instance | ||
*/ | ||
export class DafPageEvent extends Event { | ||
/** | ||
* @param {HDate} date | ||
* @param {DafPage} daf | ||
* @param {number} mask | ||
*/ | ||
constructor(date, daf, mask) { | ||
super(date, daf.render('en'), mask); | ||
this.daf = daf; | ||
} | ||
/** | ||
* Returns Daf Yomi name including the 'Daf Yomi: ' prefix (e.g. "Daf Yomi: Pesachim 107"). | ||
* @param {string} [locale] Optional locale name (defaults to active locale). | ||
* @return {string} | ||
*/ | ||
render(locale) { | ||
return this.daf.render(locale); | ||
} | ||
/** | ||
* Returns Daf Yomi name without the 'Daf Yomi: ' prefix (e.g. "Pesachim 107"). | ||
* @param {string} [locale] Optional locale name (defaults to active locale). | ||
* @return {string} | ||
*/ | ||
renderBrief(locale) { | ||
return this.daf.render(locale); | ||
} | ||
/** | ||
* Returns a link to sefaria.org or dafyomi.org | ||
* @return {string} | ||
*/ | ||
url() { | ||
const daf = this.daf; | ||
const tractate = daf.getName(); | ||
const blatt = daf.getBlatt(); | ||
if (tractate == 'Kinnim' || tractate == 'Midot') { | ||
return `https://www.dafyomi.org/index.php?masechta=meilah&daf=${blatt}a`; | ||
} else { | ||
const name0 = dafYomiSefaria[tractate] || tractate; | ||
const name = name0.replace(/ /g, '_'); | ||
return `https://www.sefaria.org/${name}.${blatt}a?lang=bi`; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.