From 1806fb338e4000a0464bfa2ebf80cedaeab9b660 Mon Sep 17 00:00:00 2001 From: Bui Date: Wed, 5 Dec 2018 21:47:35 +0000 Subject: [PATCH 1/2] add query string to view requests --- app.py | 13 ++++++++++--- public/src/js/loader.js | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 3b33813..bd366e1 100644 --- a/app.py +++ b/app.py @@ -44,6 +44,7 @@ def get_config(): if not config.get('assets_baseurl'): config['assets_baseurl'] = ''.join([request.host_url, 'assets']) + '/' + config['_game_version'] = get_version() return config @@ -118,6 +119,14 @@ def get_tja_preview(tja): return 0 +def get_version(): + version = None + if os.path.isfile('version.json'): + version = json.load(open('version.json', 'r')) + + return version + + @app.teardown_appcontext def close_connection(exception): db = getattr(g, '_database', None) @@ -127,9 +136,7 @@ def close_connection(exception): @app.route('/') def route_index(): - version = None - if os.path.isfile('version.json'): - version = json.load(open('version.json', 'r')) + version = get_version() return render_template('index.html', version=version, config=get_config()) diff --git a/public/src/js/loader.js b/public/src/js/loader.js index 07efdf1..b768841 100644 --- a/public/src/js/loader.js +++ b/public/src/js/loader.js @@ -84,7 +84,8 @@ class Loader{ assets.views.forEach(name => { var id = this.getFilename(name) - this.promises.push(this.ajax("src/views/" + name).then(page => { + var qs = gameConfig._game_version ? '?' + gameConfig._game_version.commit_short : '?' + this.promises.push(this.ajax("src/views/" + name + qs).then(page => { assets.pages[id] = page })) }) From ac23292fe710f6d79bd429579d074ec2de23e5f1 Mon Sep 17 00:00:00 2001 From: Bui Date: Wed, 5 Dec 2018 21:55:28 +0000 Subject: [PATCH 2/2] change version var name --- app.py | 2 +- public/src/js/loader.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index bd366e1..1830b88 100644 --- a/app.py +++ b/app.py @@ -44,7 +44,7 @@ def get_config(): if not config.get('assets_baseurl'): config['assets_baseurl'] = ''.join([request.host_url, 'assets']) + '/' - config['_game_version'] = get_version() + config['_version'] = get_version() return config diff --git a/public/src/js/loader.js b/public/src/js/loader.js index b768841..4294576 100644 --- a/public/src/js/loader.js +++ b/public/src/js/loader.js @@ -84,7 +84,7 @@ class Loader{ assets.views.forEach(name => { var id = this.getFilename(name) - var qs = gameConfig._game_version ? '?' + gameConfig._game_version.commit_short : '?' + var qs = gameConfig._version ? '?' + gameConfig._version.commit_short : '?' this.promises.push(this.ajax("src/views/" + name + qs).then(page => { assets.pages[id] = page }))