summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/html.c b/html.c
index a5b3ac9..f3a165d 100644
--- a/html.c
+++ b/html.c
@@ -101,7 +101,7 @@ xs_str *actor_name(xs_dict *actor)
101} 101}
102 102
103 103
104xs_html *html_actor_icon(xs_dict *actor, const char *date, 104xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
105 const char *udate, const char *url, int priv) 105 const char *udate, const char *url, int priv)
106{ 106{
107 xs_html *actor_icon = xs_html_tag("p", NULL); 107 xs_html *actor_icon = xs_html_tag("p", NULL);
@@ -120,6 +120,21 @@ xs_html *html_actor_icon(xs_dict *actor, const char *date,
120 if (avatar == NULL) 120 if (avatar == NULL)
121 avatar = xs_fmt("data:image/png;base64, %s", default_avatar_base64()); 121 avatar = xs_fmt("data:image/png;base64, %s", default_avatar_base64());
122 122
123 char *actor_id = xs_dict_get(actor, "id");
124 xs *href = NULL;
125
126 if (user) {
127 /* if this actor is a follower or being followed, create an
128 anchored link to the people page instead of the actor url */
129 if (follower_check(user, actor_id) || following_check(user, actor_id)) {
130 xs *md5 = xs_md5_hex(actor_id, strlen(actor_id));
131 href = xs_fmt("%s/people#%s", user->actor, md5);
132 }
133 }
134
135 if (href == NULL)
136 href = xs_dup(actor_id);
137
123 xs_html_add(actor_icon, 138 xs_html_add(actor_icon,
124 xs_html_sctag("img", 139 xs_html_sctag("img",
125 xs_html_attr("loading", "lazy"), 140 xs_html_attr("loading", "lazy"),
@@ -127,7 +142,7 @@ xs_html *html_actor_icon(xs_dict *actor, const char *date,
127 xs_html_attr("src", avatar), 142 xs_html_attr("src", avatar),
128 xs_html_attr("alt", "")), 143 xs_html_attr("alt", "")),
129 xs_html_tag("a", 144 xs_html_tag("a",
130 xs_html_attr("href", xs_dict_get(actor, "id")), 145 xs_html_attr("href", href),
131 xs_html_attr("class", "p-author h-card snac-author"), 146 xs_html_attr("class", "p-author h-card snac-author"),
132 xs_html_raw(name))); /* name is already html-escaped */ 147 xs_html_raw(name))); /* name is already html-escaped */
133 148
@@ -212,7 +227,7 @@ xs_html *html_actor_icon(xs_dict *actor, const char *date,
212} 227}
213 228
214 229
215xs_html *html_msg_icon(const xs_dict *msg) 230xs_html *html_msg_icon(snac *user, const xs_dict *msg)
216{ 231{
217 char *actor_id; 232 char *actor_id;
218 xs *actor = NULL; 233 xs *actor = NULL;
@@ -236,7 +251,7 @@ xs_html *html_msg_icon(const xs_dict *msg)
236 date = xs_dict_get(msg, "published"); 251 date = xs_dict_get(msg, "published");
237 udate = xs_dict_get(msg, "updated"); 252 udate = xs_dict_get(msg, "updated");
238 253
239 actor_icon = html_actor_icon(actor, date, udate, url, priv); 254 actor_icon = html_actor_icon(user, actor, date, udate, url, priv);
240 } 255 }
241 256
242 return actor_icon; 257 return actor_icon;
@@ -1231,7 +1246,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int local,
1231 xs_html_tag("div", 1246 xs_html_tag("div",
1232 xs_html_attr("class", "snac-origin"), 1247 xs_html_attr("class", "snac-origin"),
1233 xs_html_text(L("follows you"))), 1248 xs_html_text(L("follows you"))),
1234 html_msg_icon(msg))); 1249 html_msg_icon(local ? NULL : user, msg)));
1235 } 1250 }
1236 else 1251 else
1237 if (!xs_match(type, "Note|Question|Page|Article")) { 1252 if (!xs_match(type, "Note|Question|Page|Article")) {
@@ -1379,7 +1394,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int local,
1379 } 1394 }
1380 1395
1381 xs_html_add(post_header, 1396 xs_html_add(post_header,
1382 html_msg_icon(msg)); 1397 html_msg_icon(local ? NULL : user, msg));
1383 1398
1384 /** post content **/ 1399 /** post content **/
1385 1400
@@ -1984,7 +1999,7 @@ xs_html *html_people_list(snac *snac, xs_list *list, char *header, char *t)
1984 xs_html_attr("name", md5)), 1999 xs_html_attr("name", md5)),
1985 xs_html_tag("div", 2000 xs_html_tag("div",
1986 xs_html_attr("class", "snac-post-header"), 2001 xs_html_attr("class", "snac-post-header"),
1987 html_actor_icon(actor, xs_dict_get(actor, "published"), NULL, NULL, 0))); 2002 html_actor_icon(NULL, actor, xs_dict_get(actor, "published"), NULL, NULL, 0)));
1988 2003
1989 /* content (user bio) */ 2004 /* content (user bio) */
1990 char *c = xs_dict_get(actor, "summary"); 2005 char *c = xs_dict_get(actor, "summary");
@@ -2179,7 +2194,7 @@ xs_str *html_notifications(snac *user)
2179 xs_html_add(entry, 2194 xs_html_add(entry,
2180 xs_html_tag("div", 2195 xs_html_tag("div",
2181 xs_html_attr("class", "snac-post"), 2196 xs_html_attr("class", "snac-post"),
2182 html_actor_icon(actor, NULL, NULL, NULL, 0))); 2197 html_actor_icon(user, actor, NULL, NULL, NULL, 0)));
2183 } 2198 }
2184 else { 2199 else {
2185 xs *md5 = xs_md5_hex(id, strlen(id)); 2200 xs *md5 = xs_md5_hex(id, strlen(id));