mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
portal: allow to configure custom CSS from the domain config panel
This commit is contained in:
parent
a6b7ba8435
commit
8f636561d9
3 changed files with 27 additions and 0 deletions
|
@ -17,5 +17,12 @@ location /yunohost/sso/ {
|
||||||
alias /usr/share/yunohost/applogos/;
|
alias /usr/share/yunohost/applogos/;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location = /yunohost/sso/customassets/custom.css {
|
||||||
|
alias /usr/share/yunohost/portal/customassets/$host.custom.css;
|
||||||
|
etag off;
|
||||||
|
expires off;
|
||||||
|
more_set_headers "Cache-Control: no-store, no-cache, must-revalidate";
|
||||||
|
}
|
||||||
|
|
||||||
more_set_headers "Content-Security-Policy: upgrade-insecure-requests; default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; object-src 'none'; img-src 'self' data:;";
|
more_set_headers "Content-Security-Policy: upgrade-insecure-requests; default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; object-src 'none'; img-src 'self' data:;";
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,10 @@ name = "Features"
|
||||||
|
|
||||||
# FIXME link to GCU
|
# FIXME link to GCU
|
||||||
|
|
||||||
|
[feature.portal.custom_css]
|
||||||
|
# NB: this is wrote into "/usr/share/yunohost/portal/customassets/{domain}.custom.css"
|
||||||
|
type = "text"
|
||||||
|
|
||||||
[feature.app]
|
[feature.app]
|
||||||
[feature.app.default_app]
|
[feature.app.default_app]
|
||||||
type = "app"
|
type = "app"
|
||||||
|
|
|
@ -29,6 +29,7 @@ from moulinette.utils.filesystem import (
|
||||||
read_json,
|
read_json,
|
||||||
read_yaml,
|
read_yaml,
|
||||||
rm,
|
rm,
|
||||||
|
read_file,
|
||||||
write_to_file,
|
write_to_file,
|
||||||
write_to_json,
|
write_to_json,
|
||||||
write_to_yaml,
|
write_to_yaml,
|
||||||
|
@ -735,6 +736,15 @@ def _get_DomainConfigPanel():
|
||||||
|
|
||||||
return raw_config
|
return raw_config
|
||||||
|
|
||||||
|
def _get_raw_settings(self) -> "RawSettings":
|
||||||
|
raw_settings = super()._get_raw_settings()
|
||||||
|
|
||||||
|
custom_css = Path(f"/usr/share/yunohost/portal/customassets/{self.entity}.custom.css")
|
||||||
|
if custom_css.exists():
|
||||||
|
raw_settings["custom_css"] = read_file(str(custom_css))
|
||||||
|
|
||||||
|
return raw_settings
|
||||||
|
|
||||||
def _apply(
|
def _apply(
|
||||||
self,
|
self,
|
||||||
form: "FormModel",
|
form: "FormModel",
|
||||||
|
@ -761,6 +771,12 @@ def _get_DomainConfigPanel():
|
||||||
self.entity, next_settings["recovery_password"]
|
self.entity, next_settings["recovery_password"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
custom_css = next_settings.pop("custom_css", "").strip()
|
||||||
|
if custom_css:
|
||||||
|
write_to_file(f"/usr/share/yunohost/portal/customassets/{self.entity}.custom.css", custom_css)
|
||||||
|
# Make sure the value doesnt get written in the yml
|
||||||
|
form.custom_css = ""
|
||||||
|
|
||||||
portal_options = [
|
portal_options = [
|
||||||
"default_app",
|
"default_app",
|
||||||
"show_other_domains_apps",
|
"show_other_domains_apps",
|
||||||
|
|
Loading…
Add table
Reference in a new issue