Mozilla Foundation website
moz
Перейти к файлу
Tibor Leupold 8da5dcb38e Set HTML indent size in editorconfig to 4
This is matching djhtml's default indent size and much easier to read.
2023-01-20 08:08:39 -08:00
.github Activate HTML indent check in CI 2023-01-20 08:08:39 -08:00
.vscode keep repo as editor-agnostic as possible (#6962) 2021-06-30 16:31:58 -07:00
bin Add helper command to extract strings to an external repo (#4199) 2020-02-19 15:53:44 +01:00
dockerfiles Dockerfile to use node 18 2022-12-14 06:58:25 -08:00
docs Fix docker exec command 2022-12-21 11:06:39 +05:30
maintenance fundraise up on the maintenance page 2022-12-15 16:03:56 -08:00
network-api Merge branch 'main' into 9901-improve-resolution-of-publication-hero 2023-01-19 10:01:39 -08:00
source Merge branch 'main' into 9901-improve-resolution-of-publication-hero 2023-01-19 10:01:39 -08:00
tailwind-plugins 8346 - Removing usage of bootstrap buttons for tailwind version 2022-06-16 14:47:02 -07:00
test renamed category to topic, updated all references in code. (#8812) 2022-06-01 12:13:25 -07:00
tests Fix formatting 2022-10-11 13:56:43 -07:00
.editorconfig Set HTML indent size in editorconfig to 4 2023-01-20 08:08:39 -08:00
.eslintignore Nuke Pug (#1468) 2018-04-27 10:17:12 -07:00
.eslintrc.a11y.json Add 'eslint-plugin-jsx-a11y' and set violation to raise 'warning' for now (#4338) 2020-03-12 16:39:58 -07:00
.eslintrc.json Merge for PNI Q3 2021 (rebased) into the main branch. (#7745) 2021-11-02 14:38:30 -07:00
.gitignore Git ignore compiled frontend files 2022-10-10 12:24:07 -07:00
.mergify.yml fix (#8107) 2022-01-13 15:17:22 -08:00
.prettierignore Added endofline settings to workspace 2021-06-29 12:24:59 -06:00
.prettierrc keep repo as editor-agnostic as possible (#6962) 2021-06-30 16:31:58 -07:00
.profile Switch from wagtail-modeltranslation to wagtail-localize (#7228) 2021-08-17 08:07:50 -07:00
.stylelintrc fix tests 2021-08-05 12:26:39 -06:00
.stylelintrc-colors.js Update a deprecated stylelint rule name (#6021) 2021-01-13 16:59:28 -08:00
CODEOWNERS Template localization (#3529) 2019-11-14 11:18:26 -08: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
Procfile Gunicorn perf redux (#4530) 2020-04-20 10:02:06 -04:00
README.md Update README with Tito Event information 2022-11-15 13:56:26 +00:00
app.json updated script-src for continuous integration test 2022-09-16 09:21:48 -07:00
contribute.json Update contribute.json (#3496) 2019-08-06 08:11:45 -07:00
copy-db.js added --no-owner flag to script to avoid owner error (#9196) 2022-08-04 15:45:07 -07:00
cypress.json Add MozFest homepage and primary page to Percy test (#3951) 2019-11-26 19:16:30 -08:00
dev-requirements.in Install djhtml 2023-01-17 07:21:59 -08:00
dev-requirements.txt Install djhtml 2023-01-17 07:21:59 -08:00
docker-compose.yml Remove deprecate "delegated" option from volumes 2022-11-21 08:21:34 -08:00
env.default updated logic, since we are only using this in prod, also removed from env.default 2022-11-28 19:34:21 -08:00
esbuild.config.js Add basic JS setup for the editorial content index 2022-10-07 14:46:38 -07:00
esbuild.react.shim.js Replace webpack+babel with esbuild (#6230) 2021-02-23 10:44:11 -08:00
invoke.yaml Simplify docker invoke tasks (#3673) 2019-09-23 10:59:38 +02:00
mypy.ini Ignore issues in migrations 2022-07-29 08:52:31 -07:00
package-lock.json Bump cssnano from 5.0.8 to 5.1.14 2023-01-17 00:34:36 +00:00
package.json Bump cssnano from 5.0.8 to 5.1.14 2023-01-17 00:34:36 +00:00
playwright.config.js Replace cypress with playwright (#7999) 2021-12-13 13:15:54 -08:00
postcss.config.js Tailwind Style Guide and Footer Component 2021-08-04 14:24:06 -06:00
pyproject.toml Add basic config options for djlint 2022-12-07 06:39:35 -08:00
pyrightconfig.json Add pyright config 2022-06-28 09:01:20 -07:00
release-steps.sh Exit release script when release commands fail. Prevents releases succeeding when migrations fail. 2022-10-26 10:59:31 +01:00
requirements.in Removes Airtable integration 2023-01-13 10:41:18 +00:00
requirements.txt Bump wagtailmedia from 0.9.0 to 0.12.0 2023-01-19 00:20:55 +00:00
runtime.txt Feature/update python to 3.9.9 (#7969) 2021-12-01 13:14:11 -08:00
tailwind.config.js Uninstall container queries, convert campaign page to use group classes 2022-10-28 16:10:02 -06:00
tasks.py Add invoke tasks for HTML indentation with djhtml 2023-01-17 07:21:59 -08:00
tox.ini Update flake8 excluded files 2022-11-29 10:31:31 -08:00
translation-management.sh Update translation files management 2022-09-28 09:13:00 +02:00

README.md

foundation.mozilla.org

Getting started

Before you start working on the project, be sure to read this README and the linked docs.

Setup with Docker

Local development

Engineer Workflow

OPS and Heroku Settings

Scheduled Task

Stack

How to Setup your Dev Environment with Docker

Requirements: Docker (Docker Desktop for macOS and Windows or Docker Compose for Linux), Python 3 with the invoke package installed globally, and git.

Installing Invoke

We recommend that you install Invoke using pipx, but any Python package manager should work (pip, poetry, etc).

Check your environment

  • docker run hello-world.
  • 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 new-env

You're done 🎉

This task creates a .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.

To log into the admin site, a superuser will have been created with username admin with password admin.

To catch up on new dependencies, migrations, etc. after initial setup, you can use the inv catch-up command. To get a full new environment with a new database, run inv new-env again.

Use inv -l to get a list of all the available invoke commands.

More information on how to work with Docker and how to manage Python dependencies are available in the local development part of the documentation.

Code style

To ensure a consistent code style and quality, we use linters and formatters.

Linting

To check the code base for quality and style issues run inv lint. This will run all configured linters. You can run the linters individually with, e.g. inv lint-js for JavaScript only. Check available commands with inv -l.

Formatting

If inv lint shows linting errors you can try running inv format to fix style issues. inv format should automatically fix most formatting issues.

There might be some linting issues that can not be fixed automatically.

Testing

Unit tests

When relevant, we encourage you to write tests.

You can run the tests using inv test. This will the full test suite. To run only a subset or a specific Python test, you can use following command:

inv manage "test <dotted-path-to-your-test>"

See also the Django docs on running tests.

There is currently no unit test framework for JavaScript tests set up.

Integration tests

Integration testing is done using Playwright, with the integration tests found in ./tests/integration.

You can run these tests locally by running a one-time npm install and npm run playwright:install after which you should be able to run npm run playwright to run the visual tests, with docker-compose up running in a secondary terminal.

In order to run the same tests as will run during CI testing, make sure that RANDOM_SEED=530910203 is set in your .env file, and that your local database is a new db based on that seed (inv new-db).

Note that this is still a work in progress.

Visual regression tests

We also use Playwright in combination with Browserstack's Percy to perform visual regression testing for PRs, using ./tests/visual.spec.js as screenshot baseline.

Accessibility tests

Accessibility tests are currently unavailable but will use axe-playwright when the switchover from Cypress to Playwright is complete.

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 mozfest.localhost:8000. To enable this, add the following line to your hosts file: 127.0.0.1 mozfest.localhost

Ticket purchases are implemented using a third-party integration with Tito. A Tito Event snippet can be created for each event for which registration is needed. A TitoWidget Streamfield block can be used to place a button on a page to open the Tito widget, linked to a specific Tito Event. A Tito Event needs a security token and newsletter question ID which can be found in the Customize -> Webhooks section of the Tito admin dashboard for the event. A webhook (Django view) receives requests from Tito when a ticket is completed in order to sign users up for the Mozilla newsletter.

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.

Translations

Translations of UI strings (from the Django and React apps) are stored in the fomo-l10n repository. Translations are happening in Pontoon, in multiple projects: Foundation website, *Privacy Not Included and Mozilla Festival.

The latest source strings are regularly exposed to Pontoon by a Localization PM using the following process:

Initial setup:

  • Clone the fomo-l10n repository locally.
  • Set the LOCAL_PATH_TO_L10N_REPO variable in your .env file. Use the absolute path to your copy of the fomo-l10n repository and include the trailing slash. E.g. LOCAL_PATH_TO_L10N_REPO=/Users/username/Documents/GitHub/fomo-l10n/

Exposing latest source strings:

  • Make sure your local repositories of fomo-l10n and foundation.mozilla.org are matching the latest revision from main.
  • Run inv docker-makemessages from your foundation.mozilla.org repository.
  • Files should have been updated in your fomo-l10n repository. You can now create a pull-request.

Getting the latest translations for local dev

Latest translations are uploaded to S3. To get them, run:

  • curl -o translations.tar https://foundation-site-translations.s3.amazonaws.com/translations.tar
  • tar -C network-api -xvf translations.tar

You don't need to run compilemessages and it works for both pipenv or docker workflows.

The translations_github_commit_[...] file from the archive is only used for debug purposes on Heroku. It can be safely deleted if needed.

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.