Skip to content
Snippets Groups Projects
Commit 19ecc210 authored by Julian Rother's avatar Julian Rother
Browse files

Auto-inject commit hash for all static urls to invalidate browser caches

parent 24ccf16d
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,11 @@ app.add_template_global(max, name='max')
output = subprocess.check_output(['git', "log", "-g", "-1", "--pretty=%H#%h#%d#%s"]).decode('UTF-8').split('#', 3)
app.jinja_env.globals['gitversion'] = {'hash': output[1], 'longhash': output[0], 'branch': output[2], 'msg': output[3]}
@app.url_defaults
def static_version_inject(endpoint, values):
if endpoint == 'static':
values['v'] = app.jinja_env.globals['gitversion']['longhash']
@app.template_global()
def ismod(*args):
return ('user' in session)
......
......@@ -15,11 +15,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="{{url_for('static', filename='bootstrap/bootstrap.css')}}" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='style.css', v='bdd2884')}}">
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='style.css')}}">
<link rel="stylesheet" href="{{url_for('static', filename='font-awesome/css/all.css')}}">
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='videojs/video-js.css', v='d042c96')}}">
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='videojs/videojs.markers.css', v='d042c96')}}">
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='videojs/videojs-resolution-switcher.css', v='d042c96')}}">
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='videojs/video-js.css')}}">
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='videojs/videojs.markers.css')}}">
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='videojs/videojs-resolution-switcher.css')}}">
{% if ismod() %}
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='bootstrap-multiselect.css')}}">
{% endif %}
......@@ -32,11 +32,11 @@
<script src="{{url_for('static', filename='bootstrap-multiselect.js')}}"></script>
<script src="{{url_for('static', filename='plotly.min.js')}}"></script>
{% endif %}
<script src="{{url_for('static', filename='videojs/video.js', v='d042c96')}}"></script>
<script src="{{url_for('static', filename='videojs/lang/de.js', v='d042c96')}}"></script>
<script src="{{url_for('static', filename='videojs/videojs-resolution-switcher.js', v='d042c96')}}"></script>
<script src="{{url_for('static', filename='videojs/videojs.hotkeys.js', v='d042c96')}}"></script>
<script src="{{url_for('static', filename='videojs/videojs-markers.js', v='d042c96')}}"></script>
<script src="{{url_for('static', filename='videojs/video.js')}}"></script>
<script src="{{url_for('static', filename='videojs/lang/de.js')}}"></script>
<script src="{{url_for('static', filename='videojs/videojs-resolution-switcher.js')}}"></script>
<script src="{{url_for('static', filename='videojs/videojs.hotkeys.js')}}"></script>
<script src="{{url_for('static', filename='videojs/videojs-markers.js')}}"></script>
{% endblock %}
</head>
<body>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment