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
...@@ -13,9 +13,14 @@ app.add_template_global(min, name='min') ...@@ -13,9 +13,14 @@ app.add_template_global(min, name='min')
app.add_template_global(max, name='max') app.add_template_global(max, name='max')
# get git commit # get git commit
output = subprocess.check_output(['git', "log", "-g", "-1", "--pretty=%H # %h # %d # %s"]).decode('UTF-8').split('#', 3) 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.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() @app.template_global()
def ismod(*args): def ismod(*args):
return ('user' in session) return ('user' in session)
......
...@@ -15,11 +15,11 @@ ...@@ -15,11 +15,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link href="{{url_for('static', filename='bootstrap/bootstrap.css')}}" rel="stylesheet"> <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" 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/video-js.css')}}">
<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.markers.css')}}">
<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/videojs-resolution-switcher.css')}}">
{% if ismod() %} {% if ismod() %}
<link rel="stylesheet" type="text/css" href="{{url_for('static', filename='bootstrap-multiselect.css')}}"> <link rel="stylesheet" type="text/css" href="{{url_for('static', filename='bootstrap-multiselect.css')}}">
{% endif %} {% endif %}
...@@ -32,11 +32,11 @@ ...@@ -32,11 +32,11 @@
<script src="{{url_for('static', filename='bootstrap-multiselect.js')}}"></script> <script src="{{url_for('static', filename='bootstrap-multiselect.js')}}"></script>
<script src="{{url_for('static', filename='plotly.min.js')}}"></script> <script src="{{url_for('static', filename='plotly.min.js')}}"></script>
{% endif %} {% endif %}
<script src="{{url_for('static', filename='videojs/video.js', v='d042c96')}}"></script> <script src="{{url_for('static', filename='videojs/video.js')}}"></script>
<script src="{{url_for('static', filename='videojs/lang/de.js', v='d042c96')}}"></script> <script src="{{url_for('static', filename='videojs/lang/de.js')}}"></script>
<script src="{{url_for('static', filename='videojs/videojs-resolution-switcher.js', v='d042c96')}}"></script> <script src="{{url_for('static', filename='videojs/videojs-resolution-switcher.js')}}"></script>
<script src="{{url_for('static', filename='videojs/videojs.hotkeys.js', v='d042c96')}}"></script> <script src="{{url_for('static', filename='videojs/videojs.hotkeys.js')}}"></script>
<script src="{{url_for('static', filename='videojs/videojs-markers.js', v='d042c96')}}"></script> <script src="{{url_for('static', filename='videojs/videojs-markers.js')}}"></script>
{% endblock %} {% endblock %}
</head> </head>
<body> <body>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment