mirror of
https://github.com/Casvt/MIND.git
synced 2026-04-03 03:00:22 -04:00
Converted manifest file into dynamic endpoint
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user