A website to show who's winning in Koodiklinikka's Points Leader competition for IIHF World Championships.
It's running live at https://kk-mm2024.netlify.app/.
Create three files to _data/
:
games.json
with contents of []
, participants.json
with contents of []
and scores.json
with contents of []
.
Head over to _scripts
to run a Python script. To do that, you'll need to create a virtualenv and install a few packages:
cd _scripts/
python -m venv venv
source venv/bin/activate
pip install bs4 selenium
To add a game, find its Play-by-play gamecenter site (like this one) from IIHF's site.
Run
python parse.py https://www.iihf.com/en/events/2024/wm/gamecenter/playbyplay/54187/1-sui-vs-nor
This will open a Firefox window (that autocloses once it's read), parses scoring data and stores it in games.json
.
For each participant, add a JSON object to participants.json
with this template:
{
"name": "[username]",
"finns": {
"name": "[player name in ascii]",
"points": [estimate in integer]
},
"all": {
"name": "[player name in ascii]",
"points": [estimate in integer]
}
}
After either changing the participants.json
or games.json
(via running parse.py
), one more script is needed to run to generate final data. This must be run in the root of the project, not in _scripts
node _scripts/build.js
This will generate scores.json
which is used in the Eleventy site.
To run tests, run
pip install pytest
python -m pytest
npm install
to install Eleventy
To run a local developer site, run
npm run dev
which will run Eleventy and serve it in localhost.
To build the site, run
npm run build
which will generate _site/index.html
that can be deployed to a webserver as a static site.
The architecture of this is version "just put something together" and could probably be simpler and definitely more error-prone.
But for something that lives for a couple of weeks during the competition, it's good enough.
- Make the browser interactions such that it only opens one Firefox session and reads all three pages at once
- Only get Finns stats if Finland played in a game being parsed
- Make parser such that it can be run to update information (currently it just pushes a new entry to the array)
- Add an "updated after" field to let readers know which games have been parsed
- Use the JSON API instead of parsing HTML
- Make the name handling somehow better (it kinda breaks with names like McCANN -> Mccann or da Costa -> Costa)
- Build a better interface for running the scripts (through
package.json
for example)