commit 645a27d
default
·
2023-11-28 09:35:57 +0000 UTC
parent 179a7ae
Converted public user into to xs_html.
1 files changed,
+29,
-13
M
html.c
M
html.c
+29,
-13
1@@ -774,34 +774,50 @@ xs_str *html_user_header(snac *snac, xs_str *s, int local)
2 xs *bio1 = not_really_markdown(es1, NULL);
3 xs *tags = xs_list_new();
4 xs *bio2 = process_tags(snac, bio1, &tags);
5- xs *s1 = xs_fmt("<div class=\"p-note snac-top-user-bio\">%s</div>\n", bio2);
6
7- s = xs_str_cat(s, s1);
8+ xs_html *top_user_bio = xs_html_tag("div",
9+ xs_html_attr("class", "p-note snac-top-user-bio"),
10+ xs_html_raw(bio2)); /* already sanitized */
11+
12+ {
13+ xs *s1 = xs_html_render(top_user_bio);
14+ s = xs_str_cat(s, s1);
15+ }
16
17 xs_dict *metadata = xs_dict_get(snac->config, "metadata");
18 if (xs_type(metadata) == XSTYPE_DICT) {
19 xs_str *k;
20 xs_str *v;
21
22- s = xs_str_cat(s, "<br><div class=\"snac-metadata\">\n");
23+ xs_html *snac_metadata = xs_html_tag("div",
24+ xs_html_attr("class", "snac-metadata"));
25
26 while (xs_dict_iter(&metadata, &k, &v)) {
27- xs *k2 = encode_html(k);
28- xs *v2 = encode_html(v);
29- xs *v3 = NULL;
30+ xs_html *value;
31
32 if (xs_startswith(v, "https:/" "/"))
33- v3 = xs_fmt("<a href=\"%s\">%s</a>", v2, v2);
34+ value = xs_html_tag("a",
35+ xs_html_attr("href", v),
36+ xs_html_text(v));
37 else
38- v3 = xs_dup(v2);
39-
40- xs *s1 = xs_fmt("<span class=\"snac-property-name\">%s</span>:<br>"
41- "<span class=\"snac-property-value\">%s</span><br>\n", k2, v3);
42+ value = xs_html_text(v);
43+
44+ xs_html_add(snac_metadata,
45+ xs_html_tag("span",
46+ xs_html_attr("class", "snac-property-name"),
47+ xs_html_text(k)),
48+ xs_html_text(":"),
49+ xs_html_sctag("br", NULL),
50+ xs_html_tag("span",
51+ xs_html_attr("class", "snac-property-value"),
52+ value),
53+ xs_html_sctag("br", NULL));
54+ }
55
56+ {
57+ xs *s1 = xs_html_render(snac_metadata);
58 s = xs_str_cat(s, s1);
59 }
60-
61- s = xs_str_cat(s, "</div>\n");
62 }
63 }
64