SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit be0f1a12 authored by George Katsikas's avatar George Katsikas :goat:
Browse files

add git version to footer, fetch on server reboot

related to comments on #315
parent a2df661f
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,17 @@ with open(os.path.join(BASE_DIR, "secrets.json")) as f: ...@@ -35,6 +35,17 @@ with open(os.path.join(BASE_DIR, "secrets.json")) as f:
secrets = json.load(f) secrets = json.load(f)
def get_latest_commit_hash():
try:
ps = os.popen("git log -n 1 --pretty=format:%h").read()
return ps.strip()
except Exception:
return None
COMMIT_HASH = get_latest_commit_hash()
def get_secret(setting, secrets=secrets): def get_secret(setting, secrets=secrets):
"""Get the secret variable or return explicit exception.""" """Get the secret variable or return explicit exception."""
try: try:
...@@ -338,6 +349,7 @@ TEMPLATES = [ ...@@ -338,6 +349,7 @@ TEMPLATES = [
"django.contrib.messages.context_processors.messages", "django.contrib.messages.context_processors.messages",
"scipost.context_processors.roles_processor", "scipost.context_processors.roles_processor",
"scipost.context_processors.domain_processor", "scipost.context_processors.domain_processor",
"scipost.context_processors.commit_hash_processor",
"journals.context_processors.publishing_years_processor", "journals.context_processors.publishing_years_processor",
"journals.context_processors.journals_processor", "journals.context_processors.journals_processor",
"ontology.context_processors.ontology_processor", "ontology.context_processors.ontology_processor",
......
...@@ -2,6 +2,7 @@ __copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)" ...@@ -2,6 +2,7 @@ __copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3" __license__ = "AGPL v3"
from django.conf import settings
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from common.utils.models import get_current_domain from common.utils.models import get_current_domain
...@@ -56,3 +57,10 @@ def domain_processor(request): ...@@ -56,3 +57,10 @@ def domain_processor(request):
Add the domain name to the context. Add the domain name to the context.
""" """
return {"DOMAIN_HOST": get_current_domain()} return {"DOMAIN_HOST": get_current_domain()}
def commit_hash_processor(request):
"""
Add the current commit hash to the context.
"""
return {"COMMIT_HASH": settings.COMMIT_HASH}
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
<ul class="list-inline text-center"> <ul class="list-inline text-center">
<li class="list-inline-item"> <li class="list-inline-item">
<a href="https://git.{{ DOMAIN_HOST }}" target="_blank" rel="noopener"> <a href="https://git.{{ DOMAIN_HOST }}" target="_blank" rel="noopener">
<span>{% include 'bi/git.html' %}</span>&nbsp;Git Repository</a> <span>{% include 'bi/git.html' %}</span>&nbsp;Git Repository</a>
<span class="ms-1">(server version <a class="text-info" href="https://git.{{ DOMAIN_HOST }}/scipost/SciPost/-/commit/{{COMMIT_HASH}}">{{ COMMIT_HASH }}</a>)</span>
</li> </li>
<li class="list-inline-item"> <li class="list-inline-item">
<a href="{% url 'scipost:feeds' %}" aria-label="RSS feeds"> <a href="{% url 'scipost:feeds' %}" aria-label="RSS feeds">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment