From 0fc839a4e87b9f2d20eb6d78a6a4a07e088094fc Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Wed, 9 Nov 2022 21:25:14 +0100 Subject: [PATCH] Add footer Closes #9 --- .github/workflows/publish.yaml | 2 +- src/charasheet/context_processors.py | 5 +++++ src/charasheet/settings.py | 24 ++++++++++++++++++++++++ src/common/templates/common/base.html | 15 +++++++++------ src/common/templates/common/footer.html | 10 ++++++++++ 5 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 src/charasheet/context_processors.py create mode 100644 src/common/templates/common/footer.html diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 345ac5e..aeea837 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -48,4 +48,4 @@ jobs: max_attempts: 5 retry_wait_seconds: 2 warning_on_retry: false - command: curl -sSL --fail -m 10 https://charasheet.augendre.info + command: curl -sSL --fail -m 10 https://charasheet.augendre.info | grep $GITHUB_SHA > /dev/null diff --git a/src/charasheet/context_processors.py b/src/charasheet/context_processors.py new file mode 100644 index 0000000..18ab923 --- /dev/null +++ b/src/charasheet/context_processors.py @@ -0,0 +1,5 @@ +from django.conf import settings + + +def app(request): + return settings.APP diff --git a/src/charasheet/settings.py b/src/charasheet/settings.py index e2a67c7..e288d1e 100644 --- a/src/charasheet/settings.py +++ b/src/charasheet/settings.py @@ -109,6 +109,7 @@ TEMPLATES = [ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", + "charasheet.context_processors.app", ], }, }, @@ -223,3 +224,26 @@ SERVER_EMAIL = "charasheet@mg.augendre.info" if DEBUG: EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" + +APP = { + "build": { + "date": "latest-date", + "commit": "latest-commit", + "describe": "latest-describe", + } +} +try: + with open("/app/git/build-date") as f: + APP["build"]["date"] = f.read().strip() +except Exception: # noqa: S110 + pass +try: + with open("/app/git/git-commit") as f: + APP["build"]["commit"] = f.read().strip() +except Exception: # noqa: S110 + pass +try: + with open("/app/git/git-describe") as f: + APP["build"]["describe"] = f.read().strip() +except Exception: # noqa: S110 + pass diff --git a/src/common/templates/common/base.html b/src/common/templates/common/base.html index 145ddd9..421968f 100644 --- a/src/common/templates/common/base.html +++ b/src/common/templates/common/base.html @@ -23,13 +23,16 @@ {% block head_end %} {% endblock %} - + {% include "common/navbar.html" %} -
- {% bootstrap_messages %} - {% block content %} - {% endblock %} -
+
+
+ {% bootstrap_messages %} + {% block content %} + {% endblock %} +
+
+ {% include "common/footer.html" %} {% django_htmx_script %} diff --git a/src/common/templates/common/footer.html b/src/common/templates/common/footer.html new file mode 100644 index 0000000..ccebd40 --- /dev/null +++ b/src/common/templates/common/footer.html @@ -0,0 +1,10 @@ +