commit f5ad346

violette  ·  2026-01-12 04:09:21 +0000 UTC
parent fdc10b0
Use the metadata pronouns.
3 files changed,  +40, -0
M html.c
+1, -0
1@@ -40,3 +40,4 @@ blockquote { font-style: italic; }
2   a { color: #7799dd }
3   a:visited { color: #aa99dd }
4 }
5+select { max-width: 40%; }
M html.c
+38, -0
 1@@ -162,6 +162,31 @@ xs_str *actor_name(xs_dict *actor, const char *proxy)
 2 }
 3 
 4 
 5+xs_str *actor_pronouns(xs_dict *actor)
 6+/* gets the actor name */
 7+{
 8+    const xs_list *attachment;
 9+    const xs_dict *d;
10+    const char *pronouns = "";
11+    char *ret;
12+
13+    if (!xs_is_null((attachment = xs_dict_get(actor, "attachment")))) {
14+        xs_list_foreach(attachment, d) {
15+            char *prop = xs_utf8_to_lower(xs_dict_get(d, "name"));
16+            /* make sure that we are reading the correct metadata */
17+            if (strlen(prop) == 8 && strcmp(prop, "pronouns") == 0)
18+                pronouns = xs_dict_get(d, "value");
19+        }
20+    }
21+
22+    /* <p> breaks page, cannot nest them */
23+    ret = xs_replace_i(xs_dup(pronouns), "<p>", "");
24+    ret = xs_replace_i(ret, "</p>", "");
25+
26+    return ret;
27+}
28+
29+
30 xs_str *format_text_with_emoji(snac *user, const char *text, int ems, const char *proxy)
31 /* needed when we have local text with no tags attached */
32 {
33@@ -195,6 +220,10 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
34     int fwer = 0;
35 
36     xs *name = actor_name(actor, proxy);
37+    xs *pronouns = actor_pronouns(actor);
38+    char pronouns_c = 0;
39+    if (*pronouns != '\0')
40+        pronouns_c = 1;
41 
42     /* get the avatar */
43     if ((v = xs_dict_get(actor, "icon")) != NULL) {
44@@ -251,6 +280,15 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
45                 xs_html_text("ยป")));
46     }
47 
48+    if (pronouns_c > 0)
49+        xs_html_add(actor_icon,
50+            xs_html_text(" "),
51+            xs_html_tag("span",
52+                xs_html_attr("class",   "snac-pronouns"),
53+                xs_html_attr("title",   "user's pronouns"),
54+                xs_html_raw(pronouns)));
55+
56+
57     if (strcmp(xs_dict_get(actor, "type"), "Service") == 0) {
58         xs_html_add(actor_icon,
59             xs_html_text(" "),
+1, -0
1@@ -88,6 +88,7 @@ static const char * const default_css =
2     "  a { color: #7799dd }\n"
3     "  a:visited { color: #aa99dd }\n"
4     "}\n"
5+    "select { max-width: 40%; }\n"
6 ;
7 
8 const char *snac_blurb =