mirror of
https://github.com/Findus23/acronomy.git
synced 2024-09-10 05:13:45 +02:00
show version
This commit is contained in:
parent
4107ffb086
commit
ea084cdde8
5 changed files with 24 additions and 1 deletions
|
@ -3,3 +3,4 @@ from django.apps import AppConfig
|
|||
|
||||
class AcrosConfig(AppConfig):
|
||||
name = 'acros'
|
||||
verbose_name = "Acronomy"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load version %}
|
||||
{% load static %}
|
||||
|
||||
|
||||
|
@ -12,6 +13,7 @@
|
|||
|
||||
{% block content %}
|
||||
{% if acro.description_html %}
|
||||
{% commit_id %}
|
||||
<div class="description">
|
||||
{{ acro.description_html|safe }}
|
||||
</div>
|
||||
|
|
0
acros/templatetags/__init__.py
Normal file
0
acros/templatetags/__init__.py
Normal file
16
acros/templatetags/version.py
Normal file
16
acros/templatetags/version.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
from subprocess import run
|
||||
|
||||
from django import template
|
||||
from django.core.cache import cache
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
def commit_id():
|
||||
commit = cache.get("commit")
|
||||
if not commit:
|
||||
sp = run(["git", "rev-parse", "--verify", "HEAD"], capture_output=True)
|
||||
commit = sp.stdout.decode().strip()
|
||||
cache.set("commit", commit)
|
||||
return commit
|
|
@ -1,7 +1,11 @@
|
|||
{% load version %}
|
||||
<footer>
|
||||
<ul class="nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="https://github.com/Findus23/acronomy/" target="_blank" rel="noopener">Source</a>
|
||||
<a class="nav-link" href="https://github.com/Findus23/acronomy/tree/{% commit_id %}"
|
||||
target="_blank" rel="noopener" title="{% commit_id %}">
|
||||
Source
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="https://lw1.at/i">Privacy</a>
|
||||
|
|
Loading…
Reference in a new issue