summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar violette2026-01-12 05:09:21 +0100
committerGravatar grunfink2026-01-12 05:09:21 +0100
commitf5ad346f7d819a1fe71ac6f1bc98e16fe1aead01 (patch)
tree6181edc5cba0e4c0e0731580facf319e387a114c /html.c
parentUpdated RELEASE_NOTES. (diff)
downloadsnac2-f5ad346f7d819a1fe71ac6f1bc98e16fe1aead01.tar.gz
snac2-f5ad346f7d819a1fe71ac6f1bc98e16fe1aead01.tar.xz
snac2-f5ad346f7d819a1fe71ac6f1bc98e16fe1aead01.zip
Use the metadata pronouns.
Diffstat (limited to 'html.c')
-rw-r--r--html.c38
1 files changed, 38 insertions, 0 deletions
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(" "),