commit fac52ff
default
·
2023-06-01 07:16:17 +0000 UTC
parent 37878fb
Show the user@host identified next to the user avatar (contributed by Haijo7).
1 files changed,
+26,
-1
M
html.c
M
html.c
+26,
-1
1@@ -135,12 +135,37 @@ xs_str *html_actor_icon(xs_str *os, char *actor,
2 }
3
4 xs *s1 = xs_fmt(
5- "<br>\n<time class=\"dt-published snac-pubdate\" title=\"%s\">%s</time>\n",
6+ "\n<time class=\"dt-published snac-pubdate\" title=\"%s\">%s</time>\n",
7 date_title, date_label);
8
9 s = xs_str_cat(s, s1);
10 }
11
12+ {
13+ char *username, *id;
14+ xs *s1;
15+
16+ if (xs_is_null(username = xs_dict_get(actor, "preferredUsername")) || *username == '\0') {
17+ /* This should never be reached */
18+ username = "anonymous";
19+ }
20+
21+ if (xs_is_null(id = xs_dict_get(actor, "id")) || *id == '\0') {
22+ /* This should never be reached */
23+ id = "https://social.example.org/anonymous";
24+ }
25+
26+ /* "LIKE AN ANIMAL" */
27+ xs *domain = xs_split(id, "/");
28+ xs *user = xs_fmt("@%s@%s", username, xs_list_get(domain, 2));
29+
30+ s1 = xs_fmt(
31+ "<br><a href=\"%s\" class=\"p-author-tag h-card snac-author snac-author-tag\">%s</a>",
32+ xs_dict_get(actor, "id"), user);
33+
34+ s = xs_str_cat(s, s1);
35+ }
36+
37 return xs_str_cat(os, s);
38 }
39