From 7b3d9f286e186d4ac4ae582642b7f67899269c12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Thuret?= <contact@sebastien-thuret.fr>
Date: Sat, 9 Oct 2021 18:25:28 +0200
Subject: [PATCH] Added version number for assets that may change

---
 app/app.py               | 2 ++
 app/templates/index.html | 5 ++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/app/app.py b/app/app.py
index 659409f..e1a7681 100644
--- a/app/app.py
+++ b/app/app.py
@@ -1,6 +1,7 @@
 import os
 from functools import wraps
 
+import pkg_resources
 from flask import Flask, abort, jsonify, render_template, request
 from flask_swagger import swagger
 from flask_swagger_ui import get_swaggerui_blueprint
@@ -176,6 +177,7 @@ def create_app(args):
             frontendTimeout=args.frontend_timeout,
             api_keys=args.api_keys,
             web_version=os.environ.get("LT_WEB") is not None,
+            version=pkg_resources.require("LibreTranslate")[0].version
         )
 
     @app.route("/javascript-licenses", methods=["GET"])
diff --git a/app/templates/index.html b/app/templates/index.html
index 0af2484..e2a6f8c 100644
--- a/app/templates/index.html
+++ b/app/templates/index.html
@@ -19,7 +19,7 @@
 	<link rel="stylesheet" href="{{ url_for('static', filename='css/materialize.min.css') }}">
 	<link rel="stylesheet" href="{{ url_for('static', filename='css/material-icons.css') }}" />
 	<link rel="stylesheet" href="{{ url_for('static', filename='css/prism.min.css') }}" />
-	<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}?t=2" />
+	<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}?v={{ version }}" />
 
 	{% if gaId %}
 	<!-- Global site tag (gtag.js) - Google Analytics -->
@@ -245,8 +245,7 @@
 	window.Prism.manual = true;
 	// @license-end
 	</script>
-
     <script src="{{ url_for('static', filename='js/prism.min.js') }}"></script>
-    <script src="{{ url_for('static', filename='js/app.js') }}"></script>
+    <script src="{{ url_for('static', filename='js/app.js') }}?v={{ version }}"></script>
 </body>
 </html>
-- 
GitLab