fix
This commit is contained in:
@@ -7,7 +7,7 @@ let
|
||||
priority = toString (containerCfg.extra.priority or 2147482647);
|
||||
logoSvgFileName = builtins.baseNameOf (toString mediaCfg.logo.svg);
|
||||
logoSvgMount = "/assets/${logoSvgFileName}";
|
||||
borderRadius = toString (containerCfg.extra.borderRadius or 16);
|
||||
borderRadius = toString (containerCfg.extra.borderRadius or 32);
|
||||
hostMappings = lib.mapAttrs' (mapping: profile:
|
||||
lib.nameValuePair
|
||||
(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
|
||||
|
||||
|
||||
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):
|
||||
svg = LOGO_BYTES.decode("utf-8")
|
||||
svg = re.sub(
|
||||
@@ -103,6 +98,18 @@ let
|
||||
svg,
|
||||
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")
|
||||
|
||||
|
||||
@@ -118,20 +125,12 @@ let
|
||||
bg = _color(profile.get("background"), "#111827")
|
||||
fg = _color(profile.get("foreground"), "#f8fafc")
|
||||
accent = _color(profile.get("accent"), "#38bdf8")
|
||||
badge = _badge_text(profile)
|
||||
border_radius = _border_radius()
|
||||
logo_data_uri = _tinted_logo_data_uri(fg)
|
||||
|
||||
canvas = 256
|
||||
badge_svg = ""
|
||||
if badge:
|
||||
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>
|
||||
<circle cx="200" cy="56" r="34" fill="{accent}" />
|
||||
"""
|
||||
|
||||
return f"""<svg xmlns="http://www.w3.org/2000/svg" width="{canvas}" height="{canvas}" viewBox="0 0 {canvas} {canvas}">
|
||||
|
||||
Reference in New Issue
Block a user