Visit https://mysociety.github.io/nature-emergency.
All modern browsers are supported. Internet Explorer is not. See .browserlistrc
for details.
Requirements:
Install all dependencies and get a local server running immediately, in one command:
script/server
The site will be available at both http://localhost:4000 and http://0.0.0.0:4000.
If you want to serve locally over SSL (recommended) then generate self-signed SSL certificates with:
script/generate-ssl-certificates
Once the SSL certificates are in place, script/server
will serve the site over HTTPS, at both https://localhost:4000 and https://0.0.0.0:4000. (You will need to tell your web browser to accept the self-signed certificate.)
You can build the site to _site
(without serving it) with:
script/build
Data is generated by two Python scripts in script/
. Before running them, you’ll need to install their dependencies, eg:
python3 -m venv .venv
. .venv/bin/activate
pip install --upgrade pip
pip install -r dev-requirements.txt
shot-scraper install
You can then re-generate _data/councils.csv
by running script/generate-councils
over a HTML export of the spreadsheet collated by Climate Emergency UK, eg:
script/generate-councils --in path/to/google/sheet.html
Whenever you (re-)generate _data/councils.csv
you will also want to regenerate all of the social sharing preview images (this takes around 3½ minutes to run, 2 councils per second):
script/generate-social-previews --start-server
The --start-server
flag tells script/generate-social-previews
to run its own internal server at 0.0.0.0:4000 so you’ll want to make sure that port is available for it to use. If not, you can run a server separately, and tell the script where to find it. See script/generate-social-previews --help
for documentation on how to override the default server address, CSV input path, and image output path, for example, to make it generate images for only a subset of councils:
script/generate-social-previews --start-server --input /path/to/shorter-list-of-councils.csv
You will likely also want to compress the PNGs once they’ve been generated (eg: pngquant, at 80% quality, and Zopfli results in a ~65% filesize saving).
When regenerating _data/councils.csv
it can sometimes be useful to see what’s changed. The csv-diff
Python program is included in dev-requirements.txt
for this reason.
If you’ve not yet overwritten _data/councils.csv
, you can supply the --out
parameter to script/generate-councils
to tell it to generate the new councils to a separate file, and then tell csv-diff
to compare the two files:
script/generate-councils --in path/to/google/sheet.html --out _data/councils-new.csv
csv-diff _data/councils.csv _data/councils-new.csv --key=council_name
Or, if you’ve already overwritten _data/councils.csv
(but not yet committed the change), you can pull an unmodified version of the file out of the Git history, and compare that with the current state:
git show HEAD:_data/councils.csv > _data/councils-old.csv
csv-diff _data/councils-old.csv _data/councils.csv --key=council_name
_data/similarities.csv
is a simplified version of mySociety’s Local Authority Composite Similarity dataset, with GSS codes replacing three-letter-codes, and only the most similar “B” councils included for each “A” council. It was generated by script/generate-similarities
, eg:
script/generate-similarities --out _data/similarities.csv