MathHubInfo / Frontend

A new MathHub Narration Frontend written in React.
GNU Affero General Public License v3.0
2 stars 0 forks source link

MathHub-Frontend

Build Status DockerHub Status

A new MathHub Frontend written with Typescript in React and Next.js.

For Users

This is the source code for the MathHub Frontend.

The MathHub Frontend exists in two different versions:

The MathHub Frontend is backed by an MMT instance.

MathHub Releases

Because of this backing by an MMT instance, MathHub release cycles are coupled to their MMT counterparts.

In particular, because MMT aims for releases every 6 weeks, the MathHub Frontend does the same.

In a nutshell, the major version number is that of the MMT release, the minor number is used for MathHub-internal purposes.

This also means that http://mathhub.info will get a new release (and functionality update) about every six weeks following the MMT release schedule.

Supported browsers

We support the following browsers:

Developers can see a concrete list of supported browsers by running:

    yarn browserslist

For Deployers

The Frontend is best deployed using the MathHub System deployment.

However it is also possible to deploy it stand-alone.

Deployment using Docker

To easily deploy an instance of the frontend, a Dockerfile is available. It serves a server instance of this app. This takes all the variables above as build arguments. In particular, the UPSTREAM_BASE_URL should be set accordingly.

The Docker Image is available on DockerHub as mathhub/frontend. The image is built using automated builds, and automatically updates afer every commit.

To run it, use something like:

docker run -p 8043:8043 mathhub/frontend

For Developers

We use yarn, which we assume in the following is installed.


# install dependencies (needed once, or whenever new dependencies
# are added
yarn

# To build a complete distribution for production use the following
# command. This will internally split into the three commands below.
yarn dist

# When generating a distribution, it is required
# to run the following to generate notices.txt file for license 
# information of *external* dependencies
yarn mklegal

# run babel, i.e. compile and compress the source into the .next/
# folder. Afterwards it is possible to run `yarn start`.
yarn build

# To run code for local development several commands exist
# skip to the end to see the import bits

# run a local webserver for development on localhost:3000
# this takes a couple seconds to start up and will afterwards
# automatically re-compile the project when any of the files
# under src/ are changed. 
# It is recommended to use Chrome + React DevTools extension
# for a proper debugging interface
yarn dev

# By default the webpack-dev-server expects a corresponding API
# to run on http://localhost:9000/:mathhub/. 
# This URL can be changed using the LIBRARY_URL variable, e.g. like so:
yarn cross-env LIBRARY_URL=https://mmt.mathhub.info/:mathhub/ dev

# Furthermore, in case no MMT is running, a Mock Client exists during development. 
# This can be enabled like so:
yarn cross-env LIBRARY_URL= dev

# For convenience two shortcuts exist:
yarn devmock
yarn devmmt

# both start the dev server on port 3000. 
# the first command uses a mocked mmt instance, the second one
# uses a real mmt expected to be at localhost:8080

# running a production server on port 3000 (needs yarn build)
yarn start

As an IDE, it is recommended to use Visual Studio Code (>= May 2018 (version 1.24)) along with the ESLint Plugin.

Both should work out-of-the-box after cloning this repository and running the yarn command above.

File Structure

This repository conists of the following structure:

And the following un-committed folders that are generated automatically:

For Developers

Environment Variables

The MathHub Frontend takes several environment variables, which can be used to fine-tune the behaviour of the frontend. Environment variables are set at compilation time of the code and can not be changed during runtime. They are read inside of next.config.js.

The supported variables are:

Testing

This project has minimal CI tests using GitHub Actions.

These check that the project compiles in both production and non-production configurations.

License & Acknowledgements

The Code in this project is licensed under AGPL 3.0.