Skip to content
Mozilla Foundation website
Python CSS HTML JavaScript
Branch: master
Clone or download
mmmavis Add language switcher (#3613)
* Add language switcher

* Styling fixes

* Optimize SVGs

* Use div instead of fieldset since we aren't wrapping multiple controls

* styling tweaks

* style tweaks

* remove extra class

* make sure 404 pages don't render language switcher

* Exclude language switcher from PNI
Latest commit c3224bd Sep 16, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.devcontainer Replace Alpine by Debian stretch slim for Docker local dev (#3253) Jul 3, 2019
.github Update pr template with link to migration (#3459) Jul 29, 2019
cypress [Percy Test] Bannered Campaign Page (#3566) Aug 22, 2019
dockerfiles remove cypress install since it's not used for local dev (#3546) Aug 19, 2019
docs rename an inv task + add switching branch command (#3473) Aug 1, 2019
locales/en-US updating OG tags to Foundation - closes #892 (#894) Nov 7, 2017
maintenance Update dark version of instagram glyph to be the correct version (hol… Aug 14, 2019
network-api Add language switcher (#3613) Sep 16, 2019
source Add language switcher (#3613) Sep 16, 2019
test add testing for the Procfile (#2174) Nov 14, 2018
travis-scripts Travis job parallelization (#2730) Mar 11, 2019
.editorconfig Update HTTP to HTTPS (#2219) Nov 21, 2018
.eslintignore Nuke Pug (#1468) Apr 27, 2018
.eslintrc.json Switched eslint to use prettier (#2796) Mar 13, 2019
.gitignore Add support for using Docker for local development (#3002) Apr 25, 2019
.stylelintrc prettier for css/scss (#2807) Mar 14, 2019
.stylelintrc-colors.js Made stylelint throw errors if custom colours are found (#3090) May 9, 2019
.travis.yml It never worked and it's not an approach I want to explore anymore (#… May 28, 2019
CODE_OF_CONDUCT.md Update CODE_OF_CONDUCT.md (#3054) Apr 30, 2019
ISSUE.md adding github issue template (#484) Jun 5, 2017
LICENSE Update HTTP to HTTPS (#2219) Nov 21, 2018
Pipfile Bump factory-boy from 2.11.1 to 2.12.0 (#3523) Aug 14, 2019
Pipfile.lock Bump faker from 2.0.0 to 2.0.1 (#3577) Aug 27, 2019
Procfile Add a release steps file (#2240) Nov 22, 2018
README-FOR-WAGTAIL-LOCALISATION.md Adding wagtail-modeltranslation to get at least some sort of localiza… Aug 21, 2018
README.md Remove /en from links and routes (#3648) Sep 13, 2019
app.json Separating JS dev and prod dependencies (#3241) May 28, 2019
contribute.json Update contribute.json (#3496) Aug 6, 2019
cypress.json added a RANDOM_SEED as env-level seed for the data faker (#2541) Jan 30, 2019
docker-compose.yml delegated docker volumes (#3280) May 31, 2019
env.default twitter feed on the homepage May 23, 2019
package-lock.json Bump @babel/preset-env from 7.5.5 to 7.6.0 (#3623) Sep 13, 2019
package.json Bump @babel/preset-env from 7.5.5 to 7.6.0 (#3623) Sep 13, 2019
release-steps.sh Add a release steps file (#2240) Nov 22, 2018
runtime.txt Update heroku + travis to python 3.7 (#3240) May 28, 2019
tasks.py make docker-setup fall through to docker-new-db (#3536) Aug 14, 2019
tox.ini Remove extra semicolon + add tasks file to lint check + move tox.ini … Sep 11, 2018
webpack.config.js Switched eslint to use prettier (#2796) Mar 13, 2019

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}/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.

Contributing

We love contributors, but the team maintaining this project is small and not structured to significantly support new and inexperienced contributors. If there's an unassigned issue that catches your eye, feel free to open a PR for it, but keep in mind our support will be limited. We usually don't have the capacity to walk you through the process of spinning up the project, opening a PR or describing what the solution to the issue could be.

You can’t perform that action at this time.