commit 7c2e290
default
·
2023-12-27 12:18:35 +0000 UTC
parent bf435af
The actor link is now an anchored link to the people page for connected users.
1 files changed,
+23,
-8
M
html.c
M
html.c
+23,
-8
1@@ -101,7 +101,7 @@ xs_str *actor_name(xs_dict *actor)
2 }
3
4
5-xs_html *html_actor_icon(xs_dict *actor, const char *date,
6+xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
7 const char *udate, const char *url, int priv)
8 {
9 xs_html *actor_icon = xs_html_tag("p", NULL);
10@@ -120,6 +120,21 @@ xs_html *html_actor_icon(xs_dict *actor, const char *date,
11 if (avatar == NULL)
12 avatar = xs_fmt("data:image/png;base64, %s", default_avatar_base64());
13
14+ char *actor_id = xs_dict_get(actor, "id");
15+ xs *href = NULL;
16+
17+ if (user) {
18+ /* if this actor is a follower or being followed, create an
19+ anchored link to the people page instead of the actor url */
20+ if (follower_check(user, actor_id) || following_check(user, actor_id)) {
21+ xs *md5 = xs_md5_hex(actor_id, strlen(actor_id));
22+ href = xs_fmt("%s/people#%s", user->actor, md5);
23+ }
24+ }
25+
26+ if (href == NULL)
27+ href = xs_dup(actor_id);
28+
29 xs_html_add(actor_icon,
30 xs_html_sctag("img",
31 xs_html_attr("loading", "lazy"),
32@@ -127,7 +142,7 @@ xs_html *html_actor_icon(xs_dict *actor, const char *date,
33 xs_html_attr("src", avatar),
34 xs_html_attr("alt", "")),
35 xs_html_tag("a",
36- xs_html_attr("href", xs_dict_get(actor, "id")),
37+ xs_html_attr("href", href),
38 xs_html_attr("class", "p-author h-card snac-author"),
39 xs_html_raw(name))); /* name is already html-escaped */
40
41@@ -212,7 +227,7 @@ xs_html *html_actor_icon(xs_dict *actor, const char *date,
42 }
43
44
45-xs_html *html_msg_icon(const xs_dict *msg)
46+xs_html *html_msg_icon(snac *user, const xs_dict *msg)
47 {
48 char *actor_id;
49 xs *actor = NULL;
50@@ -236,7 +251,7 @@ xs_html *html_msg_icon(const xs_dict *msg)
51 date = xs_dict_get(msg, "published");
52 udate = xs_dict_get(msg, "updated");
53
54- actor_icon = html_actor_icon(actor, date, udate, url, priv);
55+ actor_icon = html_actor_icon(user, actor, date, udate, url, priv);
56 }
57
58 return actor_icon;
59@@ -1231,7 +1246,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int local,
60 xs_html_tag("div",
61 xs_html_attr("class", "snac-origin"),
62 xs_html_text(L("follows you"))),
63- html_msg_icon(msg)));
64+ html_msg_icon(local ? NULL : user, msg)));
65 }
66 else
67 if (!xs_match(type, "Note|Question|Page|Article")) {
68@@ -1379,7 +1394,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int local,
69 }
70
71 xs_html_add(post_header,
72- html_msg_icon(msg));
73+ html_msg_icon(local ? NULL : user, msg));
74
75 /** post content **/
76
77@@ -1984,7 +1999,7 @@ xs_html *html_people_list(snac *snac, xs_list *list, char *header, char *t)
78 xs_html_attr("name", md5)),
79 xs_html_tag("div",
80 xs_html_attr("class", "snac-post-header"),
81- html_actor_icon(actor, xs_dict_get(actor, "published"), NULL, NULL, 0)));
82+ html_actor_icon(NULL, actor, xs_dict_get(actor, "published"), NULL, NULL, 0)));
83
84 /* content (user bio) */
85 char *c = xs_dict_get(actor, "summary");
86@@ -2179,7 +2194,7 @@ xs_str *html_notifications(snac *user)
87 xs_html_add(entry,
88 xs_html_tag("div",
89 xs_html_attr("class", "snac-post"),
90- html_actor_icon(actor, NULL, NULL, NULL, 0)));
91+ html_actor_icon(user, actor, NULL, NULL, NULL, 0)));
92 }
93 else {
94 xs *md5 = xs_md5_hex(id, strlen(id));