Skip to content

Commit

Permalink
feat(topics): Create pathway for key sources
Browse files Browse the repository at this point in the history
  • Loading branch information
rneiss committed Feb 9, 2024
1 parent 8f72dce commit 33ad7a8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
12 changes: 10 additions & 2 deletions static/js/TopicPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,14 @@ const useTabDisplayData = (translationLanguagePreference) => {
sortFunc: refSort,
renderWrapper: refRenderWrapper,
},
{
key: 'key-sources',
fetcher: fetchBulkText.bind(null, translationLanguagePreference),
sortOptions: ['Relevance', 'Chronological'],
filterFunc: refFilter,
sortFunc: refSort,
renderWrapper: refRenderWrapper,
},
{
key: 'sources',
fetcher: fetchBulkText.bind(null, translationLanguagePreference),
Expand Down Expand Up @@ -538,12 +546,12 @@ const TopicPage = ({
currTabName={tab}
setTab={setTab}
tabs={displayTabs}
renderTab={t => {console.log(t); return (
renderTab={t => (
<div className={classNames({tab: 1, noselect: 1, filter: t.justifyright, open: t.justifyright && showFilterHeader})}>
<InterfaceText text={t.title} />
{ t.icon ? <img src={t.icon} alt={`${t.title.en} icon`} /> : null }
</div>
)}}
)}
containerClasses={"largeTabs"}
onClickArray={{[onClickFilterIndex]: ()=>setShowFilterHeader(!showFilterHeader)}}
>
Expand Down
24 changes: 15 additions & 9 deletions static/js/sefaria/sefaria.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,24 +317,24 @@ Sefaria = extend(Sefaria, {
}
},
/**
* Helps the BookPage toc translate the given integer to the correctly formatted display string for the section given the varying address types.
* Helps the BookPage toc translate the given integer to the correctly formatted display string for the section given the varying address types.
* @param {string} addressType - The address type of the schema being requested
* @param {number} i - The numeric section string from the database
* @param {number} offset - If needed, an offest to allow section addresses that do not start counting with 0
* @returns {[string,string]} Section string in both languages.
*/
* @returns {[string,string]} Section string in both languages.
*/
getSectionStringByAddressType: function(addressType, i, offset=0) {
let section = i + offset;
let enSection, heSection;
if (addressType === 'Talmud') {
enSection = Sefaria.hebrew.intToDaf(section);
heSection = Sefaria.hebrew.encodeHebrewDaf(enSection);
} else if (addressType === "Year") {
enSection = section + 1241;
enSection = section + 1241;
heSection = Sefaria.hebrew.encodeHebrewNumeral(section+1);
heSection = heSection.slice(0,-1) + '"' + heSection.slice(-1);
} else if (addressType === "Folio") {
enSection = Sefaria.hebrew.intToFolio(section);
enSection = Sefaria.hebrew.intToFolio(section);
heSection = Sefaria.hebrew.encodeHebrewFolio(enSection);
} else {
enSection = section + 1;
Expand Down Expand Up @@ -2520,22 +2520,23 @@ _media: {},
for (let refObj of linkTypeObj.refs) {
let tabKey = linkTypeSlug;
if (tabKey === 'about') {
tabKey = refObj.is_sheet ? 'sheets' : 'sources';
tabKey = refObj.descriptions ? 'key-sources' : 'sources';
}
if (!tabs[tabKey]) {
let { title } = linkTypeObj;
if (tabKey === 'sheets') {
title = {en: 'Sheets', he: Sefaria._('Sheets')};
if (tabKey === 'key-sources') {
title = {en: 'Key Sources', he: Sefaria.translation('hebrew', 'Key Sources')};
}
if (tabKey === 'sources') {
title = {en: 'Sources', he: Sefaria._('Sources')};
title = {en: 'Sources', he: Sefaria.translation('hebrew', 'Sources')};
}
tabs[tabKey] = {
refMap: {},
title,
shouldDisplay: linkTypeObj.shouldDisplay,
};
}
console.log(refObj)
const ref = refObj.is_sheet ? parseInt(refObj.ref.replace('Sheet ', '')) : refObj.ref;
if (refObj.order) {
refObj.order = {...refObj.order, availableLangs: refObj?.order?.availableLangs || [],
Expand All @@ -2550,6 +2551,11 @@ _media: {},
tabObj.refs = Object.values(tabObj.refMap);
delete tabObj.refMap;
}

if (tabs["key-sources"]) {
tabs["sources"]["title"] = {en: 'All Sources', he: Sefaria.translation('hebrew', 'All Sources')};
}

data.tabs = tabs;
return data;
},
Expand Down
2 changes: 2 additions & 0 deletions static/js/sefaria/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ const Strings = {
"Merged from": "נוצר ממיזוג",
"Source" : "מקור",
"Sources": "מקורות",
"Key Sources": "מקורות מרכזיים",
"All Sources": "כל המקורות",
"Digitization" : "דיגיטציה",
"License" : "רשיון",
"Revision History" : "היסטורית עריכה",
Expand Down

0 comments on commit 33ad7a8

Please sign in to comment.