|
|
|
|
@ -72,12 +72,15 @@ def format_nip05_chips_html(
@@ -72,12 +72,15 @@ def format_nip05_chips_html(
|
|
|
|
|
container_margin_top: str | None = None, |
|
|
|
|
) -> str: |
|
|
|
|
""" |
|
|
|
|
Horizontal row of NIP-05 chips: identifier with domain favicon in place of ``@``, plus verification mark. |
|
|
|
|
NIP-05 lines for rich text (e.g. ``QTextBrowser``): domain favicon replaces ``@`` between local and domain. |
|
|
|
|
|
|
|
|
|
Uses block / inline-block and explicit margins — Qt's HTML subset ignores ``display:flex`` and ``gap``, |
|
|
|
|
which is why a flex row collapses into an illegible run. |
|
|
|
|
|
|
|
|
|
``bool | None``: ``True`` verified, ``False`` failed, ``None`` pending / not checked. |
|
|
|
|
""" |
|
|
|
|
parts: list[str] = [] |
|
|
|
|
for ident, okv in identifiers: |
|
|
|
|
for i, (ident, okv) in enumerate(identifiers): |
|
|
|
|
parsed = parse_nip05_identifier(ident) |
|
|
|
|
dom = parsed[1] if parsed else "" |
|
|
|
|
fav = favicon_url_for_domain(dom) if dom else "" |
|
|
|
|
@ -92,47 +95,53 @@ def format_nip05_chips_html(
@@ -92,47 +95,53 @@ def format_nip05_chips_html(
|
|
|
|
|
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 style="color:{muted};font-size:14px;line-height:1.55" title="{esc_full_attr}">' |
|
|
|
|
f'<span style="display:inline-block;margin-right:10px;vertical-align:middle">{esc_local}</span>' |
|
|
|
|
f'<img src="{esc_fav}" width="16" height="16" alt="" ' |
|
|
|
|
f'style="display:inline-block;vertical-align:middle;margin:0 14px;border-radius:3px;opacity:0.95" />' |
|
|
|
|
f'<span style="display:inline-block;margin-left:10px;vertical-align:middle">{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>' |
|
|
|
|
f'<span style="color:{muted};font-size:14px;line-height:1.55" title="{esc_full_attr}">{esc_full}</span>' |
|
|
|
|
) |
|
|
|
|
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="display:inline-block;margin-left:22px;vertical-align:middle;' |
|
|
|
|
f'color:{ok};font-size:16px;line-height:1" title="NIP-05 verified">✓</span>' |
|
|
|
|
) |
|
|
|
|
elif okv is False: |
|
|
|
|
mark = f'<span style="color:{bad};font-size:15px;line-height:1" title="NIP-05 not verified">✗</span>' |
|
|
|
|
mark = ( |
|
|
|
|
f'<span style="display:inline-block;margin-left:22px;vertical-align:middle;' |
|
|
|
|
f'color:{bad};font-size:16px;line-height:1" title="NIP-05 not verified">✗</span>' |
|
|
|
|
) |
|
|
|
|
else: |
|
|
|
|
mark = f'<span style="color:{dim};font-size:15px;line-height:1" title="NIP-05 not verified yet">○</span>' |
|
|
|
|
mark = ( |
|
|
|
|
f'<span style="display:inline-block;margin-left:22px;vertical-align:middle;' |
|
|
|
|
f'color:{dim};font-size:16px;line-height:1" title="NIP-05 not verified yet">○</span>' |
|
|
|
|
) |
|
|
|
|
row_mt = "0" if i == 0 else "20px" |
|
|
|
|
if chip_bg: |
|
|
|
|
brd = chip_border or dim |
|
|
|
|
wrap = ( |
|
|
|
|
"display:inline-flex;align-items:center;gap:10px;padding:10px 18px;" |
|
|
|
|
"margin:0 12px 10px 0;" |
|
|
|
|
f"border-radius:999px;background:{chip_bg};border:1px solid {brd}" |
|
|
|
|
row = ( |
|
|
|
|
f'<div style="margin-top:{row_mt};padding:12px 14px 12px 14px;' |
|
|
|
|
f'border-radius:12px;background:{chip_bg};border:1px solid {brd}">' |
|
|
|
|
f"{id_body}{mark}</div>" |
|
|
|
|
) |
|
|
|
|
else: |
|
|
|
|
wrap = ( |
|
|
|
|
"display:inline-flex;align-items:center;gap:8px;padding:4px 4px 4px 0;" |
|
|
|
|
"margin:0 16px 6px 0" |
|
|
|
|
row = ( |
|
|
|
|
f'<div style="margin-top:{row_mt};padding:12px 8px 14px 4px;line-height:1.6">' |
|
|
|
|
f"{id_body}{mark}</div>" |
|
|
|
|
) |
|
|
|
|
parts.append(f'<span style="{wrap}">{id_body}{mark}</span>') |
|
|
|
|
parts.append(row) |
|
|
|
|
if not parts: |
|
|
|
|
return "" |
|
|
|
|
if container_margin_top is not None: |
|
|
|
|
mt = container_margin_top |
|
|
|
|
else: |
|
|
|
|
mt = "14px" if chip_bg else "4px" |
|
|
|
|
return ( |
|
|
|
|
f'<div style="display:flex;flex-wrap:wrap;align-items:flex-start;' |
|
|
|
|
f'gap:10px 14px;margin-top:{mt}">{"".join(parts)}</div>' |
|
|
|
|
) |
|
|
|
|
return f'<div style="margin-top:{mt}">{"".join(parts)}</div>' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def feed_op_author_compact_html( |
|
|
|
|
@ -166,6 +175,7 @@ def feed_op_author_compact_html(
@@ -166,6 +175,7 @@ def feed_op_author_compact_html(
|
|
|
|
|
f'<div style="color:{dim};font-size:13px;line-height:1.5;margin:0">{event_meta_inner_html}</div>' |
|
|
|
|
) |
|
|
|
|
row_mt = "12px" if nip38_block else "8px" |
|
|
|
|
# ``QTextBrowser`` / ``QTextDocument`` ignore most flexbox; use a table so avatar + npub sit side‑by‑side. |
|
|
|
|
return ( |
|
|
|
|
f'<div style="background:{header_bg};border:1px solid {border};border-radius:10px;' |
|
|
|
|
f'padding:14px 16px 18px;margin:0 0 22px 0">' |
|
|
|
|
@ -174,16 +184,18 @@ def feed_op_author_compact_html(
@@ -174,16 +184,18 @@ def feed_op_author_compact_html(
|
|
|
|
|
f"{name_e}</div>" |
|
|
|
|
f"</a>" |
|
|
|
|
f"{nip38_block}" |
|
|
|
|
f'<div style="display:flex;align-items:flex-start;gap:14px;margin-top:{row_mt}">' |
|
|
|
|
f"{av}" |
|
|
|
|
f'<div style="flex:1;min-width:0;display:flex;flex-direction:column;gap:12px">' |
|
|
|
|
f'<table style="margin-top:{row_mt};width:100%;border:none;border-collapse:collapse" ' |
|
|
|
|
f'cellpadding="0" cellspacing="0"><tr>' |
|
|
|
|
f'<td style="vertical-align:top;padding:0 14px 0 0;width:1px">{av}</td>' |
|
|
|
|
f'<td style="vertical-align:top;padding:0">' |
|
|
|
|
f'<a href="{href}" style="text-decoration:none;color:inherit" title="View profile">' |
|
|
|
|
f'<div style="font-size:13px;color:{dim};font-family:ui-monospace,Cascadia Mono,Consolas,monospace;' |
|
|
|
|
f'line-height:1.5;word-break:break-all" title="{npub_title}">{npub_line}</div>' |
|
|
|
|
f'line-height:1.5;word-break:break-all;margin:0 0 14px 0" title="{npub_title}">{npub_line}</div>' |
|
|
|
|
f"</a>" |
|
|
|
|
f"{nip05_chips_html}" |
|
|
|
|
f'<div style="margin:0 0 12px 0">{nip05_chips_html}</div>' |
|
|
|
|
f"{meta_block}" |
|
|
|
|
f"</div></div></div>" |
|
|
|
|
f"</td></tr></table>" |
|
|
|
|
f"</div>" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|