Web editor for P5.js, modified for workshops at Digital Playground.
Find a file
2018-08-27 17:59:09 -04:00
.github move github files to .github folder, delete useless server config, get development Docker build working 2018-06-18 14:30:10 -07:00
client for simplicity and security, remove redirect to HTTP and keep everything on HTTPS 2018-08-27 14:37:31 -04:00
kubernetes load client-side environment variables at runtime 2018-08-24 17:41:23 -04:00
mongo fix Dockerfile and docker-compose.yml so that image will hopefully build correctly on travis 2018-08-10 17:11:04 -04:00
server load client-side environment variables at runtime 2018-08-24 17:41:23 -04:00
.babelrc update babel packages 2018-05-08 19:16:04 -07:00
.env.example start to add mongo configuration 2018-06-25 16:13:31 -07:00
.eslintignore start to add eslint, add repository to package.json 2016-06-22 19:59:12 -04:00
.eslintrc fix many linting errors 2018-05-08 19:16:04 -07:00
.gitignore for simplicity and security, remove redirect to HTTP and keep everything on HTTPS 2018-08-27 14:37:31 -04:00
.travis.yml i have no idea why travis isn't running my deploy script 2018-08-27 17:59:09 -04:00
backup.sh fix fetch example scripts, add webpack config to build fetch script bundles 2018-06-18 14:32:09 -07:00
deploy.sh does this fix the travis deployment???? 2018-08-27 17:42:58 -04:00
docker-compose-development.yml try building docker images in development first for linting 2018-06-20 10:01:11 -07:00
docker-compose.yml try updating travis to have deploy script 2018-08-27 17:30:34 -04:00
Dockerfile add args to Dockerfile 2018-08-13 16:40:51 -04:00
Dockerfile-development start production docker configuration 2018-06-18 14:30:11 -07:00
ecosystem.json more changes to get dockerization working 2018-06-18 14:30:11 -07:00
index.js change Dockerfile to fix environment variables and fetching examples 2018-06-18 14:32:09 -07:00
LICENSE add license 2017-10-15 22:36:46 -07:00
nodemon.json add nodemon, remove .env from being tracked 2016-06-22 18:48:45 -04:00
package-lock.json add basic auth to server for beta editor setup 2018-08-21 16:09:41 -04:00
package.json add basic auth to server for beta editor setup 2018-08-21 16:09:41 -04:00
README.md try building docker images in development first for linting 2018-06-20 10:01:11 -07:00
webpack.config.babel.js Improve current console (#656) 2018-07-30 12:20:57 -04:00
webpack.config.dev.js load client-side environment variables at runtime 2018-08-24 17:41:23 -04:00
webpack.config.examples.js fix fetch example scripts, add webpack config to build fetch script bundles 2018-06-18 14:32:09 -07:00
webpack.config.prod.js load client-side environment variables at runtime 2018-08-24 17:41:23 -04:00
webpack.config.server.js update babel packages 2018-05-08 19:16:04 -07:00

p5.js Web Editor

This project is currently in development! It will be announced when there is a (public) beta release.

Development Installation

  1. Fork this repository.
  2. Clone the forked repository and cd into it
  3. $ npm install
  4. Install MongoDB and make sure it is running
  5. $ cp .env.example .env
  6. (Optional) Update .env with necessary keys to enable certain app behavoirs, i.e. add Github ID and Github Secret if you want to be able to log in with Github.
  7. $ npm run fetch-examples - this downloads the example sketches into a user called 'p5'
  8. $ npm start
  9. Navigate to http://localhost:8000 in your browser
  10. Install the React Developer Tools
  11. Open and close the Redux DevTools using ctrl+h, and move them with ctrl+w

Testing SSL on your local machine

Please refer to this gist. This allows you to access the editor using both HTTP and HTTPS. Don't worry about this unless you need to make changes or test HTTPS behavior.

The automatic redirection to HTTPS is turned off by default in development. If you need to test this behavior, put FORCE_TO_HTTPS=true in your .env file.

Development Installation using Docker

Using Docker, you can have a complete, consistent development environment without having to manually install dependencies such as Node, Mongo, etc. It also helps isolate these dependencies and their data from other projects that you may have on the same computer that use different/conflicting versions, etc.

Note that this takes up a significant amount of space on your machine. Make sure you have at least 5GB free.

  1. Install Docker for your operating system
  2. Clone this repository and cd into it
  3. $ docker-compose -f docker-compose-development.yml build
  4. $ docker-compose -f docker-compose-development.yml run --rm app npm run fetch-examples

Now, anytime you wish to start the server with its dependencies, you can run:

  1. $ docker-compose -f docker-compose-development.yml up
  2. Navigate to http://localhost:8000 in your browser

To open a terminal/shell in the running Docker server (i.e. after docker-compose up has been run):

  1. $ docker-compose -f docker-compose-development.yml exec app bash -l

If you don't have the full server environment running, you can launch a one-off container instance (and have it automatically deleted after you're done using it):

  1. $ docker-compose -f docker-compose-development.yml run app --rm bash -l

Production Installation

  1. Clone this repository and cd into it
  2. $ npm install
  3. Install MongoDB and make sure it is running
  4. $ cp .env.example .env
  5. (NOT Optional) edit .env and fill in all necessart values.
  6. $ npm run fetch-examples - this downloads the example sketches into a user called 'p5'
  7. $ npm run build
  8. $ npm run start:prod

For Production Setup with PM2

  1. $ npm install -g pm2
  2. $ pm2 start ecosystem.json

S3 Bucket Configuration

Please refer to the folllowing gist to set up an S3 bucket to be used with this project.

If your S3 bucket is in the US East (N Virginia) region (us-east-1), you'll need to set a custom URL base for it, because it does not follow the standard naming pattern as the rest of the regions. Instead, add the following to your environment/.env file:

S3_BUCKET_URL_BASE=https://s3.amazonaws.com

If you've configured your S3 bucket and DNS records to use a custom domain name, you can also set it using this variable. I.e.:

S3_BUCKET_URL_BASE=https://files.mydomain.com

For more information on using a custom domain, see this documentation link:

http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#VirtualHostingCustomURLs

Accessibility Guidelines

Here is guide on how to use the accessible editor and here is an overview of the p5-accessibility.js library that makes p5.js sketches accessible to screen readers.

The code for the p5.js web editor adheres to web accessibility standards. The following guidelines will help to ensure that accessibility continues to be a priority as development continues.

Code Structure

  • Screen Readers are an assistive technology for vision loss which helps users to navigate a web page. They are able to prioritize content based on the semantic meaning of HTML tags. Therefore, it is important to use specific tags, such as nav, ul, li, section, and so on. div is the least screen reader friendly tag. For example, here is the semantic meaning of the body tag
  • All buttons/links/windows need to be accessible by the keyboard ( By tabbing, pressing space etc.)
  • In cases where tags are not screen reader friendly, we can take advantage of tabIndex. Using tabIndex ensures that all elements are accessible via keyboard. code example
  • When opening a new window or pop up window, ensure the keyboard focus also moves to the new window. code example

Labeling

  • When creating button icons, images, or something without text (this does not include an HTML5 <button>), use aria-labels. code example
  • All <table>s need to have a summary attribute. This will ensure user is given context to what the table is. code example
  • uls and navs menus need to include a title. code example

For more information on accessibility see the teach access tutorial

Contributing

See CONTRIBUTING.md.

Tooling and Style Overview

The p5.js Web Editor is built on a MERN stack - MongoDB, Express, React/Redux, and Node. For a reference to the file structure format I am using, please look at the Mern Starter and this comment.

This project uses an in-development p5-accessibility.js library for accessibility.

This project does not use CSS Modules, but uses Sass. I like to follow BEM rules for CSS naming conventions, write OOSCSS with placeholders and mixins, and follow the 7-1 Pattern for Sass.

I'm using ES6 and transpiling to ES5 using Babel. For reference to the JavaScript style guide, see the Airbnb Style Guide, React ESLint Plugin.

The ESLint configuration is based on a few popular React/Redux boilerplates. Open to suggestions on this. If in development, you're getting annoyed with ESLint, you can remove it from webpack.config.dev.js in the JavaScript loader, or disable any line from eslint by commenting at the end of the line // eslint-disable-line.

AWS information

This project is currently hosted on an EC2 instance and uses S3 for media hosting.

Backups on the MongoDB are also hosted on an S3 bucket, based on the following gist. The backup script runs nightly via a cronjob at 8AM UTC/3AM EST/12AM PST. Backups are deleted after 30 days.