commit f556cb5

default  ·  2023-09-18 09:49:27 +0000 UTC
parent c4b2d3b
Show metadata in the public HTML page.
1 files changed,  +26, -0
M html.c
M html.c
+26, -0
 1@@ -481,6 +481,32 @@ xs_str *html_user_header(snac *snac, xs_str *s, int local)
 2             xs *s1   = xs_fmt("<div class=\"p-note snac-top-user-bio\">%s</div>\n", bio2);
 3 
 4             s = xs_str_cat(s, s1);
 5+
 6+            xs_dict *metadata = xs_dict_get(snac->config, "metadata");
 7+            if (xs_type(metadata) == XSTYPE_DICT) {
 8+                xs_str *k;
 9+                xs_str *v;
10+
11+                s = xs_str_cat(s, "<br><div class=\"snac-metadata\">\n");
12+
13+                while (xs_dict_iter(&metadata, &k, &v)) {
14+                    xs *k2 = encode_html(k);
15+                    xs *v2 = encode_html(v);
16+                    xs *v3 = NULL;
17+
18+                    if (xs_startswith(v, "https:/" "/"))
19+                        v3 = xs_fmt("<a href=\"%s\">%s</a>", v2, v2);
20+                    else
21+                        v3 = xs_dup(v2);
22+
23+                    xs *s1 = xs_fmt("<span class=\"snac-property-name\">%s</span>:<br>"
24+                            "<span class=\"snac-property-value\">%s</span><br>\n", k2, v3);
25+
26+                    s = xs_str_cat(s, s1);
27+                }
28+
29+                s = xs_str_cat(s, "</div>\n");
30+            }
31         }
32 
33         s = xs_str_cat(s, "</div>\n");