diff --git a/backend/db.py b/backend/db.py
index 8214e93..c29fc33 100644
--- a/backend/db.py
+++ b/backend/db.py
@@ -21,7 +21,7 @@ from backend.custom_exceptions import (AccessUnauthorized, InvalidDatabaseFile,
from backend.helpers import RestartVars, folder_path
DB_FILENAME = 'db', 'MIND.db'
-__DATABASE_VERSION__ = 9
+__DATABASE_VERSION__ = 10
__DATEBASE_NAME_ORIGINAL__ = "MIND_original.db"
class DB_Singleton(type):
@@ -283,6 +283,22 @@ def migrate_db(current_db_version: int) -> None:
current_db_version = 9
+ if current_db_version == 9:
+ # V9 -> V10
+
+ # Nothing is changed in the database
+ # It's just that this code needs to run once
+ # and the DB migration system does exactly that:
+ # run pieces of code once.
+ from backend.settings import update_manifest
+
+ url_prefix: str = cursor.execute(
+ "SELECT value FROM config WHERE key = 'url_prefix' LIMIT 1;"
+ ).fetchone()[0]
+ update_manifest(url_prefix)
+
+ current_db_version = 10
+
return
def setup_db() -> None:
diff --git a/backend/settings.py b/backend/settings.py
index a32d484..047de8f 100644
--- a/backend/settings.py
+++ b/backend/settings.py
@@ -4,10 +4,12 @@
Getting and setting settings
"""
+from json import dumps, loads
from typing import Any
from backend.custom_exceptions import InvalidKeyValue, KeyNotFound
from backend.db import __DATABASE_VERSION__, get_db
+from backend.helpers import folder_path
default_settings = {
'allow_new_accounts': True,
@@ -143,6 +145,25 @@ def set_setting(key: str, value: Any) -> None:
"UPDATE config SET value = ? WHERE key = ?;",
(value, key)
)
+
+ if key == 'url_prefix':
+ update_manifest(value)
+
+ return
+
+def update_manifest(url_base: str) -> None:
+ """Update the url's in the manifest file.
+ Needs to happen when url base changes.
+
+ Args:
+ url_base (str): The url base to use in the file.
+ """
+ with open(folder_path('frontend', 'static', 'json', 'manifest.json'), 'r+') as f:
+ manifest = loads(f.read())
+ manifest['start_url'] = url_base + '/'
+ manifest['icons'][0]['src'] = f'{url_base}/static/img/favicon.svg'
+ f.seek(0)
+ f.write(dumps(manifest, indent=4))
return
def backup_hosting_settings() -> None:
diff --git a/frontend/static/json/manifest.json b/frontend/static/json/manifest.json
new file mode 100644
index 0000000..46eb34d
--- /dev/null
+++ b/frontend/static/json/manifest.json
@@ -0,0 +1,18 @@
+{
+ "name": "MIND",
+ "short_name": "MIND",
+ "start_url": "/",
+ "display": "standalone",
+ "background_color": "#1b1b1b",
+ "theme_color": "#6b6b6b",
+ "orientation": "portrait-primary",
+ "icons": [
+ {
+ "src": "/static/img/favicon.svg",
+ "type": "image/svg+xml",
+ "sizes": "64x64 32x32 24x24 16x16"
+ }
+ ]
+} }
+ ]
+}
\ No newline at end of file
diff --git a/frontend/templates/admin.html b/frontend/templates/admin.html
index 243c695..e0b3cbe 100644
--- a/frontend/templates/admin.html
+++ b/frontend/templates/admin.html
@@ -5,6 +5,11 @@
+
+
+
+
+
diff --git a/frontend/templates/login.html b/frontend/templates/login.html
index 796fbb0..1b370ba 100644
--- a/frontend/templates/login.html
+++ b/frontend/templates/login.html
@@ -6,6 +6,11 @@
+
+
+
+
+
diff --git a/frontend/templates/reminders.html b/frontend/templates/reminders.html
index 2339e28..9cefc9a 100644
--- a/frontend/templates/reminders.html
+++ b/frontend/templates/reminders.html
@@ -6,6 +6,11 @@
+
+
+
+
+