mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
domain/portal: try to re-implement portal logo
This commit is contained in:
parent
90aa6b86f1
commit
566f5d29a7
4 changed files with 31 additions and 4 deletions
2
debian/control
vendored
2
debian/control
vendored
|
@ -15,7 +15,7 @@ Depends: ${python3:Depends}, ${misc:Depends}
|
||||||
, python3-miniupnpc, python3-dbus, python3-jinja2
|
, python3-miniupnpc, python3-dbus, python3-jinja2
|
||||||
, python3-toml, python3-packaging, python3-publicsuffix2
|
, python3-toml, python3-packaging, python3-publicsuffix2
|
||||||
, python3-ldap, python3-zeroconf (>= 0.47), python3-lexicon,
|
, python3-ldap, python3-zeroconf (>= 0.47), python3-lexicon,
|
||||||
, python3-cryptography, python3-jwt
|
, python3-cryptography, python3-jwt, python3-magic
|
||||||
, python-is-python3, python3-pydantic, python3-email-validator
|
, python-is-python3, python3-pydantic, python3-email-validator
|
||||||
, nginx, nginx-extras (>=1.22)
|
, nginx, nginx-extras (>=1.22)
|
||||||
, apt, apt-transport-https, apt-utils, dirmngr
|
, apt, apt-transport-https, apt-utils, dirmngr
|
||||||
|
|
|
@ -71,6 +71,9 @@ do_init_regen() {
|
||||||
mkdir -p /etc/yunohost/portal
|
mkdir -p /etc/yunohost/portal
|
||||||
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
|
||||||
|
chmod 550 /usr/share/yunohost/portallogos
|
||||||
|
chown ynh-portal:www-data /usr/share/yunohost/portallogos
|
||||||
|
|
||||||
# YunoHost services
|
# YunoHost services
|
||||||
cp yunohost-api.service /etc/systemd/system/yunohost-api.service
|
cp yunohost-api.service /etc/systemd/system/yunohost-api.service
|
||||||
|
@ -253,6 +256,9 @@ do_post_regen() {
|
||||||
mkdir -p /etc/yunohost/portal
|
mkdir -p /etc/yunohost/portal
|
||||||
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
|
||||||
|
chmod 550 /usr/share/yunohost/portallogos
|
||||||
|
chown ynh-portal:www-data /usr/share/yunohost/portallogos
|
||||||
|
|
||||||
# Domain settings
|
# Domain settings
|
||||||
mkdir -p /etc/yunohost/domains
|
mkdir -p /etc/yunohost/domains
|
||||||
|
|
|
@ -15,8 +15,8 @@ name = "Features"
|
||||||
type = "string"
|
type = "string"
|
||||||
default = "YunoHost"
|
default = "YunoHost"
|
||||||
|
|
||||||
# [feature.portal.portal_logo]
|
[feature.portal.portal_logo]
|
||||||
# type = "file"
|
type = "file"
|
||||||
|
|
||||||
[feature.portal.portal_theme]
|
[feature.portal.portal_theme]
|
||||||
type = "select"
|
type = "select"
|
||||||
|
|
|
@ -758,9 +758,30 @@ class DomainConfigPanel(ConfigPanel):
|
||||||
"default_app",
|
"default_app",
|
||||||
"show_other_domains_apps",
|
"show_other_domains_apps",
|
||||||
"portal_title",
|
"portal_title",
|
||||||
# "portal_logo",
|
"portal_logo",
|
||||||
"portal_theme",
|
"portal_theme",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if "portal_logo" in next_settings:
|
||||||
|
|
||||||
|
import magic, hashlib
|
||||||
|
with open(next_settings["portal_logo"], "rb") as f:
|
||||||
|
file_content = f.read()
|
||||||
|
mimetype = magic.Magic(mime=True).from_buffer(file_content)
|
||||||
|
if mimetype not in ["image/png", "image/jpeg"]:
|
||||||
|
raise YunohostValidationError(f"Unsupported image type : {mimetype}", raw=True)
|
||||||
|
ext = mimetype.split("/")[-1]
|
||||||
|
m = hashlib.sha256()
|
||||||
|
m.update(file_content)
|
||||||
|
sha256sum = m.hexdigest()
|
||||||
|
filename = f"/usr/share/yunohost/portallogos/{sha256sum}.{ext}"
|
||||||
|
with open(filename, "wb") as f:
|
||||||
|
f.write(file_content)
|
||||||
|
next_settings["portal_logo"] = filename
|
||||||
|
# FIXME : the previous line doesn't actually set anything in the actual form ...
|
||||||
|
# ... and calling `form.portal_logo = filename` would actually make it sort of "re-upload" the file to another place ...
|
||||||
|
# not sure how to address this issue ...
|
||||||
|
|
||||||
if _get_parent_domain_of(self.entity, topest=True) is None and any(
|
if _get_parent_domain_of(self.entity, topest=True) is None and any(
|
||||||
option in next_settings for option in portal_options
|
option in next_settings for option in portal_options
|
||||||
):
|
):
|
||||||
|
|
Loading…
Add table
Reference in a new issue