Skip to content

Latest commit

 

History

History
79 lines (53 loc) · 3.05 KB

CONTRIBUTING.md

File metadata and controls

79 lines (53 loc) · 3.05 KB

Contributing

This project adheres to openZIM's Contribution Guidelines and openZIM's Bootstrap conventions especially its Policy.

Guidelines

  • Don't take assigned issues. Comment if those get staled.
  • If your contribution is far from trivial, open an issue to discuss it first.
  • Ensure your Python code (inside scraper folder) passes inv lintall and inv checkall
  • Ensure your Javascript code (inside zimui folder) passes yarn format and yarn lint

Testing

If you encounter a challenge for which you do not achieve to make the tests pass, or if you wanna check that all challenges are solvable, you might want to activate a cheat mode.

When cheat mode is activated, every challenge has a new button to directly set a known solution into the code editor.

To activate this cheat mode, you need to set a given property on your browser local storage. This is typically done by typing following text in the Console of your browser (the item to set in local storage is cheatMode and the value is true):

localStorage.setItem("cheatMode", "true")

Development

Setup

See README for details about how to install with hatch virtualenv.

Developing the ZIM UI in Vue.JS

When you want to alter something in the ZIM UI in Vue.JS, you need assets which are generated by the scraper (e.g. shared.json, ...).

To simplify this, it is possible to:

  • run the scraper (with original code base or your modified one)
  • extract assets from generated files and place them in a directory where ZIM UI will find them
  • iterate on ZIM UI code

This needs to be done everytime you make significant changes to the scraper (Python code) that have impact on files used by the Vue.JS UI.

To achieve this, first build the Docker image based on current code base.

docker build -t local-freecodecamp .

Scrape one or more courses (here we use the regular-expressions course but you could use any other one of interest for your UI developments).

docker run --rm -it -v "$PWD/output":/output local-freecodecamp fcc2zim --course=regular-expressions --name tests_en_freecodecamp --zim-file tests_en_freecodecamp.zim --title "freeCodeCamp tests" --description "Test courses from freeCodeCamp" --language eng

Extract interesting ZIM content and move it to public folder.

rm -rf zimui/public/content zimui/public/mathjax
docker run -it --rm -v $(pwd)/output:/data ghcr.io/openzim/zim-tools:latest zimdump dump --dir=/data/tests_en_freecodecamp /data/tests_en_freecodecamp.zim
sudo chown -R $(id -u -n):$(id -g -n) output/tests_en_freecodecamp
mv output/tests_en_freecodecamp/content output/tests_en_freecodecamp/mathjax zimui/public
rm -rf output/tests_en_freecodecamp

Start ZIM UI locally.

cd zimui
yarn dev

Do not forget to cleanup public/content folder before building the docker image again, otherwise all assets will be pushed to the ZIM.

rm -rf zimui/public/content