Mozilla Foundation website
moz
Перейти к файлу
Mavis Ou 9308847bba
Added 'share button group' style + example on /styleguide (#3352)
* added 'share button group' style + example on /styleguide

* turned share-button-group into a React component

* removed redundant code

* fixed linting errors

* code improvement

* Update source/js/components/share-button-group/share-button-group.jsx

Co-Authored-By: Pomax <pomax@nihongoresources.com>

* Update source/js/components/share-button-group/share-button-group.jsx

Co-Authored-By: Pomax <pomax@nihongoresources.com>

* Update source/js/components/share-button-group/share-button-group.jsx

Co-Authored-By: Pomax <pomax@nihongoresources.com>

* from <hr /> to <hr>

* js/jsx improvements

* code & language improvement

* code improvement

* added tooltip to 'copy link' button

* updated tooltip text
2019-07-09 16:26:40 -07:00
.devcontainer Replace Alpine by Debian stretch slim for Docker local dev (#3253) 2019-07-03 12:17:35 +02:00
.github Docs update (#2819) 2019-03-26 15:03:32 -07:00
cypress added blog page to Percy (#3152) 2019-05-14 13:27:41 -07:00
dockerfiles Replace Alpine by Debian stretch slim for Docker local dev (#3253) 2019-07-03 12:17:35 +02:00
docs Replace Alpine by Debian stretch slim for Docker local dev (#3253) 2019-07-03 12:17:35 +02:00
locales/en-US updating OG tags to Foundation - closes #892 (#894) 2017-11-07 15:23:20 -08:00
maintenance Tweaked footer layout for tablet (#3238) 2019-05-24 18:41:00 -07:00
network-api Added 'share button group' style + example on /styleguide (#3352) 2019-07-09 16:26:40 -07:00
source Added 'share button group' style + example on /styleguide (#3352) 2019-07-09 16:26:40 -07:00
test add testing for the Procfile (#2174) 2018-11-14 09:41:00 -08:00
travis-scripts Travis job parallelization (#2730) 2019-03-11 14:09:08 -04:00
.editorconfig Update HTTP to HTTPS (#2219) 2018-11-20 16:38:36 -08:00
.eslintignore Nuke Pug (#1468) 2018-04-27 10:17:12 -07:00
.eslintrc.json Switched eslint to use prettier (#2796) 2019-03-13 13:44:24 -07:00
.gitignore Add support for using Docker for local development (#3002) 2019-04-25 08:39:52 +02:00
.stylelintrc prettier for css/scss (#2807) 2019-03-14 11:11:35 -07:00
.stylelintrc-colors.js Made stylelint throw errors if custom colours are found (#3090) 2019-05-08 17:06:18 -07:00
.travis.yml It never worked and it's not an approach I want to explore anymore (#3232) 2019-05-28 12:59:06 +02:00
CODE_OF_CONDUCT.md Update CODE_OF_CONDUCT.md (#3054) 2019-04-30 09:10:45 +02:00
ISSUE.md adding github issue template (#484) 2017-06-05 09:41:02 -07:00
LICENSE Update HTTP to HTTPS (#2219) 2018-11-20 16:38:36 -08:00
Pipfile Weekly python update (#3364) 2019-07-03 13:53:41 -04:00
Pipfile.lock Weekly python update (#3364) 2019-07-03 13:53:41 -04:00
Procfile Add a release steps file (#2240) 2018-11-22 12:26:51 +01:00
README-FOR-WAGTAIL-LOCALISATION.md Adding wagtail-modeltranslation to get at least some sort of localization. (#1566) 2018-08-21 10:30:47 -07:00
README.md Removing Snyk (#3287) 2019-06-06 10:21:05 -04:00
app.json Separating JS dev and prod dependencies (#3241) 2019-05-28 11:10:00 +02:00
contribute.json Nuke Pug (#1468) 2018-04-27 10:17:12 -07:00
cypress.json added a RANDOM_SEED as env-level seed for the data faker (#2541) 2019-01-30 10:24:22 -08:00
docker-compose.yml delegated docker volumes (#3280) 2019-05-31 15:43:40 -04:00
env.default twitter feed on the homepage 2019-05-23 09:47:39 -07:00
package-lock.json Bump eslint-plugin-react from 7.13.0 to 7.14.2 (#3346) 2019-07-04 14:57:30 -07:00
package.json Bump eslint-plugin-react from 7.13.0 to 7.14.2 (#3346) 2019-07-04 14:57:30 -07:00
release-steps.sh Add a release steps file (#2240) 2018-11-22 12:26:51 +01:00
runtime.txt Update heroku + travis to python 3.7 (#3240) 2019-05-28 12:03:17 +02:00
tasks.py Replace Alpine by Debian stretch slim for Docker local dev (#3253) 2019-07-03 12:17:35 +02:00
tox.ini Remove extra semicolon + add tasks file to lint check + move tox.ini to top-level dir (#1799) 2018-09-11 12:28:47 -07:00
webpack.config.js Switched eslint to use prettier (#2796) 2019-03-13 13:44:24 -07:00

README.md

foundation.mozilla.org

Build Status Dependency Status Dev Dependency Status Uses Mofo Standards Code Coverage

Table of contents

Setup

Setup with Docker

Local development with invoke and pipenv

Local development with Docker

Engineer Workflow

OPS and Heroku Settings

Scheduled Task

Stack

How to Setup your Dev Environment with Pipenv and Invoke

Requirements: Node, npm, git, python3.6 or later, pip, pipenv, invoke.

If you installed Python with Homebrew, use pip3 install instead of pip install when installing the relevant requirements.

Check your environment

  • python --version should return 3.7 or higher,
  • pipenv --version should return 11.10 or higher,
  • invoke --version should return 0.22.1 or higher.

Setup steps

Run the following terminal commands to get started:

  • git clone https://github.com/mozilla/foundation.mozilla.org.git
  • cd foundation.mozilla.org
  • inv setup

If you're on windows, you need an extra step: run inv manage createsuperuser to create an admin user.

You're done 🎉

To catch up on new dependencies, migrations, etc. after initial setup, you can use the inv catch-up command.

For more information on how to run this project, check the local development with invoke and pipenv documentation.

Testing

When relevant, we encourage you to write tests. You can run the tests using the following command

  • inv test

In addition to the code tests there are also visual regression tests, located in the ./cypress/integration directory. You can run these tests locally by installing cypress using npm i cypress@3.0.3, after which the command npm run cypress will run these tests locally. However, note that these tests are currently intended for screenshot comparisons across branches, and so will not yield any meaningful results when run for a single branch.

How to Setup your Dev Environment with Docker

  • Install Docker Desktop (macOS and Windows). For Linux users: install Docker CE and Docker Compose. If you don't want to create a Docker account, direct links to download can be found in this issue,
  • Check your install by running docker run hello-world,
  • If relevant: delete your node_modules directory (rm -rf node_modules). It's not necessary, but it speeds up the install.
  • Run invoke docker-setup (install invoke if you don't have it yet). If you're running on Windows, you need to run docker-compose --rm pipenv run python network-api/manage.py createsuperuser when the setup is finished.

This task is copying your .env to the new .docker.env that is in charge of managing your environment variables while running Docker. The installation will take a few minutes: you need to download images from the Docker Hub, install JS and Python dependencies, create fake data, migrate your database, etc.

When it's done, run docker-compose up, wait until the static files to be built, and go to 0.0.0.0:8000. You should have a local working version of the foundation site with fake data. When you want to stop, do ^C to shut down your containers.

For more information on how to run the project with Docker, check the local development with Docker documentation.

Mozilla Festival

The fake data generator can generate a site structure for the Mozilla Festival that can be served under it's own domain, or in the case of review apps on Heroku, where we're limited to a single domain, as a sub-directory of the main foundation site, at {review_app_host}/en/mozilla-festival.

In order to access the Mozilla Festival site locally on a different domain than the main Foundation site, you'll need to edit your hosts file (/etc/hosts on *nix systems, C:\Windows\System32\Drivers\etc\hosts on Windows) to allow you to access the site at mozillafestival.localhost:8000. To enable this, add the following line to your hosts file: 127.0.0.1 mozillafestival.localhost

Gotchas

As this is REST API and CMS built on top of Django, there are some "gotcha!"s to keep in mind due to the high level of magic in the Django code base (where things will happen automatically without the code explicitly telling you).

DEBUG=True

The DEBUG flag does all sorts of magical things, to the point where testing with debugging turned on effectively runs a completely different setup compared to testing with debugging turned off. When debugging is on, the following things happen:

  • Django bypasses the ALLOWED_HOST restrictions, which again can lead to 400 Bad Request errors in DEBUG=False setting.
  • Rather than HTTP error pages, Django will generate stack traces pages that expose pretty much all environment variables except any that match certain substrings such as KEY, PASS, etc. for obvious security reasons.
  • ...there are probably more gotchas just for DEBUG so if you find any please add them to this list.