Skip to content

Commit

Permalink
Display the site's commit hash
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkykh committed May 14, 2017
1 parent a7d3c5a commit 2a71fd8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions nyaa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ def internal_error(exception):
'<strong>An error occured!</strong> Debugging information has been logged.'), 'danger')
return flask.redirect('/')

# Get git commit hash
app.config['COMMIT_HASH'] = None
master_head = os.path.abspath(os.path.join(os.path.dirname(__file__), '../.git/refs/heads/master'))
if os.path.isfile(master_head):
with open(master_head, 'r') as head:
app.config['COMMIT_HASH'] = head.readline().strip()

# Enable the jinja2 do extension.
app.jinja_env.add_extension('jinja2.ext.do')
app.jinja_env.lstrip_blocks = True
Expand Down
3 changes: 3 additions & 0 deletions nyaa/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@

<footer style="text-align: center;">
<p>Dark Mode: <a href="#" id="themeToggle">Toggle</a></p>
{% if config.COMMIT_HASH %}
<p>Commit: <a href="https://github.com/nyaadevs/nyaa/tree/{{ config.COMMIT_HASH }}">{{ config.COMMIT_HASH[:7] }}</a></p>
{% endif %}
</footer>
</body>
</html>
Expand Down

0 comments on commit 2a71fd8

Please sign in to comment.