Fix icons in visualize.py

This commit is contained in:
Tobias Reisinger 2024-10-14 20:53:13 +02:00
parent 4104057771
commit 3408ba3c45
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE

View file

@ -18,6 +18,12 @@ icon_overrides = {
"woodpecker": None,
}
icon_format = {
"linkwarden": "webp",
"telegraf": "webp",
"tiny-tiny-rss": "webp",
}
template_host = """
'serguzim.net'.{host}: {{
label: {host}
@ -28,7 +34,7 @@ template_service = """
{key}: {{
label: {label}
label.near: top-left
icon: https://cdn.jsdelivr.net/gh/selfhst/icons/webp/{icon}.webp
icon: {icon}
icon.near: top-right
}}
"""
@ -53,6 +59,11 @@ external: {
}
"""
def get_icon(svc):
svc = icon_overrides.get(svc, svc) or 'docker'
fmt = icon_format.get(svc, 'svg')
return f'https://cdn.jsdelivr.net/gh/selfhst/icons/{fmt}/{svc}.{fmt}'
def service_key(svc, data):
return f"'serguzim.net'.{data['host']}.{svc}"
@ -95,7 +106,7 @@ def parse_services(services):
result.append(template_service.format(
key=svc_key,
label="\\n".join([svc] + domains),
icon=icon_overrides.get(svc, svc) or "docker",
icon=get_icon(svc)
))
for backup in data.get("backup") or []: