Add link to deployed commit in footer

This commit is contained in:
Gabriel Augendre 2020-09-12 17:02:29 +02:00
parent 5fbdf4c3e5
commit bd938138a2
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
3 changed files with 13 additions and 3 deletions

View file

@ -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}

View file

@ -50,7 +50,7 @@
<a href="http://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0 International License</a>.
Code blocks by Gabriel Augendre are licensed under the
<a href="https://www.gnu.org/licenses/gpl-3.0.html">GNU GENERAL PUBLIC LICENSE version 3</a>.<br>
Currently deployed version: {{ git_version }}
Currently deployed version: <a href="{{ git_version_url }}">{{ git_version }}</a>
</p>
</footer>
</body>

View file

@ -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")