Add default theme option

Dark mode can be set as the default theme by setting 'DARK_MODE' environment variable to 'true' in the docker compose file
pull/279/head
Rithas K 2023-06-19 16:30:13 +05:30
parent d3bc5d39a1
commit eead6acbf5
1 changed files with 6 additions and 3 deletions

View File

@ -29,10 +29,11 @@ class Config:
'YTDL_OPTIONS': '{}', 'YTDL_OPTIONS': '{}',
'HOST': '0.0.0.0', 'HOST': '0.0.0.0',
'PORT': '8081', 'PORT': '8081',
'BASE_DIR': '' 'BASE_DIR': '',
'DARK_MODE': 'false'
} }
_BOOLEAN = ('DOWNLOAD_DIRS_INDEXABLE', 'CUSTOM_DIRS', 'CREATE_CUSTOM_DIRS', 'DELETE_FILE_ON_TRASHCAN') _BOOLEAN = ('DOWNLOAD_DIRS_INDEXABLE', 'CUSTOM_DIRS', 'CREATE_CUSTOM_DIRS', 'DELETE_FILE_ON_TRASHCAN', 'DARK_MODE')
def __init__(self): def __init__(self):
for k, v in self._DEFAULTS.items(): for k, v in self._DEFAULTS.items():
@ -153,7 +154,9 @@ def get_custom_dirs():
@routes.get(config.URL_PREFIX) @routes.get(config.URL_PREFIX)
def index(request): def index(request):
return web.FileResponse(os.path.join(config.BASE_DIR, 'ui/dist/metube/index.html')) response = web.FileResponse(os.path.join(config.BASE_DIR, 'ui/dist/metube/index.html'))
response.set_cookie('metube_dark', 'true' if config.DARK_MODE else 'false')
return response
if config.URL_PREFIX != '/': if config.URL_PREFIX != '/':
@routes.get('/') @routes.get('/')