From 87eba10185786fc8c42fe160ddf4588274502098 Mon Sep 17 00:00:00 2001
From: Andreas <andreasv@fsmpi.rwth-aachen.de>
Date: Fri, 7 Apr 2017 03:56:16 +0200
Subject: [PATCH] added commit hash and debug highlight

---
 server.py           |  4 ++++
 templates/base.html | 15 ++++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/server.py b/server.py
index d1ccc1d..28be552 100644
--- a/server.py
+++ b/server.py
@@ -54,6 +54,10 @@ if sys.argv[0].endswith('run.py'):
 config.from_pyfile('config.py', silent=True)
 if config['DEBUG']:
 	app.jinja_env.auto_reload = True
+	# get git commit
+	import subprocess
+	app.jinja_env.globals['gitversion'] = subprocess.check_output(['git', "log", "-g", "-1", "--pretty=%h # %d # %s"]).decode('UTF-8').split('#')
+
 if not config.get('SECRET_KEY', None):
 	config['SECRET_KEY'] = os.urandom(24)
 
diff --git a/templates/base.html b/templates/base.html
index ff4dd01..6467f8d 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -38,7 +38,7 @@
 	</head>
 	<body>
 	{% block navbar %}
-		<nav class="hidden-print navbar navbar-default navbar-static-top">
+		<nav class="hidden-print navbar navbar-default navbar-static-top" {% if config.DEBUG %} style="background-color: red" {% endif %} >
 			<div class="container-fluid">
 				<div class="navbar-header">
 					<button type="button" class="navbar-toggle" data-toggle="collapse" 
@@ -127,7 +127,7 @@
 			</div>
 		</div>
 		{% block footer %}
-		<footer class="footer hidden-print">
+		<footer class="footer hidden-print"  {% if config.DEBUG %} style="background-color: red" {% endif %} >
 			<div class="container-fluid">
 				<ul class="list-inline" style="margin-top: 5px;">
 					<li>
@@ -145,9 +145,10 @@
 					<li>
 						<a href="https://twitter.com/rwthvideo">Twitter</a>
 					</li>
-					{% if ismod() %}
+					{% if ismod() or config.DEBUG %}
 					<li class="pull-right">
-						{{ gethostname() }}
+						<a target="_blank" href="https://git.fsmpi.rwth-aachen.de/videoagwebsite/videoagwebsite/commit/{{ gitversion[0] }}"><span title="{{ gitversion[0] }} {{ gitversion[1] }}: {{ gitversion[2] }}" data-toggle="tooltip">{{ gitversion[0] }}</span></a>
+						<span>{{ gethostname() }}</span>
 					</li>
 					{% endif %}
 			</div>
@@ -159,8 +160,12 @@
 			$( function () {
 				moderator.permissioneditor.setpermissions({{global_permissions|tojson|safe}});
 				moderator.api.setcsrftoken('{{ session['_csrf_token'] }}');
-				$('[data-toggle="tooltip"]').tooltip({ 'trigger': 'hover'  });
 			});	
 		</script>
 	{% endif %}
+	<script>
+		$( function () {
+			$('[data-toggle="tooltip"]').tooltip({ 'trigger': 'hover'  });
+		});	
+	</script>
 </html>
-- 
GitLab