Clusive can be installed in several ways, either as a standalone server or a Docker container. To try it out quickly using Docker skip ahead to that section.
Note: all steps between Create/Activitate Virtual Environment and Create a Superuser can be run using local_install.sh
(on Unix-based systems) or local_install.ps1
(on Windows) to more easily set up or refresh a local environment. Be sure to set up your virtual environment first.
- Python 3
- Version 3.7.4 up to 3.9. (3.10+ not tested yet). On Mac, Homebrew is the easiest way to install.
- [Django 3]
- Version 3.2.14+, installed with other Python dependencies as documented in section Install Python Dependencies.
- virtualenv
- Not required, but highly recommended for maintaining an isolated environment and dependencies.
- Postgres
- Version 11.5 or later. Used in the deployment configuration.
- Node.js
Clone the Clusive repository to your local machine and check out the appropriate branch. Note that there are currently no released versions.
- master branch - the most stable version
- development branch - the latest code changes
Always activate and use the python virtual environment to maintain an isolated environment for Clusive's dependencies.
-
Create the virtual environment (one time setup):
python -m venv ENV
- Or do this via your IDE, e.g. Intellij's support for virtualenv
-
Activate (every command-line session):
- Windows:
.\ENV\Scripts\activate
- Mac/Linux:
source ENV/bin/activate
- Windows:
Run in the Clusive directory:
npm install
grunt build
- Use the noclean option to preserve data on subsequent builds:
grunt build-noclean
This creates the compiled, runnable server in the Clusive/target directory.
- Use the noclean option to preserve data on subsequent builds:
- Front-end JS libraries are combined with Webpack and end up in
shared\static\shared\js\lib\main.js
- Front-end assets for Infusion and Figuration (CSS, etc) are copied to
shared\static\shared\js\lib\
in their own directories - The Django template at
shared\templates\shared\base.html
sets a Javascript global calledDJANGO_STATIC_ROOT
for the use of client-side Javascript needing to construct references to static content
Run in the Clusive directory:
pip install -r requirements.txt
- If necessary, refer to these possible solutions for psycopg2 library issues on Mac
- For instance, as suggested in the answers on that page, you might need to use:
LDFLAGS="-L/usr/local/opt/openssl/lib" pip install -r requirements.txt
Run in the Clusive directory:
python -m nltk.downloader wordnet
- possible solutions for certificate issues on Mac
The local development configuration uses sqlite, so no database setup is required.
To initialize the schema and initial data, run in the Clusive\target directory:
python manage.py migrate
python manage.py loaddata preferencesets tiptypes callstoaction subjects
There are a number of learning materials ready for import in the Clusive\content directory.
For each one that you want to make available, run a command like this in the Clusive\target directory:
python manage.py import ..\content\cast-lexington\*
You can also import the entire content
directory in one go:
python manage.py importdir ..\content
The import
command can be used to import a single EPUB file,
or multiple files which are considered to be a set of leveled versions
of the same content. A glossary JSON file and directory of images that
it refers to can also be included on the command line.
The content directory contains many examples of these.
Run in the Clusive\target directory:
python manage.py createsuperuser
Run in the Clusive\target directory:
python manage.py runserver
- Verify Clusive login page: http://localhost:8000
- Verify Clusive admin site with the superuser login: http://localhost:8000/admin/
grunt watch:devRebuild
can be used to watch thesrc
directory and run the build totarget
again on changes, reducing the need to manually run the build while working locally
In the Clusive directory, build the Docker image:
docker build . -t clusive
Or, in the command lines below, you can use the pre-built castudl/clusive
image from Docker Hub.
Run with local development settings (creates an empty sqlite database at each run):
docker run -e DJANGO_CONFIG=local -p 8000:8000 clusive
Run with production settings and Postgres database (note: the production settings require HTTPS):
docker run -p 8000:8000 \\
-e DJANGO_CONFIG=prod -e DJANGO_SECRET_KEY=<key> \\
-e DJANGO_DB_HOST=<host> -e DJANGO_DB_NAME=<name> \\
-e DJANGO_DB_USER=<user> -e DJANGO_DB_PASSWORD=<password> \\
clusive
Docker will run any pending database migrations and import the default books at startup, but users must be added manually:
docker exec -it <container_id> python manage.py createsuperuser
- Run the standard local install. This will install Cypress as a dev dependency.
- In the Clusive\target directory, run
python manage.py createrostersamples
if you have not already. The tests depend on logging in as one of these test users. - Run
npx cypress open
from the root to interactively run the tests. - For IntelliJ users, the "Cypress Support" plugin is helpful.
To allow users to log in with their Google account, there are several additional steps.
- Create a Project in the Google Cloud Console.
- Enable the Google Classroom API
- Configure the authentication on the "OAuth Consent Screen" page in the "APIs and Services" section of the Console. The "EDIT APP" link at the top of the "OAuth Consent Screen" provides an "Edit app registration" step-by-step process for filling in the information.
- Required scopes (step 2 of the "Edit app registration"):
auth/userinfo.email
auth/userinfo.profile
auth/classroom.courses.readonly
auth/classroom.rosters.readonly
auth/classroom.profile.emails
- Create an "OAuth client ID" on the "Credentials" page, which is also in the
"APIs and Services" section of the Console.
- Application type is "Web application"
- Authorized JavaScript origins should be the URL of your instance, eg
https://clusive.cast.org
. - Authorized redirect URIs should list two URIs: your instance with the paths '/accounts/google/login/callback/' and '/account/add_scope_callback/',
eg
https://clusive.cast.org/accounts/google/login/callback/
https://clusive.cast.org/account/add_scope_callback/
- When created, take note of the Client ID and Client Secret.
- Add the Google "provider" to Clusive as documented for the Django-allauth module. There are a few different ways to do this. The manual method is as follows:
- Log in to your instance as an administrator.
- Go to "Social Applications", click Add, and set:
- provider: Google
- name: Google
- Client id: from step 5, above.
- Secret key: "Client Secret" from step 5.
- Key: leave blank.
- Chosen sites: add the default site (if you haven't changed anything, this will be called "example.com" and have ID=1).
- Set up the "Sites" record
- This is the record for the default site chosen in the previous step, initially called "example.com".
- Go to the top-level "Sites" and choose "example.com".
- Set the
Domain Name
field to:- "localhost:8000", if this setup is for local development, and you are running Clusive on "localhost" and using port 8000. Note that the domain name must match the actual domain name exactly. That is, if the server is using "localhost", do not specify "127.0.0.1" for the domain name in the Sites record.
- In general, the
Domain Name
must match the host and port of your Clusive server. For example, if the server is running on "clusive.abcxyz.org" (no port), then use that for theDomain Name
.
- You can change the
Display Name
from "example.com" to something more meaningful to your situation, but it does not really matter.
Optional. In order to allow users to download books from their Bookshare accounts, you would need to obtain a Bookshare API key from Benetech. If you have one, in Clusive's admin interface, go to "Social Applications", click Add, and set:
- Provider: Bookshare
- Name: bookshare
- Client ID: your API key
- Sites: add your site
Optional. A fallback to a custom dictionary entry includes definitions from the Merriam-Webster
Intermediate Dictionary. To use Merriam-Webster your installation must apply for a Merriam-Webster
API key directly from Merriam Webster.
The API key must be supplied into the settings file variable MERRIAM_WEBSTER_API_KEY.
Optional. Mailchimp has been integrated to communicate via email with users of the application. To connect with Mailchimp the API key, the server, and the email list must be provided. These fields are supplied into the settings file as the variables: MAILCHIMP_API_KEY, MAILCHIMP_SERVER, and MAILCHIMP_EMAIL_LIST_ID.