diff --git a/.env.example b/.env.example index ee948df6..3bfd7e50 100644 --- a/.env.example +++ b/.env.example @@ -10,6 +10,13 @@ GITHUB_ID= GITHUB_SECRET= GOOGLE_ID= (use google+ api) GOOGLE_SECRET= (use google+ api) +MAILGUN_DOMAIN= MAILGUN_KEY= -EXAMPLE_USER_EMAIL= -EXAMPLE_USER_PASSWORD= \ No newline at end of file +EMAIL_SENDER= +EMAIL_VERIFY_SECRET_TOKEN=whatever_you_want_this_to_be_it_only_matters_for_production +S3_BUCKET_URL_BASE= +EXAMPLE_USER_EMAIL=examples@p5js.org +EXAMPLE_USER_PASSWORD=hellop5js +GG_EXAMPLES_USERNAME=generative-design +GG_EXAMPLES_PASS=generativedesign +GG_EXAMPLES_EMAIL=benedikt.gross@generative-gestaltung.de diff --git a/.eslintignore b/.eslintignore index 8d1287fa..017248a5 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,2 @@ -webpack.config.js +webpack/* index.js \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md diff --git a/contributing.md b/.github/CONTRIBUTING.md similarity index 54% rename from contributing.md rename to .github/CONTRIBUTING.md index 0d74b0fb..d113780a 100644 --- a/contributing.md +++ b/.github/CONTRIBUTING.md @@ -1,17 +1,12 @@ -# Contributing to the p5.js web editor +# Contributing to the p5.js Web Editor -Hello! We welcome community contributions to the p5.js web editor. Contributing takes many forms and doesn't have to be **writing code**, it can be **documenting bugs**, **proposing new features**, and **updating documentation**. We would also like to Thank you for choosing to contribute p5.js web editor, any way possible. You are awesome! :blush: - -This **web editor** for **p5.js**, a JavaScript library with the goal of making coding accessible to **artists**, **designers**, **educators**, and **beginners**, is an environment to make p5.js sketches without needing to download any software or do any configuration, which makes it a great place to start learning how to code and start learning p5.js. +Hello! We welcome community contributions to the p5.js Web Editor. Contributing takes many forms and doesn't have to be **writing code**, it can be **report bugs**, **proposing new features**, **creating UI/UX designs**, and **updating documentation**. Here are links to all the sections in this document: - [Code of Conduct](#code-of-conduct) -- [Technologies Used](#technologies-used) -- [Development Installation](#development-installation) -- [New Design](#new-design) - [How Can I Contribute ?](#how-can-i-contribute?) - [First Timers](#first-timers) - [Want something more challenging](#want-something-more-challenging) @@ -19,35 +14,11 @@ Here are links to all the sections in this document: - [Creating a Pull request](#creating-a-pull-request) - - [Tips](#tips) -# Code of Conduct +## Code of Conduct Please follow the guidelines mentioned at [CODE OF CONDUCT.md](https://github.com/processing/p5.js-web-editor/blob/master/CODE_OF_CONDUCT.md#p5js-code-of-conduct). -# Technologies Used - - > **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](https://github.com/Hashnode/mern-starter). - - - This project **does not use CSS Modules, but uses Sass**. [BEM guidelines and naming conventions](http://getbem.com/) are followed. - - - For repeatitive and common styles, write OOSCSS (Object-Oriented SCSS) with placeholders and mixins. For organizing styles, follow the 7-1 Pattern for Sass. - - - We're using [ES6](http://es6-features.org/) and transpiling to ES5 using [Babel](https://babeljs.io/). - - - For reference to the JavaScript style guide, see the [Airbnb Style Guide](https://github.com/airbnb/javascript), [React ESLint Plugin](https://github.com/yannickcr/eslint-plugin-react). - - - 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`. - -# Development Installation - -To get started on a patch, first read the instruction from [README.md](https://github.com/processing/p5.js-web-editor#development-installation). - -# New Design - -Design proposed and theme changes are present at: [Zeplin](https://scene.zeplin.io/project/55f746c54a02e1e50e0632c3). - -# How Can I Contribute? +## How Can I Contribute? ### First Timers For first-time contributors or those who want to start with a small task: [check out our list of good first bugs](https://github.com/processing/p5.js-web-editor/labels/good%20first%20issue). First read the github discussion on that issue and find out if there's currently a person working on that or not. If no one is working on it or if there has was one claimed to but has not been active for a while, ask if it is up for grabs. It's okay to not know how to fix an issue and feel free to ask questions about to approach the problem! We are all just here to learn and make something awesome. Someone from the community would help you out and these are great issues for learning about the web editor, its file structure and its development process. @@ -59,31 +30,14 @@ If you're already familiar with the project or would like take on something a li If you want to work on building new things, please take a look at [type: feature](https://github.com/processing/p5.js-web-editor/labels/type%3Afeature). If you'd like to work on a bug, please comment on it to let the maintainers know. -If someone else has already commented and taken up that bug, please refrain from working on it and submitting -a PR without asking the maintainers as it leads to unnecessary duplication of effort. +If someone else has already commented and taken up that bug, please refrain from working on it and submitting a PR without asking the maintainers as it leads to unnecessary duplication of effort. ### Contribution guides * [https://guides.github.com/activities/hello-world/](https://guides.github.com/activities/hello-world/) * [https://guides.github.com/activities/forking/](https://guides.github.com/activities/forking/) -# Creating a pull request - -Set up a new remote that points to the original project so that you can update your local repository once any changes have made to remote. - - $ git remote add upstream https://github.com/processing/p5.js-web-editor - - and also before you submit a [pull request](https://help.github.com/articles/creating-a-pull-request/), please remember to fetch the changes using: - - $ git fetch upstream - -When you create a pull request for a new fix or feature, be sure to mention the issue number for what you're working on. The best way to do it is to mention the issue like this at the top of your description: - - Fixes #333 - -The issue number in this case is "333." The word *Fixes* is magical; GitHub will automatically close the issue when your pull request is merged. - -# Writing commit messages +## Writing commit messages Good commit messages serve at least three important purposes: diff --git a/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md similarity index 100% rename from ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE.md diff --git a/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from PULL_REQUEST_TEMPLATE.md rename to .github/PULL_REQUEST_TEMPLATE.md diff --git a/.gitignore b/.gitignore index ebb519cf..30e479a2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store .env +.env.production .vscode/ node_modules/ npm-debug.log diff --git a/.travis.yml b/.travis.yml index 4eaef2a4..46ec9016 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,39 @@ +sudo: required language: node_js node_js: - - "8.11.1" \ No newline at end of file + - "8.11.1" + +cache: + directories: + - "$HOME/google-cloud-sdk/" + +services: + - docker + +before_install: + - docker-compose -f docker-compose-development.yml up -d + - docker ps -a + +install: true + +script: + - docker-compose exec -T app npm run test --verbose + +before_deploy: + - docker-compose stop + - if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; export CLOUDSDK_CORE_DISABLE_PROMPTS=1; curl https://sdk.cloud.google.com | bash >/dev/null; fi + - source /home/travis/google-cloud-sdk/path.bash.inc + - gcloud --quiet version + - gcloud --quiet components update + - gcloud --quiet components update kubectl + +deploy: + - provider: script + script: ./deploy.sh + skip_cleanup: true + on: + branch: master + +env: + global: + - APP_IMAGE_NAME=p5jswebeditor_app diff --git a/Dockerfile b/Dockerfile index 6d75fe0c..51864673 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,29 @@ -FROM node:8.9.0 - -ENV APP_HOME=/opt/node/app \ - TERM=xterm - -# Copy in the project files and set as working directory -ADD . $APP_HOME +FROM node:8.11.1 as base +ENV APP_HOME=/usr/src/app \ + TERM=xterm +RUN mkdir -p $APP_HOME WORKDIR $APP_HOME - -# Install node modules -RUN npm install - -# Rebuild node-sass just to be safe -RUN npm rebuild node-sass - -# For development, mark the directory as a mount override point -VOLUME $APP_HOME - -# Expose default server port EXPOSE 8000 + +FROM base as development +ENV NODE_ENV development +COPY package.json package-lock.json ./ +RUN npm install +RUN npm rebuild node-sass +COPY .babelrc index.js nodemon.json ./ +COPY ./webpack ./webpack +COPY client ./client +COPY server ./server +CMD ["npm", "start"] + +FROM development as build +ENV NODE_ENV production +RUN npm run build + +FROM base as production +ENV NODE_ENV=production +COPY package.json package-lock.json index.js ./ +RUN npm install --production +RUN npm rebuild node-sass +COPY --from=build $APP_HOME/dist ./dist +CMD ["npm", "run", "start:prod"] diff --git a/README.md b/README.md index 44e8ebdf..d4ee0ebf 100644 --- a/README.md +++ b/README.md @@ -1,166 +1,23 @@ -# p5.js Web Editor +# [p5.js Web Editor](https://editor.p5js.org) -This project is currently in development! It will be announced when there is a (public) beta release. +The p5.js Web Editor is an in-browser code editor for creating [p5.js](https://p5js.org/) sketches. p5.js, which is a separate project, is a JavaScript library with the goal of making coding accessible for artists, designers, educators, and beginners, and the web editor shares this same spirit. It is designed with the benginner in mind—when using the web editor, you don't need to download or configure anything, you can simply open the website, and start writing code. You can also host their work online and share it with others. -## Development Installation +The p5.js Web Editor is currently in active development, and looking for contributions of any type! Please check out the [contribution guide](https://github.com/processing/p5.js-web-editor/blob/master/.github/CONTRIBUTING.md) for more details. -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 - * For Mac OSX with [homebrew](http://brew.sh/): `brew install mongodb` then `brew services start mongodb` - * For Windows and Linux: [MongoDB Installation](https://docs.mongodb.com/manual/installation/) -5. Create a file called `.env` in the root of this directory that looks like +If you have found a bug in the p5.js Web Editor, you can file it under the ["issues" tab](https://github.com/processing/p5.js-web-editor/issues). - ``` - 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= - AWS_SECRET_KEY= - AWS_REGION= - S3_BUCKET= - GITHUB_ID= - GITHUB_SECRET= - GOOGLE_ID= (use google+ api) - GOOGLE_SECRET= (use google+ api) - MAILGUN_KEY= - EXAMPLE_USER_EMAIL= - EXAMPLE_USER_PASSWORD= - ``` +## Issues - 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](https://gist.github.com/catarak/70c9301f0fd1ac2d6b58de03f61997e3) 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. +Please post bugs and feature requests in the correct repository: -6. `$ npm run fetch-examples` - this downloads the example sketches into a user called 'p5' -7. `$ npm start` -8. Navigate to [http://localhost:8000](http://localhost:8000) in your browser -9. Install the [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en). -10. Open and close the Redux DevTools using `ctrl+h`, and move them with `ctrl+w` +* p5.js general and p5.dom: [https://github.com/processing/p5.js/issues](https://github.com/processing/p5.js/issues) +* p5.accessibility: [https://github.com/processing/p5.accessibility/issues](https://github.com/processing/p5.accessibility/issues) +* p5.sound: [https://github.com/processing/p5.js-sound/issues](https://github.com/processing/p5.js-sound/issues) +* p5.js website: [https://github.com/processing/p5.js-website/issues](https://github.com/processing/p5.js-website/issues) -### Testing SSL on your local machine -Please refer to [this gist](https://gist.github.com/andrewn/953ffd5cb17ac2634dc969fc7bdaff3f). 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. +## Get Involved -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. +The p5.js Web Editor is a collaborative project created by many individuals, and you are invited to help. All types of involvement are welcome. You can start with the [p5.js community section](https://p5js.org/community), which also applies to this project. -## Development Installation using Docker +Developers, check the [developer docs](https://github.com/processing/p5.js-web-editor/blob/master/developer_docs/) details about contributing code, bug fixes, and documentation. -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 - * Mac: https://www.docker.com/docker-mac - * Windows: https://www.docker.com/docker-windows -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: - -5. `$ docker-compose up` -6. Navigate to [http://localhost:8000](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): - -7. `$ 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): - -8. `$ 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= - AWS_SECRET_KEY= - AWS_REGION= - S3_BUCKET= - GITHUB_ID= - GITHUB_SECRET= - GOOGLE_ID= (use google+ api) - GOOGLE_SECRET= (use google+ api) - EMAIL_SENDER= - MAILGUN_KEY= - MAILGUN_DOMAIN= - EMAIL_VERIFY_SECRET_TOKEN=whatever_you_want_this_to_be_it_only_matters_for_production - EXAMPLE_USER_EMAIL= - EXAMPLE_USER_PASSWORD= - ``` - For production, you will need to have real Github and Amazon credentials. Refer to [this gist](https://gist.github.com/catarak/70c9301f0fd1ac2d6b58de03f61997e3) for creating an S3 bucket for testing. - -5. `$ npm run fetch-examples` - this downloads the example sketches into a user called 'p5' -6. `$ npm run build` -7. `$ 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](https://gist.github.com/MathuraMG/e86666b7b41fbc8c078bad9aff3f666d) and here is an overview of the [p5-accessibility.js](https://github.com/processing/p5.accessibility) 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](http://html5doctor.com/element-index/#body) -* 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](http://webaim.org/techniques/keyboard/tabindex). Using tabIndex ensures that all elements are accessible via keyboard. [code example](https://github.com/processing/p5.js-web-editor/blob/master/client/modules/IDE/components/Editor.jsx#L249) -* When opening a new window or pop up window, ensure the keyboard focus also moves to the new window. [code example](https://github.com/processing/p5.js-web-editor/blob/master/client/modules/IDE/components/NewFileForm.jsx#L16) - -**Labeling** - -* When creating button icons, images, or something without text (this does not include an HTML5 `