Skip to content

Commit

Permalink
Merge branch 'patch_for_normalized_dates' into normalizeddates
Browse files Browse the repository at this point in the history
  • Loading branch information
stevekaplan123 committed Sep 20, 2023
2 parents f9512cd + 40cd092 commit fb3a85a
Show file tree
Hide file tree
Showing 17 changed files with 497 additions and 121 deletions.
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use an official Python runtime as a parent image
FROM python:3.7-slim

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install psycopg2 dependencies
RUN apt-get update && apt-get install -y libpq-dev

# Install gcc
RUN apt-get update && apt-get install -y gcc

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org -r requirements.txt

# Make port 8000 available to the world outside this container
EXPOSE 8000

# Define environment variable
ENV NAME Sefaria-Project

# Run app.py when the container launches
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
80 changes: 80 additions & 0 deletions README.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,87 @@ First clone the Sefaria-Project repository to a directory on your computer, then
*Note for macOS users - Install `Homebrew`:*

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"


There are two methods with which you can run the Sefaria-Project, docker-compose and local install

#### Run with docker-compose
##### 1) Install Docker and Docker Compose

Follow the instructions [here](https://docs.docker.com/docker-for-mac/install/) to install Docker and [here](https://docs.docker.com/compose/install/) to install Docker Compose.

##### 2) Run the project
In your terminal run:

docker-compose up

This will build the project and run it. You should now have all the proper services set up, lets add some texts.

##### 3) Connect to mongo and add texts:
Connect to mongo running on port 27018. We use 27018 instead of the standard port 27017 to avoid conflicts with any mongo instance you may already have running.

Follow instructions in section 8 below to restore the mongo dump.


##### 4) Update your local settings file:
Copy the local settings file:

cp sefaria/local_settings_example.py sefaria/local_settings.py

Replace the following values:

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'sefaria',
'USER': 'admin',
'PASSWORD': 'admin',
'HOST': 'postgres',
'PORT': '',
}
}


MONGO_HOST = "db"

Optionally, you can replace the cache values as well:

MULTISERVER_REDIS_SERVER = "cache"
REDIS_HOST = "cache"

and the respective values in CACHES


##### 5) Connect to the django container and run migrations:
In a new terminal window run:

docker exec -it sefaria-project_web_1 bash

This will connect you to the django container. Now run:

python manage.py migrate

##### 6) Run webpack:
In a new terminal window run:

docker exec -it sefaria-project-node-1 bash

This will connect you to the django container. Now run:

npm run build-client

or

npm run watch-client


##### 7) Visit the site:
In your browser go to http://localhost:8000

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*
Expand Down
49 changes: 49 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: '3'

services:
web:
build: .
ports:
- "8000:8000"
volumes:
- .:/app
depends_on:
- db
- cache
- postgres

db:
image: "mongo:4.4"
ports:
- "27018:27017"
volumes:
- mongo-data:/data/db

cache:
image: "redis:latest"
ports:
- "6379:6379"

node:
image: "node:latest"
working_dir: /app
volumes:
- .:/app
command: npm start
ports:
- "3000:3000"

postgres:
image: "postgres:latest"
environment:
POSTGRES_USER: admin
POSTGRES_PASSWORD: admin
POSTGRES_DB: sefaria
ports:
- "5433:5432"
volumes:
- postgres-data:/var/lib/postgresql/sefaria_data

volumes:
mongo-data:
postgres-data:
1 change: 1 addition & 0 deletions reader/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3061,6 +3061,7 @@ def topic_page(request, topic, test_version=None):
"initialMenu": "topics",
"initialTopic": topic,
"initialTab": urllib.parse.unquote(request.GET.get('tab', 'sources')),
"initialTopicSort": urllib.parse.unquote(request.GET.get('sort', 'Relevance')),
"initialTopicTitle": {
"en": topic_obj.get_primary_title('en'),
"he": topic_obj.get_primary_title('he')
Expand Down
3 changes: 0 additions & 3 deletions sefaria/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@
# Make this unique, and don't share it with anybody.
SECRET_KEY = ''

STRAPI_LOCATION = 'https://credible-basketball-a14e66cd27.strapiapp.com'
STRAPI_PORT = 443

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
Expand Down
22 changes: 21 additions & 1 deletion static/css/s2.css
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,8 @@ div.interfaceLinks-row a {
color: inherit;
cursor: pointer;
}
.navSidebar a.inTextLink {
.navSidebar a.inTextLink,
.translationsDesc a.inTextLink {
color: inherit;
text-decoration: underline;
margin-inline-start: 5px;
Expand Down Expand Up @@ -8413,6 +8414,25 @@ h3.aboutSheetHeader {
border-width: 1px;
}

.translationsHeader {
margin-bottom: 35px;
}

.translationsHeader h3 {
text-transform: none;
color: var(--dark-grey);
font-size: var(--sans-serif-h3-font-size);
--english-font: var(--english-sans-serif-font-family);
--hebrew-font: var(--hebrew-sans-serif-font-family);
margin-bottom: 12px;
margin-top: 0;
}

.translationsHeader .translationsDesc {
font-size: var(--sans-serif-body-font-size);
color: var(--dark-grey);
}

.aboutSheetPanel hr {
height: 0px;
border: 1px solid var(--light-grey);
Expand Down
37 changes: 32 additions & 5 deletions static/js/Misc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,41 @@ ProfilePic.propTypes = {
};


/**
* Renders a list of data that can be filtered and sorted
* @param filterFunc
* @param sortFunc
* @param renderItem
* @param sortOptions
* @param getData
* @param data
* @param renderEmptyList
* @param renderHeader
* @param renderFooter
* @param showFilterHeader
* @param refreshData
* @param initialFilter
* @param scrollableElement
* @param pageSize
* @param onDisplayedDataChange
* @param initialRenderSize
* @param bottomMargin
* @param containerClass
* @param onSetSort: optional. function that is passed the current sort option when the user changes it. Use this to control sort from outside the component. See `externalSortOption`.
* @param externalSortOption: optional. string that is one of the options in `sortOptions`. Use this to control sort from outside the component. See `onSetSort`.
* @returns {JSX.Element}
* @constructor
*/
const FilterableList = ({
filterFunc, sortFunc, renderItem, sortOptions, getData, data, renderEmptyList,
renderHeader, renderFooter, showFilterHeader, refreshData, initialFilter,
scrollableElement, pageSize, onDisplayedDataChange, initialRenderSize,
bottomMargin, containerClass
bottomMargin, containerClass, onSetSort, externalSortOption,
}) => {
const [filter, setFilter] = useState(initialFilter || '');
const [sortOption, setSortOption] = useState(sortOptions[0]);
const [internalSortOption, setSortOption] = useState(sortOptions[0]);
const [displaySort, setDisplaySort] = useState(false);
const sortOption = externalSortOption || internalSortOption;

// Apply filter and sort to the raw data
const processData = rawData => rawData ? rawData
Expand Down Expand Up @@ -420,10 +446,11 @@ const FilterableList = ({
}, [dataUpToPage]);
}

const onSortChange = newSortOption => {
const setSort = newSortOption => {
if (newSortOption === sortOption) { return; }
setSortOption(newSortOption);
setDisplaySort(false);
onSetSort?.(newSortOption);
};

const oldDesign = typeof showFilterHeader == 'undefined';
Expand Down Expand Up @@ -453,7 +480,7 @@ const FilterableList = ({
isOpen={displaySort}
options={sortOptions.map(option => ({type: option, name: option, heName: Sefaria._(option, "FilterableList")}))}
currOptionSelected={sortOption}
handleClick={onSortChange}
handleClick={setSort}
/>
</DropdownModal>
: null
Expand All @@ -480,7 +507,7 @@ const FilterableList = ({
<span
key={option}
className={classNames({'sans-serif': 1, 'sort-option': 1, noselect: 1, active: sortOption === option})}
onClick={() => onSortChange(option)}
onClick={() => setSort(option)}
>
<InterfaceText context="FilterableList">{option}</InterfaceText>
</span>
Expand Down
2 changes: 1 addition & 1 deletion static/js/Promotions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const Promotions = () => {
title: title,
bodyText: bodyText,
buttonText: buttonText,
buttonUrl: buttonURL,
buttonURL: buttonURL,
buttonIcon: sidebarAd.buttonIcon,
buttonLocation: sidebarAd.buttonAboveOrBelow,
hasBlueBackground: sidebarAd.hasBlueBackground,
Expand Down
8 changes: 6 additions & 2 deletions static/js/ReaderApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class ReaderApp extends Component {
searchQuery: props.initialQuery,
searchTab: props.initialSearchTab,
tab: props.initialTab,
topicSort: props.initialTopicSort,
textSearchState: new SearchState({
type: 'text',
appliedFilters: props.initialTextSearchFilters,
Expand Down Expand Up @@ -167,6 +168,7 @@ class ReaderApp extends Component {
textHighlights: state.textHighlights || null,
profile: state.profile || null,
tab: state.tab || null,
topicSort: state.topicSort || null,
webPagesFilter: state.webPagesFilter || null,
sideScrollPosition: state.sideScrollPosition || null,
topicTestVersion: state.topicTestVersion || null
Expand Down Expand Up @@ -386,6 +388,7 @@ class ReaderApp extends Component {
(prev.searchQuery != next.searchQuery) ||
(prev.searchTab != next.searchTab) ||
(prev.tab !== next.tab) ||
(prev.topicSort !== next.topicSort) ||
(prev.collectionName !== next.collectionName) ||
(prev.collectionTag !== next.collectionTag) ||
(!prevTextSearchState.isEqual({ other: nextTextSearchState, fields: ["appliedFilters", "field", "sortType"]})) ||
Expand Down Expand Up @@ -479,6 +482,7 @@ class ReaderApp extends Component {
case "topics":
if (state.navigationTopic) {
hist.url = state.topicTestVersion ? `topics/${state.topicTestVersion}/${state.navigationTopic}` : `topics/${state.navigationTopic}`;
hist.url = hist.url + (state.topicSort ? `&sort=${state.topicSort}` : '');
hist.title = `${state.topicTitle[shortLang]} | ${ Sefaria._("Texts & Source Sheets from Torah, Talmud and Sefaria's library of Jewish sources.")}`;
hist.mode = "topic";
} else if (state.navigationTopicCategory) {
Expand Down Expand Up @@ -2068,7 +2072,7 @@ toggleSignUpModal(modalContentKind = SignUpModalKind.Default) {
var updateSearchFilter = this.updateSearchFilter.bind(null, i);
var updateSearchOptionField = this.updateSearchOptionField.bind(null, i);
var updateSearchOptionSort = this.updateSearchOptionSort.bind(null, i);
var onOpenConnectionsClick = this.openTextListAt.bind(null, i+1);
var openConnectionsPanel = this.openTextListAt.bind(null, i+1);
var setTextListHighlight = this.setTextListHighlight.bind(null, i);
var setSelectedWords = this.setSelectedWords.bind(null, i);
var clearSelectedWords = this.clearSelectedWords.bind(null, i);
Expand Down Expand Up @@ -2107,7 +2111,7 @@ toggleSignUpModal(modalContentKind = SignUpModalKind.Default) {
onSearchResultClick={onSearchResultClick}
onSidebarSearchClick={onSidebarSearchClick}
onNavigationClick={this.handleNavigationClick}
onOpenConnectionsClick={onOpenConnectionsClick}
openConnectionsPanel={openConnectionsPanel}
openComparePanel={openComparePanel}
setTextListHighlight={setTextListHighlight}
setConnectionsFilter={setConnectionsFilter}
Expand Down
Loading

0 comments on commit fb3a85a

Please sign in to comment.