fix
This commit is contained in:
@@ -7,7 +7,7 @@ let
|
|||||||
priority = toString (containerCfg.extra.priority or 2147482647);
|
priority = toString (containerCfg.extra.priority or 2147482647);
|
||||||
logoSvgFileName = builtins.baseNameOf (toString mediaCfg.logo.svg);
|
logoSvgFileName = builtins.baseNameOf (toString mediaCfg.logo.svg);
|
||||||
logoSvgMount = "/assets/${logoSvgFileName}";
|
logoSvgMount = "/assets/${logoSvgFileName}";
|
||||||
borderRadius = toString (containerCfg.extra.borderRadius or 16);
|
borderRadius = toString (containerCfg.extra.borderRadius or 32);
|
||||||
hostMappings = lib.mapAttrs' (mapping: profile:
|
hostMappings = lib.mapAttrs' (mapping: profile:
|
||||||
lib.nameValuePair
|
lib.nameValuePair
|
||||||
(if lib.hasInfix "." mapping then mapping else "${mapping}.${serverCfg.domain}")
|
(if lib.hasInfix "." mapping then mapping else "${mapping}.${serverCfg.domain}")
|
||||||
@@ -72,11 +72,6 @@ let
|
|||||||
return value if isinstance(value, str) and value else fallback
|
return value if isinstance(value, str) and value else fallback
|
||||||
|
|
||||||
|
|
||||||
def _badge_text(profile):
|
|
||||||
badge = profile.get("icon") or profile.get("label") or profile.get("text") or ""
|
|
||||||
return str(badge).strip()
|
|
||||||
|
|
||||||
|
|
||||||
def _tinted_logo_data_uri(color):
|
def _tinted_logo_data_uri(color):
|
||||||
svg = LOGO_BYTES.decode("utf-8")
|
svg = LOGO_BYTES.decode("utf-8")
|
||||||
svg = re.sub(
|
svg = re.sub(
|
||||||
@@ -103,6 +98,18 @@ let
|
|||||||
svg,
|
svg,
|
||||||
flags=re.IGNORECASE,
|
flags=re.IGNORECASE,
|
||||||
)
|
)
|
||||||
|
svg = re.sub(
|
||||||
|
r'fill\s*:\s*(?!none\b)[^;"\']+',
|
||||||
|
f"fill:{color}",
|
||||||
|
svg,
|
||||||
|
flags=re.IGNORECASE,
|
||||||
|
)
|
||||||
|
svg = re.sub(
|
||||||
|
r'stroke\s*:\s*(?!none\b)[^;"\']+',
|
||||||
|
f"stroke:{color}",
|
||||||
|
svg,
|
||||||
|
flags=re.IGNORECASE,
|
||||||
|
)
|
||||||
return "data:image/svg+xml;base64," + base64.b64encode(svg.encode("utf-8")).decode("ascii")
|
return "data:image/svg+xml;base64," + base64.b64encode(svg.encode("utf-8")).decode("ascii")
|
||||||
|
|
||||||
|
|
||||||
@@ -118,21 +125,13 @@ let
|
|||||||
bg = _color(profile.get("background"), "#111827")
|
bg = _color(profile.get("background"), "#111827")
|
||||||
fg = _color(profile.get("foreground"), "#f8fafc")
|
fg = _color(profile.get("foreground"), "#f8fafc")
|
||||||
accent = _color(profile.get("accent"), "#38bdf8")
|
accent = _color(profile.get("accent"), "#38bdf8")
|
||||||
badge = _badge_text(profile)
|
|
||||||
border_radius = _border_radius()
|
border_radius = _border_radius()
|
||||||
logo_data_uri = _tinted_logo_data_uri(fg)
|
logo_data_uri = _tinted_logo_data_uri(fg)
|
||||||
|
|
||||||
canvas = 256
|
canvas = 256
|
||||||
badge_svg = ""
|
badge_svg = f"""
|
||||||
if badge:
|
<circle cx="200" cy="56" r="34" fill="{accent}" />
|
||||||
badge_svg = f"""
|
"""
|
||||||
<text x="196" y="72"
|
|
||||||
font-family="DejaVu Sans, sans-serif"
|
|
||||||
font-size="72"
|
|
||||||
font-weight="900"
|
|
||||||
text-anchor="middle"
|
|
||||||
fill="{accent}">{badge}</text>
|
|
||||||
"""
|
|
||||||
|
|
||||||
return f"""<svg xmlns="http://www.w3.org/2000/svg" width="{canvas}" height="{canvas}" viewBox="0 0 {canvas} {canvas}">
|
return f"""<svg xmlns="http://www.w3.org/2000/svg" width="{canvas}" height="{canvas}" viewBox="0 0 {canvas} {canvas}">
|
||||||
<rect x="0" y="0" width="{canvas}" height="{canvas}" rx="{border_radius}" ry="{border_radius}" fill="{bg}" />
|
<rect x="0" y="0" width="{canvas}" height="{canvas}" rx="{border_radius}" ry="{border_radius}" fill="{bg}" />
|
||||||
|
|||||||
Reference in New Issue
Block a user