Add git version to page footer
This commit is contained in:
parent
2587165f28
commit
f79621876e
6 changed files with 68 additions and 3 deletions
1
Pipfile
1
Pipfile
|
@ -16,6 +16,7 @@ dj-database-url = "*"
|
|||
django-dotenv = "*"
|
||||
plotly = "*"
|
||||
django-mailgun = "*"
|
||||
gitpython = "*"
|
||||
|
||||
|
||||
[dev-packages]
|
||||
|
|
24
Pipfile.lock
generated
24
Pipfile.lock
generated
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "6f892c3bf84ae9490e88b9a4b56b258544c23872374a800b2abf9b7bf35c584d"
|
||||
"sha256": "32be3f9fe9f6e66fc10caa61b74eb88f6a183ddf5c6ed65607024838f2af6ee6"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {},
|
||||
|
@ -81,6 +81,21 @@
|
|||
"index": "pypi",
|
||||
"version": "==3.7.7"
|
||||
},
|
||||
"gitdb2": {
|
||||
"hashes": [
|
||||
"sha256:b60e29d4533e5e25bb50b7678bbc187c8f6bcff1344b4f293b2ba55c85795f09",
|
||||
"sha256:cf9a4b68e8c4da8d42e48728c944ff7af2d8c9db303ac1ab32eac37aa4194b0e"
|
||||
],
|
||||
"version": "==2.0.3"
|
||||
},
|
||||
"gitpython": {
|
||||
"hashes": [
|
||||
"sha256:05069e26177c650b3cb945dd543a7ef7ca449f8db5b73038b465105673c1ef61",
|
||||
"sha256:c47cc31af6e88979c57a33962cbc30a7c25508d74a1b3a19ec5aa7ed64b03129"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.1.9"
|
||||
},
|
||||
"gunicorn": {
|
||||
"hashes": [
|
||||
"sha256:75af03c99389535f218cc596c7de74df4763803f7b63eb09d77e92b3956b36c6",
|
||||
|
@ -192,6 +207,13 @@
|
|||
],
|
||||
"version": "==1.11.0"
|
||||
},
|
||||
"smmap2": {
|
||||
"hashes": [
|
||||
"sha256:b78ee0f1f5772d69ff50b1cbdb01b8c6647a8354f02f23b488cf4b2cfc923956",
|
||||
"sha256:c7530db63f15f09f8251094b22091298e82bf6c699a6b8344aaaef3f2e1276c3"
|
||||
],
|
||||
"version": "==2.0.3"
|
||||
},
|
||||
"traitlets": {
|
||||
"hashes": [
|
||||
"sha256:9c4bd2d267b7153df9152698efb1050a5d84982d3384a37b2c1f7723ba3e7835",
|
||||
|
|
23
gym/context_processors.py
Normal file
23
gym/context_processors.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from django.conf import settings
|
||||
from git import Repo
|
||||
|
||||
|
||||
def get_git_version():
|
||||
"""
|
||||
Get the git version of the site.
|
||||
"""
|
||||
try:
|
||||
repo = Repo(settings.BASE_DIR)
|
||||
branch = repo.active_branch
|
||||
commit = repo.head.commit.hexsha
|
||||
name = u'{0}/{1}'.format(branch, commit[:7])
|
||||
return {'name': name, 'url': u'{}/tree/{}'.format(settings.REPO_URL, commit)}
|
||||
except (KeyError, TypeError):
|
||||
return {'name': '', 'url': ''}
|
||||
|
||||
|
||||
def git_version(request):
|
||||
"""
|
||||
A context processor to include the git version on all pages.
|
||||
"""
|
||||
return {'git_version': get_git_version()}
|
8
gym/static/gym/style.css
Normal file
8
gym/static/gym/style.css
Normal file
|
@ -0,0 +1,8 @@
|
|||
.footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
line-height: 60px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
{% load static %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
|
@ -5,10 +7,11 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
|
||||
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="{% static 'gym/style.css' %}">
|
||||
{% block add-head %}
|
||||
{% endblock %}
|
||||
|
||||
<title>Gym · {% block title %}Home{% endblock %}</title>
|
||||
<title>Workout · {% block title %}Home{% endblock %}</title>
|
||||
</head>
|
||||
<body>
|
||||
{% include 'gym/navbar.html' %}
|
||||
|
@ -48,6 +51,13 @@
|
|||
{% endblock %}
|
||||
</div>
|
||||
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">Version : <a href="{{ git_version.url }}">{{ git_version.name }}</a></p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
|
||||
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
|
||||
crossorigin="anonymous"></script>
|
||||
|
|
|
@ -68,7 +68,7 @@ TEMPLATES = [
|
|||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'gym.context_processors.git_version',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
@ -126,3 +126,4 @@ EMAIL_BACKEND = 'django_mailgun.MailgunBackend'
|
|||
MAILGUN_ACCESS_KEY = os.getenv('MAILGUN_ACCESS_KEY', '')
|
||||
MAILGUN_SERVER_NAME = os.getenv('MAILGUN_SERVER_NAME', '')
|
||||
|
||||
REPO_URL = 'https://github.com/Crocmagnon/workout'
|
||||
|
|
Loading…
Reference in a new issue