Converted manifest file into dynamic endpoint

This commit is contained in:
CasVT
2025-04-24 13:51:43 +02:00
parent 2fbc460893
commit 4f77435801
8 changed files with 53 additions and 60 deletions

View File

@@ -298,15 +298,8 @@ class MigrateUpdateManifest(DBMigrator):
def run(self) -> None:
# 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.internals.settings import Settings, update_manifest
update_manifest(
Settings().get_settings().url_prefix
)
# There used to be a migration here that fixed the manifest file.
# That has since been replaced by the dynamic endpoint serving the JSON.
# So the migration doesn't do anything anymore, and a function used
# doesn't exist anymore, so the whole migration is just removed.
return

View File

@@ -139,15 +139,13 @@ class Settings(metaclass=Singleton):
reversed_tuples(formatted_data.items())
)
for key, handler in (
('url_prefix', update_manifest),
('log_level', set_log_level)
if (
'log_level' in data
and formatted_data['log_level'] != getattr(
self.get_settings(), 'log_level'
)
):
if (
key in data
and formatted_data[key] != getattr(self.get_settings(), key)
):
handler(formatted_data[key])
set_log_level(formatted_data['log_level'])
self._fetch_settings()
@@ -232,24 +230,3 @@ class Settings(metaclass=Singleton):
raise InvalidKeyValue(key, value)
return converted_value
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.
"""
filename = folder_path('frontend', 'static', 'json', 'pwa_manifest.json')
with open(filename, 'r') as f:
manifest = load(f)
manifest['start_url'] = url_base + '/'
manifest['scope'] = url_base + '/'
manifest['icons'][0]['src'] = f'{url_base}/static/img/favicon.svg'
with open(filename, 'w') as f:
dump(manifest, f, indent=4)
return