Skip to content

Commit

Permalink
Merge pull request #329 from freezingsaddles/djlint
Browse files Browse the repository at this point in the history
djlint the frontend
  • Loading branch information
obscurerichard authored Dec 19, 2024
2 parents 672f292 + a94074d commit 5ede3e4
Show file tree
Hide file tree
Showing 51 changed files with 2,634 additions and 1,460 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Docker Build and maybe Push

on:
on:
workflow_call:
inputs:
org:
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Fix metadata
run: |
if [ -x bin/freeze.sh ]; then
Expand Down Expand Up @@ -76,4 +76,3 @@ jobs:
context: .
push: true
tags: ${{ inputs.org }}/${{ inputs.repo }}:${{ inputs.tag }}

50 changes: 22 additions & 28 deletions .github/workflows/build-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,32 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:

- name: install
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
passphrase: ${{ secrets.PASSPHRASE }}
script: |
set -euo pipefail
cd /opt/compose
docker compose pull freezing-web
docker compose up -d freezing-web
- name: wait
uses: iFaxity/[email protected]
with:
resource: https-get://freezingsaddles.org
timeout: 5000

- name: install
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
passphrase: ${{ secrets.PASSPHRASE }}
script: |
set -euo pipefail
cd /opt/compose
docker compose pull freezing-web
docker compose up -d freezing-web
- name: wait
uses: iFaxity/[email protected]
with:
resource: https-get://freezingsaddles.org
timeout: 5000

test:
concurrency: build-deploy-and-test
needs: [build, deploy]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:

- name: checkout
uses: actions/checkout@v4

- name: test-wget-spider
run: "URL=https://freezingsaddles.org test/wget-spider.sh"

- name: checkout
uses: actions/checkout@v4
- name: test-wget-spider
run: "URL=https://freezingsaddles.org test/wget-spider.sh"
2 changes: 1 addition & 1 deletion .github/workflows/build-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Build Tag
on:
push:
tags:
- '*'
- '*'

jobs:
build:
Expand Down
26 changes: 22 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ name: Lint
on: pull_request

jobs:

# Thanks https://black.readthedocs.io/en/stable/integrations/github_actions.html
lint:
# Thanks for the inspiration:
# https://black.readthedocs.io/en/stable/integrations/github_actions.html
python:
name: Python Lint
runs-on: ubuntu-latest
steps:
Expand All @@ -21,6 +21,24 @@ jobs:
- name: isort Lint
uses: isort/isort-action@v1
with:
requirements-files: "requirements.txt requirements-test.txt"
requirements-files: "requirements.txt requirements-test.txt"
- name: flake8 Lint
uses: py-actions/flake8@v2

templates:
name: Templates Lint
runs-on: ubuntu-latest
steps:
- name: Check out source repository
uses: actions/checkout@v4
- name: Set up Python environment
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-test.txt
- name: djlint Lint
run: |
djlint --check freezing/web/templates
5 changes: 3 additions & 2 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ name: Security
on: pull_request

jobs:

# Thanks https://black.readthedocs.io/en/stable/integrations/github_actions.html

# Thanks for inspiration:
# https://black.readthedocs.io/en/stable/integrations/github_actions.html
bandit:
name: Bandit
runs-on: ubuntu-latest
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,13 @@ To get `freezing-web` to permanently use the `freezing-model` changes you will h

### Coding standards

The `freezing-web` code is intended to be [PEP-8](https://www.python.org/dev/peps/pep-0008/) compliant. Code formatting is done with [black](https://black.readthedocs.io/en/stable/) and can be linted with [flake8](http://flake8.pycqa.org/en/latest/). See the [.flake8](.flake8) file and install the test dependencies to get these tools (`pip install -r test-requirements.txt`).
The `freezing-web` code is intended to be [PEP-8](https://www.python.org/dev/peps/pep-0008/) compliant. Code formatting is done with [black](https://black.readthedocs.io/en/stable/), [isort](https://pycqa.github.io/isort/) and [djlint}(https://www.djlint.com/) and can be linted with [flake8](http://flake8.pycqa.org/en/latest/). See the [.flake8](.flake8) file and install the test dependencies to get these tools (`pip install -r test-requirements.txt`).

To run _all_ the linters and formatters, use the following commands:
```
bin/lint.sh
bin/fmt.sh
```

## Docker Deployment

Expand Down
9 changes: 9 additions & 0 deletions bin/fmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
echo "Running formatters"
echo "*** black ***"
black freezing
echo "*** isort ***"
isort freezing
echo "*** djlint ***"
djlint --reformat freezing/web/templates

12 changes: 12 additions & 0 deletions bin/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
echo "Running linting checks"
echo "*** black ***"
black --check freezing
echo "*** isort ***"
isort --check freezing
echo "*** flake8 ***"
flake8 freezing
echo "*** mypy ***"
echo "*** djlint ***"
djlint --check freezing/web/templates

52 changes: 36 additions & 16 deletions freezing/web/templates/alt_scoring/indiv_freeze.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
{% extends "base.html" %}
{% block content %}
<div class="card">
<h5 class="card-header">Freeze Points</h5>
<div class="card-body">
<p>Thanks to VVill for coming up with this, (<a href="https://www.bikearlingtonforum.com/forums/topic/freeze-points-metric/">explained here</a>). Basically you get more points for riding in the cold, but distance doesn't matter so much.</p>
<table class="table table-condensed">
<tr><th>Rank</th><th>Team</th><th>Points</th></tr>
{% for a, b in indiv_freeze %}
<tr>
<td>{{loop.index}}</td>
<td>{{a}}</td>
<td>{{ '%0.1f' % b }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
<div class="card">
<h5 class="card-header">
Freeze Points
</h5>
<div class="card-body">
<p>
Thanks to VVill for coming up with this, (<a href="https://www.bikearlingtonforum.com/forums/topic/freeze-points-metric/">explained here</a>). Basically you get more points for riding in the cold, but distance doesn't matter so much.
</p>
<table class="table table-condensed">
<tr>
<th>
Rank
</th>
<th>
Team
</th>
<th>
Points
</th>
</tr>
{% for a, b in indiv_freeze %}
<tr>
<td>
{{ loop.index }}
</td>
<td>
{{ a }}
</td>
<td>
{{ '%0.1f' % b }}
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endblock %}
105 changes: 73 additions & 32 deletions freezing/web/templates/alt_scoring/indiv_hains.html
Original file line number Diff line number Diff line change
@@ -1,43 +1,84 @@
{% extends "base.html" %}
{% block content %}
<div class="card">
<h5 class="card-header">Hains Point Laps</h5>
<div class="card-body">
<p class="lead">We're looking for the hamsterest hamster who ever hamstered.</p>
<p>Segment Miles is based on the 2.5 mile <a href="https://www.strava.com/segments/1081507">Gate
to Gate segment</a>, so it undercounts your mileage if you did a full lap.
However, since this segment is the official measure of "A Hains Point Lap" as far as
this contest is concerned, it was thought best to use 2.5 miles.</p>
<p>If you feel the wrong decision has been made here, please be reminded that you are a hamster, and hamsters don't get the admin password to the web server.</p>
<div class="table-responsive">
<table id="hamster" class="table table-condensed">
<thead>
<tr><th>Rank</th><th>Hamster</th><th>Times Hamstered</th><th>Segment Miles</th><th>Total Miles</th><th>Hamster %</th></tr>
</thead>
{% for a, b, c in indiv_hains %}
<tr>
<td>{{loop.index}}</td>
<td>{{a}}</td>
<td>{{b}}</td>
<td>{{b * 2.5}}</td>
<td>{{c|round(1)}}</td>
<td>{{((b*250)/c)|round(1)}}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
<div class="card">
<h5 class="card-header">
Hains Point Laps
</h5>
<div class="card-body">
<p class="lead">
We're looking for the hamsterest hamster who ever hamstered.
</p>
<p>
Segment Miles is based on the 2.5 mile <a href="https://www.strava.com/segments/1081507">Gate
to Gate segment</a>, so it undercounts your mileage if you did a full lap.
However, since this segment is the official measure of "A Hains Point Lap" as far as
this contest is concerned, it was thought best to use 2.5 miles.
</p>
<p>
If you feel the wrong decision has been made here, please be reminded that you are a hamster, and hamsters don't get the admin password to the web server.
</p>
<div class="table-responsive">
<table id="hamster" class="table table-condensed">
<thead>
<tr>
<th>
Rank
</th>
<th>
Hamster
</th>
<th>
Times Hamstered
</th>
<th>
Segment Miles
</th>
<th>
Total Miles
</th>
<th>
Hamster %
</th>
</tr>
</thead>
{% for a, b, c in indiv_hains %}
<tr>
<td>
{{ loop.index }}
</td>
<td>
{{ a }}
</td>
<td>
{{ b }}
</td>
<td>
{{ b * 2.5 }}
</td>
<td>
{{ c|round(1) }}
</td>
<td>
{{ ((b*250)/c)|round(1) }}
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</div>
{% endblock %}
{% block foot %}
<script type="text/javascript" src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
<script type="text/javascript">
<script type="text/javascript"
src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet"
href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
<script type="text/javascript">
$(document).ready(function(){
$('#hamster').DataTable( {
"paging": false,
"order": [[ 2, "desc" ]]
} );
});
</script>
</script>
{% endblock %}
Loading

0 comments on commit 5ede3e4

Please sign in to comment.