Browse Source

move favicon

master
Silberengel 2 weeks ago
parent
commit
06b5d2ae08
  1. 38
      src/imwald/core/author_html.py

38
src/imwald/core/author_html.py

@ -72,7 +72,7 @@ def format_nip05_chips_html(
container_margin_top: str | None = None, container_margin_top: str | None = None,
) -> str: ) -> str:
""" """
Horizontal row of NIP-05 chips: favicon (per domain), identifier, verification mark. Horizontal row of NIP-05 chips: identifier with domain favicon in place of ``@``, plus verification mark.
``bool | None``: ``True`` verified, ``False`` failed, ``None`` pending / not checked. ``bool | None``: ``True`` verified, ``False`` failed, ``None`` pending / not checked.
""" """
@ -81,13 +81,28 @@ def format_nip05_chips_html(
parsed = parse_nip05_identifier(ident) parsed = parse_nip05_identifier(ident)
dom = parsed[1] if parsed else "" dom = parsed[1] if parsed else ""
fav = favicon_url_for_domain(dom) if dom else "" fav = favicon_url_for_domain(dom) if dom else ""
esc = html.escape(ident, quote=False) esc_full = html.escape(ident.strip(), quote=False)
esc_full_attr = html.escape(ident.strip(), quote=True)
esc_fav = html.escape(fav, quote=True) if fav else "" esc_fav = html.escape(fav, quote=True) if fav else ""
icon = "" raw = ident.strip()
if fav: at_split = raw.rpartition("@") if "@" in raw else ("", "", "")
icon = ( local_raw, _at, dom_raw = at_split
f'<img src="{esc_fav}" width="14" height="14" alt="" ' id_body: str
f'style="vertical-align:middle;border-radius:3px;opacity:0.92" />' if fav and local_raw and dom_raw:
esc_local = html.escape(local_raw, quote=False)
esc_dom = html.escape(dom_raw, quote=False)
id_body = (
f'<span style="display:inline-flex;align-items:center;gap:5px;flex-wrap:nowrap" '
f'title="{esc_full_attr}">'
f'<span style="color:{muted};font-size:14px;line-height:1.45">{esc_local}</span>'
f'<img src="{esc_fav}" width="15" height="15" alt="" '
f'style="display:block;border-radius:3px;opacity:0.95;flex-shrink:0" />'
f'<span style="color:{muted};font-size:14px;line-height:1.45">{esc_dom}</span>'
f"</span>"
)
else:
id_body = (
f'<span style="color:{muted};font-size:14px;line-height:1.45" title="{esc_full_attr}">{esc_full}</span>'
) )
if okv is True: if okv is True:
mark = f'<span style="color:{ok};font-size:15px;line-height:1" title="NIP-05 verified">✓</span>' mark = f'<span style="color:{ok};font-size:15px;line-height:1" title="NIP-05 verified">✓</span>'
@ -104,15 +119,10 @@ def format_nip05_chips_html(
) )
else: else:
wrap = ( wrap = (
"display:inline-flex;align-items:center;gap:10px;padding:4px 4px 4px 0;" "display:inline-flex;align-items:center;gap:8px;padding:4px 4px 4px 0;"
"margin:0 16px 6px 0" "margin:0 16px 6px 0"
) )
parts.append( parts.append(f'<span style="{wrap}">{id_body}{mark}</span>')
f'<span style="{wrap}">'
f"{icon}"
f'<span style="color:{muted};font-size:14px;line-height:1.45">{esc}</span>{mark}'
f"</span>"
)
if not parts: if not parts:
return "" return ""
if container_margin_top is not None: if container_margin_top is not None:

Loading…
Cancel
Save