From 540b9d1470e5432b1cdc9d6eda9b4acc5f8b8df0 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Fri, 4 Nov 2022 19:28:21 +0100 Subject: [PATCH] Minor tweaks about non-root handling --- app/config.py | 11 +++++++++-- app/templates/login.html | 2 +- scripts/config_wizard.py | 2 -- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/config.py b/app/config.py index 241a0d1..ea736f4 100644 --- a/app/config.py +++ b/app/config.py @@ -90,7 +90,6 @@ class Config(pydantic.BaseModel): name: str summary: str https: bool - id: str = None icon_url: str secret: str debug: bool = False @@ -113,6 +112,9 @@ class Config(pydantic.BaseModel): sqlalchemy_database: str | None = None key_path: str | None = None + # Only set when the app is served on a non-root path + id: str | None = None + def load_config() -> Config: try: @@ -147,6 +149,9 @@ CONFIG = load_config() DOMAIN = CONFIG.domain _SCHEME = "https" if CONFIG.https else "http" ID = f"{_SCHEME}://{DOMAIN}" + +# When running the app on a path, the ID maybe set by the config, but in this +# case, a valid webfinger must be served on the root domain if CONFIG.id: ID = CONFIG.id USERNAME = CONFIG.username @@ -179,7 +184,9 @@ if CONFIG.emoji: EMOJIS = CONFIG.emoji # Emoji template for the FE -EMOJI_TPL = '{raw}' +EMOJI_TPL = ( + '{raw}' +) _load_emojis(ROOT_DIR, BASE_URL) diff --git a/app/templates/login.html b/app/templates/login.html index 5879158..bc0512d 100644 --- a/app/templates/login.html +++ b/app/templates/login.html @@ -7,7 +7,7 @@ {% if error %}

Invalid password.

{% endif %} -
+ diff --git a/scripts/config_wizard.py b/scripts/config_wizard.py index f5a75a2..22119e6 100644 --- a/scripts/config_wizard.py +++ b/scripts/config_wizard.py @@ -74,8 +74,6 @@ def main() -> None: dat["https"] = False proto = "http" - dat["id"] = f'{proto}://{dat["domain"]}' - print("Note that you can put your icon/avatar in the static/ directory") dat["icon_url"] = prompt( "icon URL: ", default=f'{proto}://{dat["domain"]}/static/nopic.png'