summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar violette2026-01-12 05:09:21 +0100
committerGravatar grunfink2026-01-12 05:09:21 +0100
commitf5ad346f7d819a1fe71ac6f1bc98e16fe1aead01 (patch)
tree6181edc5cba0e4c0e0731580facf319e387a114c
parentUpdated RELEASE_NOTES. (diff)
downloadsnac2-f5ad346f7d819a1fe71ac6f1bc98e16fe1aead01.tar.gz
snac2-f5ad346f7d819a1fe71ac6f1bc98e16fe1aead01.tar.xz
snac2-f5ad346f7d819a1fe71ac6f1bc98e16fe1aead01.zip
Use the metadata pronouns.
-rw-r--r--doc/style.css1
-rw-r--r--html.c38
-rw-r--r--utils.c1
3 files changed, 40 insertions, 0 deletions
diff --git a/doc/style.css b/doc/style.css
index 2981926..9c8764a 100644
--- a/doc/style.css
+++ b/doc/style.css
@@ -40,3 +40,4 @@ blockquote { font-style: italic; }
40 a { color: #7799dd } 40 a { color: #7799dd }
41 a:visited { color: #aa99dd } 41 a:visited { color: #aa99dd }
42} 42}
43select { max-width: 40%; }
diff --git a/html.c b/html.c
index ebd9331..9aaaa50 100644
--- a/html.c
+++ b/html.c
@@ -162,6 +162,31 @@ xs_str *actor_name(xs_dict *actor, const char *proxy)
162} 162}
163 163
164 164
165xs_str *actor_pronouns(xs_dict *actor)
166/* gets the actor name */
167{
168 const xs_list *attachment;
169 const xs_dict *d;
170 const char *pronouns = "";
171 char *ret;
172
173 if (!xs_is_null((attachment = xs_dict_get(actor, "attachment")))) {
174 xs_list_foreach(attachment, d) {
175 char *prop = xs_utf8_to_lower(xs_dict_get(d, "name"));
176 /* make sure that we are reading the correct metadata */
177 if (strlen(prop) == 8 && strcmp(prop, "pronouns") == 0)
178 pronouns = xs_dict_get(d, "value");
179 }
180 }
181
182 /* <p> breaks page, cannot nest them */
183 ret = xs_replace_i(xs_dup(pronouns), "<p>", "");
184 ret = xs_replace_i(ret, "</p>", "");
185
186 return ret;
187}
188
189
165xs_str *format_text_with_emoji(snac *user, const char *text, int ems, const char *proxy) 190xs_str *format_text_with_emoji(snac *user, const char *text, int ems, const char *proxy)
166/* needed when we have local text with no tags attached */ 191/* needed when we have local text with no tags attached */
167{ 192{
@@ -195,6 +220,10 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
195 int fwer = 0; 220 int fwer = 0;
196 221
197 xs *name = actor_name(actor, proxy); 222 xs *name = actor_name(actor, proxy);
223 xs *pronouns = actor_pronouns(actor);
224 char pronouns_c = 0;
225 if (*pronouns != '\0')
226 pronouns_c = 1;
198 227
199 /* get the avatar */ 228 /* get the avatar */
200 if ((v = xs_dict_get(actor, "icon")) != NULL) { 229 if ((v = xs_dict_get(actor, "icon")) != NULL) {
@@ -251,6 +280,15 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
251 xs_html_text("»"))); 280 xs_html_text("»")));
252 } 281 }
253 282
283 if (pronouns_c > 0)
284 xs_html_add(actor_icon,
285 xs_html_text(" "),
286 xs_html_tag("span",
287 xs_html_attr("class", "snac-pronouns"),
288 xs_html_attr("title", "user's pronouns"),
289 xs_html_raw(pronouns)));
290
291
254 if (strcmp(xs_dict_get(actor, "type"), "Service") == 0) { 292 if (strcmp(xs_dict_get(actor, "type"), "Service") == 0) {
255 xs_html_add(actor_icon, 293 xs_html_add(actor_icon,
256 xs_html_text(" "), 294 xs_html_text(" "),
diff --git a/utils.c b/utils.c
index fd077f6..9f4e1b7 100644
--- a/utils.c
+++ b/utils.c
@@ -88,6 +88,7 @@ static const char * const default_css =
88 " a { color: #7799dd }\n" 88 " a { color: #7799dd }\n"
89 " a:visited { color: #aa99dd }\n" 89 " a:visited { color: #aa99dd }\n"
90 "}\n" 90 "}\n"
91 "select { max-width: 40%; }\n"
91; 92;
92 93
93const char *snac_blurb = 94const char *snac_blurb =