From bd938138a26f7c54e34d1237c8650c4ff877500f Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 12 Sep 2020 17:02:29 +0200 Subject: [PATCH] Add link to deployed commit in footer --- articles/context_processors.py | 9 +++++++-- articles/templates/articles/base.html | 2 +- blog/settings.py | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/articles/context_processors.py b/articles/context_processors.py index 343d245..d51fd98 100644 --- a/articles/context_processors.py +++ b/articles/context_processors.py @@ -1,3 +1,5 @@ +from django.conf import settings + from articles.models import Article, Page IGNORED_PATHS = [ @@ -28,7 +30,10 @@ def git_version(request): return {} try: with open("/app/.version") as f: - version = f.read().strip()[:8] + version = f.read().strip() + url = settings.BLOG["repo"]["commit_url"].format(commit_sha=version) + version = version[:8] except FileNotFoundError: version = "latest" - return {"git_version": version} + url = settings.BLOG["repo"]["log"] + return {"git_version": version, "git_version_url": url} diff --git a/articles/templates/articles/base.html b/articles/templates/articles/base.html index 66339a5..9cd6376 100644 --- a/articles/templates/articles/base.html +++ b/articles/templates/articles/base.html @@ -50,7 +50,7 @@ CC BY-SA 4.0 International License. Code blocks by Gabriel Augendre are licensed under the GNU GENERAL PUBLIC LICENSE version 3.
- Currently deployed version: {{ git_version }} + Currently deployed version: {{ git_version }}

diff --git a/blog/settings.py b/blog/settings.py index efbdfde..dc2d7a8 100644 --- a/blog/settings.py +++ b/blog/settings.py @@ -176,6 +176,11 @@ BLOG = { "title": "Gab's Notes", "description": "My take on tech-related subjects (but not only)", "base_url": os.getenv("BLOG_BASE_URL", "https://gabnotes.org/"), + "repo": { + "commit_url": "https://git.sr.ht/~crocmagnon/blog/commit/{commit_sha}", + "homepage": "https://git.sr.ht/~crocmagnon/blog", + "log": "https://git.sr.ht/~crocmagnon/blog/log", + }, } SHORTPIXEL_API_KEY = os.getenv("SHORTPIXEL_API_KEY")