Skip to content

Commit

Permalink
Merge remote-tracking branch 'local/jmc_aug31'
Browse files Browse the repository at this point in the history
  • Loading branch information
stevekaplan123 committed Oct 25, 2023
2 parents 2106569 + 5b6c669 commit bb55f6f
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ If the server isn't running, you may need to run `docker-compose up` again.
#### Run locally
#### 1) Install Python 3.7

*We Recommend using the latest Python 3.7 as opposed to later versions of Python (esp 3.10 and up) since it has been known to cause some compatability issues. These are solvable, but for an easier install experience, we currently recommend 3.7*
*We Recommend using the latest Python 3.7 as opposed to later versions of Python (esp 3.10 and up) since it has been known to cause some compatibility issues. These are solvable, but for an easier install experience, we currently recommend 3.7*

###### Linux and macOS
Most UNIX systems come with a python interpreter pre-installed. However, this is generally still Python 2. The recommended way to get Python 3, and not mess up any software the OS is dependent on, is by using Pyenv. You can use the instructions [here](https://github.com/pyenv/pyenv#installation) and also [here](https://opensource.com/article/19/5/python-3-default-mac#what-we-should-do).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ data:
DB_NAME=$SEFARIA_DB
{{ end }}
URI="${URI}${MONGO_HOST}/${DATABASE}?ssl=false&authSource=admin"
APSCHEDULER_URI="${URI}${MONGO_HOST}/${APSCHEDULER_NAME}?ssl=false&authSource=admin"
URI="${URI}${MONGO_HOST}/${DATABASE}?ssl=false&authSource=admin"
if [[ ! -z "$MONGO_REPLICASET_NAME" ]]; then
URI="${URI}&replicaSet=${MONGO_REPLICASET_NAME}"
Expand Down
5 changes: 3 additions & 2 deletions reader/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,9 @@ def search(request):
desc = _("Search 3,000 years of Jewish texts in Hebrew and English translation.") if SITE_SETTINGS["TORAH_SPECIFIC"] else _("Search")

return render_template(request,'base.html', props, {
"title": (search_params["query"] + " | " if search_params["query"] else "") + _(SITE_SETTINGS["SITE_NAME"]["en"]+" Search"),
"desc": desc
"title": (search_params["query"] + " | " if search_params["query"] else "") + _(SITE_SETTINGS["SITE_NAME"]["en"],
"desc": desc,
"noindex": True
})


Expand Down
47 changes: 25 additions & 22 deletions sefaria/helper/topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def merge_props_for_similar_refs(curr_link, new_link):
# as well as datasource and descriptions of all the similar refs
data_source = new_link.get('dataSource', None)
if data_source:
curr_link = update_refs(curr_link, new_link, data_source)
curr_link = update_refs(curr_link, new_link)
curr_link = update_data_source_in_link(curr_link, new_link, data_source)

if not curr_link['is_sheet']:
Expand All @@ -128,20 +128,9 @@ def update_data_source_in_link(curr_link, new_link, data_source):
del new_link['dataSource']
return curr_link

def is_data_source_learning_team(func):
def wrapper(curr_link, new_link, data_source):
if data_source == 'learning-team':
return func(curr_link, new_link)
else:
return curr_link
return wrapper

@is_data_source_learning_team
def update_refs(curr_link, new_link):
# in case the new_link was created by the learning team, we want to use ref of learning team link
# in the case when both links are from the learning team, use whichever ref covers a smaller range
if 'learning-team' not in curr_link['dataSources'] or len(curr_link['expandedRefs']) > len(
new_link['expandedRefs']):
# use whichever ref covers a smaller range
if len(curr_link['expandedRefs']) > len(new_link['expandedRefs']):
curr_link['ref'] = new_link['ref']
curr_link['expandedRefs'] = new_link['expandedRefs']
return curr_link
Expand Down Expand Up @@ -171,18 +160,32 @@ def update_curated_primacy(curr_link, new_link):
curr_link['order']['curatedPrimacy'] = curr_curated_primacy
return curr_link

def is_learning_team(dataSource):
return dataSource == 'learning-team' or dataSource == 'learning-team-editing-tool'

def iterate_and_merge(new_ref_links, new_link, subset_ref_map, temp_subset_refs):
# temp_subset_refs contains the refs within link's expandedRefs that overlap with other refs
# subset_ref_map + new_ref_links contain mappings to get from the temp_subset_refs to the actual link objects
for seg_ref in temp_subset_refs:
for index in subset_ref_map[seg_ref]:
new_ref_links[index]['similarRefs'] += [new_link]
curr_link_learning_team = any([is_learning_team(dataSource) for dataSource in new_ref_links[index]['dataSources']])
if not curr_link_learning_team: # if learning team, ignore source with overlapping refs
new_ref_links[index] = merge_props_for_similar_refs(new_ref_links[index], new_link)
return new_ref_links

def sort_and_group_similar_refs(ref_links):
ref_links.sort(key=cmp_to_key(sort_refs_by_relevance))
subset_ref_map = defaultdict(list)
new_ref_links = []
for link in ref_links:
del link['topic']
temp_subset_refs = subset_ref_map.keys() & set(link.get('expandedRefs', []))
for seg_ref in temp_subset_refs:
for index in subset_ref_map[seg_ref]:
new_ref_links[index]['similarRefs'] += [link]
new_ref_links[index] = merge_props_for_similar_refs(new_ref_links[index], link)
if len(temp_subset_refs) == 0:
new_data_source = link.get("dataSource", None)
should_merge = len(temp_subset_refs) > 0 and not is_learning_team(new_data_source) # learning team links should be handled separately from one another and not merged
if should_merge:
new_ref_links = iterate_and_merge(new_ref_links, link, subset_ref_map, temp_subset_refs)
else:
link['similarRefs'] = []
link['dataSources'] = {}
if link.get('dataSource', None):
Expand Down Expand Up @@ -1250,12 +1253,12 @@ def delete_ref_topic_link(tref, to_topic, link_type, lang):
if link is None:
return {"error": f"Link between {tref} and {to_topic} doesn't exist."}

if lang in link.order['availableLangs']:
if lang in link.order.get('availableLangs', []):
link.order['availableLangs'].remove(lang)
if lang in link.order['curatedPrimacy']:
if lang in link.order.get('curatedPrimacy', []):
link.order['curatedPrimacy'].pop(lang)

if len(link.order['availableLangs']) > 0:
if len(link.order.get('availableLangs', [])) > 0:
link.save()
return {"status": "ok"}
else: # deleted in both hebrew and english so delete link object
Expand Down
6 changes: 6 additions & 0 deletions sefaria/model/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,12 @@ def _validate(self):
if not Category().load({"path": self.categories}):
raise InputError("You must create category {} before adding texts to it.".format("/".join(self.categories)))

for date_key in ['compDate', 'pubDate']:
if hasattr(self, date_key):
val = getattr(self, date_key)
if not isinstance(val, list) or not all([isinstance(x, int) for x in val]):
raise InputError(f"Optional attribute '{date_key}' must be list of integers.")

'''
for cat in self.categories:
if not hebrew_term(cat):
Expand Down
5 changes: 3 additions & 2 deletions sefaria/model/topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,9 @@ def annotate_place(self, d):
if place and heKey not in properties:
value, dataSource = place['value'], place['dataSource']
place_obj = Place().load({"key": value})
name = place_obj.primary_name('he')
d['properties'][heKey] = {'value': name, 'dataSource': dataSource}
if place_obj:
name = place_obj.primary_name('he')
d['properties'][heKey] = {'value': name, 'dataSource': dataSource}
return d

def contents(self, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion static/js/CategoryEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Reorder = ({subcategoriesAndBooks, updateOrder, displayType, updateParentC
const clickHandler = (dir, child) => {
const index = subcategoriesAndBooks.indexOf(child);
let index_to_swap = -1;
if (dir === 'down' && index < subcategoriesAndBooks.length)
if (dir === 'down' && index < subcategoriesAndBooks.length - 1)
{
index_to_swap = index + 1;
}
Expand Down
9 changes: 7 additions & 2 deletions static/js/NavSidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,13 @@ const AboutTopics = ({hideTitle}) => (
<Module>
{hideTitle ? null :
<ModuleTitle>About Topics</ModuleTitle> }
<InterfaceText>Topics bring you straight to selections of texts and user created source sheets about thousands of subjects.</InterfaceText>

<InterfaceText>
<HebrewText>
דפי הנושא מציגים מקורות נבחרים מארון הספרים היהודי עבור אלפי נושאים. ניתן לדפדף לפי קטגוריה או לחפש לפי נושא ספציפי, ובסרגל הצד מוצגים הנושאים הפופולריים ביותר ואלה הקשורים אליהם. הקליקו ושוטטו בין הנושאים השונים כדי ללמוד עוד.
</HebrewText>
<EnglishText>
Topics bring you straight to selections of texts and user created source sheets about thousands of subjects. </EnglishText>
</InterfaceText>
</Module>
);

Expand Down
23 changes: 12 additions & 11 deletions templates/static/jobs.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1 class="serif">
</h1>

<!-- Comment out when jobs page has no content -->
<!-- <h2>
<h2>
<span class="int-en">About Sefaria</span>
<span class="int-he">אודות ספריא</span>
</h2>
Expand All @@ -31,7 +31,7 @@ <h1 class="serif">
ספריא היא ארגון ללא מטרות רווח שמטרתו יצירת הדור הבא של לימוד התורה באופן פתוח ומשותף.
אנחנו בספריא מרכיבים ספרייה חיה וחופשית של טקסטים יהודיים וכלל הקישורים ביניהם, בשפת המקור ובתרגומים.
</span>
</p> -->
</p>
<!-- Comment out when jobs page has no content -->
</header>

Expand All @@ -52,12 +52,13 @@ <h2 class="anchorable">Engineering</h2>
<section class="jobsListForDepartment">
</section>
</section>
<section class="section department englishOnly">
<section class="section department englishOnly">
<header>
<h2 class="anchorable">Marketing and Communications</h2>
<h2 class="anchorable">Learning</h2>
</header>
<section class="jobsListForDepartment">
<div class="job"><a class="" target="_blank" href=""></a></div>
<div class="job"><a class="jobLink" target="_blank" href=""></a></div>
<div class="job"><a class="jobLink" target="_blank" href=""></a></div>
</section>
</section>
<section class="section department englishOnly">
Expand All @@ -68,19 +69,19 @@ <h2 class="anchorable">HR and Operations</h2>
<div class="job"><a class="" target="_blank" href=""></a></div>
</section>
</section> -->

<section class="section department englishOnly">
<header>
<h2 class="anchorable">Learning</h2>
<h2 class="anchorable">Marketing and Communications</h2>
</header>
<section class="jobsListForDepartment">
<div class="job"><a class="jobLink" target="_blank" href="https://sefaria.breezy.hr/p/c693c3ab1b78-hebrew-editorial-associate-part-time">Hebrew Editorial Associate (Part-Time)</a></div>
<div class="job"><a class="jobLink" target="_blank" href="https://docs.google.com/document/d/107rwA4LuShD-szPmYJfKqyqxxU6Ycnj2KWqEUEc9GoU/edit#heading=h.hqg5tv31xe3k">English Editorial Associate (Contractor)</a></div>

<div class="job"><a class="joblink" target="_blank" href="https://sefaria.breezy.hr/p/b11c89877ad6-communications-specialist?state=published">Communications Specialist</a></div>
</section>
</section>



</section>
</section>

<!--
<section class="section department englishOnly">
<header>
Expand Down

0 comments on commit bb55f6f

Please sign in to comment.