Add Version identification to footer

This commit is contained in:
Phillip Kühne 2021-10-08 23:18:56 +02:00
parent 4b70b70a1d
commit c203317320
6 changed files with 72 additions and 7 deletions

5
.gitignore vendored
View File

@ -134,4 +134,7 @@ data/
# Node Modules
node_modules/
node_modules/
# Version identification file
.version

43
.vscode/launch.json vendored
View File

@ -4,12 +4,44 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{"name":"Python: Flask","type":"python","request":"launch","module":"flask","env":{"FLASK_APP":"backend/app/main.py","FLASK_ENV":"development","FLASK_DEBUG":"1"},"args":["run","--no-debugger","--no-reload"],"jinja":true},
{"name":"Python: Flask (with reload)","type":"python","request":"launch","module":"flask","env":{"FLASK_APP":"backend/app/main.py","FLASK_ENV":"development","FLASK_DEBUG":"1"},"args":["run","--no-debugger"],"jinja":true},
{
"preLaunchTask": "versiondump",
"name": "Python: Flask",
"type": "python",
"cwd": "${workspaceFolder}/backend/app",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "backend/app/main.py",
"FLASK_ENV": "development",
"FLASK_DEBUG": "1"
},
"args": [
"run",
"--no-debugger",
"--no-reload"
],
"jinja": true
},
{
"preLaunchTask": "versiondump",
"name": "Python: Flask (with reload)",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "backend/app/main.py",
"FLASK_ENV": "development",
"FLASK_DEBUG": "1"
},
"args": [
"run",
"--no-debugger"
],
"jinja": true
},
{
"preLaunchTask": "versiondump",
"name": "Python: Flask (with reload, externally reachable)",
"type": "python",
"request": "launch",
@ -27,6 +59,7 @@
"jinja": true
},
{
"preLaunchTask": "versiondump",
"name": "Python: Flask (externally reachable)",
"type": "python",
"request": "launch",

13
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,13 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "versiondump",
"type": "shell",
"command": "git describe > ${workspaceFolder}/backend/app/.version",
"problemMatcher": []
}
]
}

View File

@ -32,6 +32,17 @@ def is_valid_uuid(val):
def check_config_exists():
return os.path.isfile(config_file)
def load_version(app):
if os.path.isfile(".version"):
with open('.version', 'r') as file:
data = file.read().replace('\n', '')
if data:
app.config['VERSION'] = data
else:
app.config['VERSION'] = ""
else:
app.config['VERSION'] = ""
def setup_config(app):
if check_config_exists():
config = json.load(open(config_file))

View File

@ -200,6 +200,7 @@ def admin():
@app.before_first_request
def activate_job():
helpers.load_version(app)
helpers.create_data_directory()
database.create_entry_table()
database.create_song_table()
@ -208,6 +209,10 @@ def activate_job():
database.create_done_song_view()
helpers.setup_config(app)
@app.context_processor
def inject_version():
return dict(karaoqueue_version=app.config['VERSION'])
if __name__ == "__main__":
app.run(host='127.0.0.1', port=8080, debug=True)

View File

@ -75,7 +75,7 @@
{% endif %}
<!--<a href="https://github.com/PhoenixTwoFive/karaoqueue"
class="ml-1 mr-1"><i class="fab fa-github mr-1"></i><span>Github</span></a>-->
<span class="text-muted">KaraoQueue (stale branch) -&nbsp;<span>&copy</span>&nbsp;2019-2021 - Phillip
<span class="text-muted">KaraoQueue {{karaoqueue_version}} -&nbsp;<span>&copy</span>&nbsp;2019-2021 - Phillip
Kühne</span>
</div>
</footer>