Web editor for P5.js, modified for workshops at Digital Playground.
Find a file
Jared Donovan 2f21130e0d Fix needs saving mark 2 - for #576 (#658)
* Comment out show/hide file options action creators.

* Comment out show/hide file options properties

* Comment out show/hide file options action definitions

* Comment out constants for show/hide options action types

* Comment out props for show/hide options and replace with component state.

* Comment out show/hide edit file name reducers.

* Comment out show/hide edit file name actions.

* comment out show/hide edit file name action types.

* Comment out show/edit file name props from IDEView component

* Replace show/hide edit filename props in FileNode component with local state

* Remove commented out code from previous changes for moving redux state back into component state.

* Add binding to this for new functions. And tidy up of code.
2018-09-07 15:48:25 -04:00
client Fix needs saving mark 2 - for #576 (#658) 2018-09-07 15:48:25 -04:00
server fixes #668 2018-08-29 15:06:41 -04:00
.babelrc update babel packages 2018-05-08 19:16:04 -07:00
.env.example Remove EXAMPLE_USERNAME as a settable option as per discussion on Issue #646 (#651) 2018-06-18 14:30:05 -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 move around static and dist folders to work with server bundle, and make preview generation work with this 2018-05-08 19:16:03 -07:00
.travis.yml try setting exact node version in travis configuration 2018-05-24 18:55:53 -07:00
backup.sh update instructions for backup.sh 2016-11-16 14:52:27 -05:00
CODE_OF_CONDUCT.md create contributing guide, move code of conduct to separate file, add issue template 2017-10-15 22:04:56 -07:00
contributing.md [WIP] Add detailed git workflow (#603) 2018-03-16 11:44:55 -04:00
docker-compose.yml Fixes #484 by adding MAILGUN_KEY variable to README instructions on setting up .env file, and by adding a default value to the docker-compose environment. (#487) 2017-12-04 13:39:54 -05:00
Dockerfile Accessibility - Transition from interceptor to accessibility library (#508) 2018-02-22 16:47:25 -05:00
ecosystem.json update pm2 to use clusering mode 2017-04-07 00:01:58 -04:00
fetch-examples-gg.js Added script to download and save all generative-design project examples to p5-web-editor (#526) 2018-02-08 16:02:35 -05:00
fetch-examples.js Fetch examples from p5 website repo (#203) 2016-12-01 18:57:50 -05:00
index.html Adding basic meta tags. (#565) 2018-03-08 16:16:48 -05:00
index.js include webpack babel file in server for possible isomorphic stuff in the future 2018-05-08 19:16:03 -07:00
ISSUE_TEMPLATE.md create contributing guide, move code of conduct to separate file, add issue template 2017-10-15 22:04:56 -07:00
LICENSE add license 2017-10-15 22:36:46 -07:00
nginx.conf add nginx configuration to repo 2018-05-17 17:25:45 -07:00
nodemon.json add nodemon, remove .env from being tracked 2016-06-22 18:48:45 -04:00
package-lock.json fix linting error 2018-08-20 14:54:12 -04:00
package.json Improve current console (#656) 2018-07-30 12:20:57 -04:00
PULL_REQUEST_TEMPLATE.md Update PULL_REQUEST_TEMPLATE for clarity (#619) 2018-05-01 00:06:33 +02:00
README.md Remove EXAMPLE_USERNAME as a settable option as per discussion on Issue #646 (#651) 2018-06-18 14:30:05 -07:00
webpack.config.babel.js Improve current console (#656) 2018-07-30 12:20:57 -04:00
webpack.config.dev.js Improve current console (#656) 2018-07-30 12:20:57 -04:00
webpack.config.prod.js Improve current console (#656) 2018-07-30 12:20:57 -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. Create a file called .env in the root of this directory that looks like
API_URL=/api
MONGO_URL=mongodb://localhost:27017/p5js-web-editor
PORT=8000
SESSION_SECRET=whatever_you_want_this_to_be_it_only_matters_for_production
AWS_ACCESS_KEY=<your-aws-access-key>
AWS_SECRET_KEY=<your-aws-secret-key>
AWS_REGION=<your-aws-region>
S3_BUCKET=<your-s3-bucket>
GITHUB_ID=<your-github-client-id>
GITHUB_SECRET=<your-github-client-secret>
GOOGLE_ID=<your-google-client-id> (use google+ api)
GOOGLE_SECRET=<your-google-client-secret> (use google+ api)
MAILGUN_KEY=<your-mailgun-api-key>
EXAMPLE_USER_EMAIL=<email-id-for-p5-example-user>
EXAMPLE_USER_PASSWORD=<password-for-p5-example-user>

If you don't care about being able to upload media files to S3 or Login with Github or Google, you can drop in the file exactly how it is. Or, if you don't want to do that, just ask me to send you mine. Refer to this gist for creating an S3 bucket for testing, or if you don't want to do that, I can add you to one of my S3 buckets.

  1. $ npm run fetch-examples - this downloads the example sketches into a user called 'p5'
  2. $ npm start
  3. Navigate to http://localhost:8000 in your browser
  4. Install the React Developer Tools.
  5. 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 build
  4. $ docker-compose run --rm server npm run fetch-examples

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

  1. $ docker-compose 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 exec server 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 run server --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. Create a file called .env in the root of this directory that looks like
API_URL=/api
MONGO_URL=mongodb://localhost:27017/p5js-web-editor
PORT=8000
SESSION_SECRET=make_this_a_long-random_string_like_maybe_126_characters_long
AWS_ACCESS_KEY=<your-aws-access-key>
AWS_SECRET_KEY=<your-aws-secret-key>
AWS_REGION=<your-aws-region>
S3_BUCKET=<your-s3-bucket>
GITHUB_ID=<your-github-client-id>
GITHUB_SECRET=<your-github-client-secret>
GOOGLE_ID=<your-google-client-id> (use google+ api)
GOOGLE_SECRET=<your-google-client-secret> (use google+ api)
EMAIL_SENDER=<email-address-to-send-from>
MAILGUN_KEY=<mailgun-api-key>
MAILGUN_DOMAIN=<mailgun-domain>
EMAIL_VERIFY_SECRET_TOKEN=whatever_you_want_this_to_be_it_only_matters_for_production
EXAMPLE_USER_EMAIL=<email-id-for-p5-example-user>
EXAMPLE_USER_PASSWORD=<password-for-p5-example-user>

For production, you will need to have real Github and Amazon credentials. Refer to this gist for creating an S3 bucket for testing.

  1. $ npm run fetch-examples - this downloads the example sketches into a user called 'p5'
  2. $ npm run build
  3. $ npm run start:prod

For Production Setup with PM2

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

Optional S3 bucket URL base configuration

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.