Add a global setting to choose SSOwat's theme

This commit is contained in:
Alexandre Aubin 2022-12-06 20:20:24 +01:00
parent 83bdfab255
commit 08521882ca
4 changed files with 24 additions and 1 deletions

View file

@ -424,6 +424,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",

View file

@ -144,7 +144,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]

View file

@ -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": {

View file

@ -163,6 +163,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()