commit 20f8972
green
·
2025-05-12 11:54:06 +0000 UTC
parent 2a617bc
metadata for remote users in people page
1 files changed,
+40,
-0
M
html.c
M
html.c
+40,
-0
1@@ -3357,6 +3357,46 @@ xs_html *html_people_list(snac *user, xs_list *list, const char *header, const c
2 xs_html_add(snac_post, snac_content);
3 }
4
5+ /* add user metadata */
6+ xs_html *snac_metadata = xs_html_tag("div",
7+ xs_html_attr("class", "snac-metadata"));
8+
9+ int count = 0;
10+ const xs_val *v;
11+ const xs_list *attachment = xs_dict_get(actor, "attachment");
12+ xs_list_foreach(attachment, v) {
13+ const char *type = xs_dict_get(v, "type");
14+ const char *name = xs_dict_get(v, "name");
15+ const char *value = xs_dict_get(v, "value");
16+
17+ if (!xs_is_null(type) && !xs_is_null(name) &&
18+ !xs_is_null(value) && strcmp(type, "PropertyValue") == 0) {
19+ xs *val = sanitize(value);
20+ val = replace_shortnames(val, xs_dict_get(actor, "tag"), 1, proxy);
21+
22+ xs_html_add(snac_metadata,
23+ xs_html_tag("span",
24+ xs_html_attr("class", "snac-property-name"),
25+ xs_html_text(name)),
26+ xs_html_text(":"),
27+ xs_html_raw(" "),
28+ xs_html_tag("span",
29+ xs_html_attr("class", "snac-property-value"),
30+ xs_html_raw(val)),
31+ xs_html_sctag("br", NULL));
32+
33+ count++;
34+ }
35+ }
36+
37+ if (count > 0) {
38+ xs_html_add(snac_post, snac_metadata);
39+ }
40+ else {
41+ /* free the html, by rendering it... */
42+ xs_free(xs_html_render(snac_metadata));
43+ }
44+
45 /* buttons */
46 xs *btn_form_action = xs_fmt("%s/admin/action", user->actor);
47