mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
portal: store custom logos in a /usr/share/yunohost/customassets, and only store the file id which the front should then query as a regular asset
This commit is contained in:
parent
f248086fb6
commit
c77d05e693
3 changed files with 5 additions and 14 deletions
|
@ -30,9 +30,9 @@ base_folder_and_perm_init() {
|
||||||
chmod 500 /etc/yunohost/portal
|
chmod 500 /etc/yunohost/portal
|
||||||
chown ynh-portal:ynh-portal /etc/yunohost/portal
|
chown ynh-portal:ynh-portal /etc/yunohost/portal
|
||||||
|
|
||||||
mkdir -p /usr/share/yunohost/portallogos
|
mkdir -p /usr/share/yunohost/portal/customassets
|
||||||
chmod 550 /usr/share/yunohost/portallogos
|
chmod 775 /usr/share/yunohost/portal/customassets
|
||||||
chown ynh-portal:www-data /usr/share/yunohost/portallogos
|
chown root:root /usr/share/yunohost/customassets
|
||||||
|
|
||||||
touch /var/log/yunohost-portalapi.log
|
touch /var/log/yunohost-portalapi.log
|
||||||
chown ynh-portal:root /var/log/yunohost-portalapi.log
|
chown ynh-portal:root /var/log/yunohost-portalapi.log
|
||||||
|
|
|
@ -20,7 +20,7 @@ name = "Features"
|
||||||
type = "file"
|
type = "file"
|
||||||
accept = ["image/png", "image/jpeg", "image/svg+xml"]
|
accept = ["image/png", "image/jpeg", "image/svg+xml"]
|
||||||
mode = "python"
|
mode = "python"
|
||||||
bind = "/usr/share/yunohost/portallogos/{filename}{ext}"
|
bind = "/usr/share/yunohost/portal/customassets/{filename}{ext}"
|
||||||
|
|
||||||
[feature.portal.portal_theme]
|
[feature.portal.portal_theme]
|
||||||
type = "select"
|
type = "select"
|
||||||
|
|
|
@ -810,16 +810,7 @@ def _get_DomainConfigPanel():
|
||||||
portal_values["portal_logo"] = ""
|
portal_values["portal_logo"] = ""
|
||||||
|
|
||||||
if next_settings["portal_logo"]:
|
if next_settings["portal_logo"]:
|
||||||
# Save the file content as `{mimetype}:{base64content}` in portal settings
|
portal_values["portal_logo"] = Path(next_settings["portal_logo"]).name
|
||||||
# while keeping the file path in the domain settings
|
|
||||||
from base64 import b64encode
|
|
||||||
from magic import Magic
|
|
||||||
|
|
||||||
file_content = Path(next_settings["portal_logo"]).read_bytes()
|
|
||||||
mimetype = Magic(mime=True).from_buffer(file_content)
|
|
||||||
portal_values["portal_logo"] = (
|
|
||||||
mimetype + ":" + b64encode(file_content).decode("utf-8")
|
|
||||||
)
|
|
||||||
|
|
||||||
portal_settings_path = Path(f"{PORTAL_SETTINGS_DIR}/{self.entity}.json")
|
portal_settings_path = Path(f"{PORTAL_SETTINGS_DIR}/{self.entity}.json")
|
||||||
portal_settings: dict[str, Any] = {"apps": {}}
|
portal_settings: dict[str, Any] = {"apps": {}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue