diff --git a/locales/en.json b/locales/en.json index d47447e14..9a427b159 100644 --- a/locales/en.json +++ b/locales/en.json @@ -425,6 +425,8 @@ "global_settings_setting_ssh_password_authentication_help": "Allow password authentication for SSH", "global_settings_setting_ssh_port": "SSH port", "global_settings_setting_ssowat_panel_overlay_enabled": "Enable the small 'YunoHost' portal shortcut square on apps", + "global_settings_setting_portal_theme": "Portal theme", + "global_settings_setting_portal_theme_help": "More info regarding creating custom portal themes at https://yunohost.org/theming", "global_settings_setting_user_strength": "User password strength requirements", "global_settings_setting_user_strength_help": "These requirements are only enforced when initializing or changing the password", "global_settings_setting_webadmin_allowlist": "Webadmin IP allowlist", diff --git a/share/config_global.toml b/share/config_global.toml index 51754166c..1f3cc1b39 100644 --- a/share/config_global.toml +++ b/share/config_global.toml @@ -149,7 +149,12 @@ name = "Other" [misc.portal.ssowat_panel_overlay_enabled] type = "boolean" default = true - + + [misc.portal.portal_theme] + type = "select" + # Choices are loaded dynamically in the python code + default = "default" + [misc.backup] name = "Backup" [misc.backup.backup_compress_tar_archives] diff --git a/src/app.py b/src/app.py index dd8b92a02..1a6e01e0e 100644 --- a/src/app.py +++ b/src/app.py @@ -1471,6 +1471,7 @@ def app_ssowatconf(): """ from yunohost.domain import domain_list, _get_maindomain, domain_config_get from yunohost.permission import user_permission_list + from yunohost.settings import settings_get main_domain = _get_maindomain() domains = domain_list()["domains"] @@ -1550,6 +1551,7 @@ def app_ssowatconf(): } conf_dict = { + "theme": settings_get("misc.portal.portal_theme"), "portal_domain": main_domain, "portal_path": "/yunohost/sso/", "additional_headers": { diff --git a/src/settings.py b/src/settings.py index 5fed8a8a3..f84ff0d4d 100644 --- a/src/settings.py +++ b/src/settings.py @@ -164,6 +164,20 @@ class SettingsConfigPanel(ConfigPanel): logger.error(f"Post-change hook for setting failed : {e}") raise + def _get_toml(self): + + toml = super()._get_toml() + + # Dynamic choice list for portal themes + THEMEDIR = "/usr/share/ssowat/portal/assets/themes/" + try: + themes = [d for d in os.listdir(THEMEDIR) if os.path.isdir(THEMEDIR + d)] + except Exception: + themes = ['unsplash', 'vapor', 'light', 'default', 'clouds'] + toml["misc"]["portal"]["portal_theme"]["choices"] = themes + + return toml + def _load_current_values(self): super()._load_current_values() @@ -271,6 +285,11 @@ def trigger_post_change_hook(setting_name, old_value, new_value): # # =========================================== +@post_change_hook("portal_theme") +def regen_ssowatconf(setting_name, old_value, new_value): + if old_value != new_value: + from yunohost.app import app_ssowatconf + app_ssowatconf() @post_change_hook("ssowat_panel_overlay_enabled") @post_change_hook("nginx_redirect_to_https")