shorten footer and link directly to the running commit

This commit is contained in:
codl 2017-08-20 18:48:43 +02:00
parent 6bd769e21e
commit 069a8ab9fb
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
4 changed files with 19 additions and 3 deletions

2
app.py
View File

@ -20,6 +20,8 @@ default_config = {
"HTTPS": True,
"SENTRY_CONFIG": {},
"RATELIMIT_STORAGE_URL": "redis://",
"REPO_URL": "https://github.com/codl/forget",
"COMMIT_URL": "https://github.com/codl/forget/commit/{hash}",
}
app.config.update(default_config)

11
lib/version.py Normal file
View File

@ -0,0 +1,11 @@
from app import app
import re
version_re = re.compile('(?P<tag>.+)-(?P<commits>[0-9]+)-g(?P<hash>[0-9a-f]+)')
def url_for_version(ver):
match = version_re.match(ver)
if not match:
return app.config['REPO_URL']
return app.config['COMMIT_URL'].format(hash=match.group('hash'))

View File

@ -13,6 +13,7 @@ from zipfile import BadZipFile
from twitter import TwitterError
from urllib.error import URLError
import version
import lib.version
@app.before_request
def load_viewer():
@ -26,7 +27,10 @@ def load_viewer():
@app.context_processor
def inject_version():
return dict(version=version.version)
return dict(
version=version.version,
repo_url=lib.version.url_for_version(version.version),
)
@app.context_processor
def inject_sentry():

View File

@ -33,9 +33,8 @@
</header>
{% block body %}{% endblock %}
<footer>
<p>Forget {{version or "dev"}}</p>
<p>Forget <a href='{{repo_url}}'>{{version or "dev"}}</a></p>
<p>A <a href="https://twitter.com/codl">codl</a> joint</p>
<p><a href="https://github.com/codl/forget">Code on Github</a></p>
</footer>
</body>
</html>