summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar default2024-04-09 06:32:07 +0200
committerGravatar default2024-04-09 06:32:07 +0200
commitebc2f36c086721579c6a409b8636876b4a64d189 (patch)
tree891f92ff6dab2a599eb37bf854939792cd585ffc /html.c
parentAdded new OpenBSD guide link to README. (diff)
downloadsnac2-ebc2f36c086721579c6a409b8636876b4a64d189.tar.gz
snac2-ebc2f36c086721579c6a409b8636876b4a64d189.tar.xz
snac2-ebc2f36c086721579c6a409b8636876b4a64d189.zip
Added rel="alternate" links to ActivityPub objects for the public timeline and single posts.
Diffstat (limited to 'html.c')
-rw-r--r--html.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/html.c b/html.c
index 310c9eb..8813994 100644
--- a/html.c
+++ b/html.c
@@ -574,7 +574,7 @@ static xs_html *html_instance_body(char *tag)
574} 574}
575 575
576 576
577xs_html *html_user_head(snac *user, char *desc) 577xs_html *html_user_head(snac *user, char *desc, char *url)
578{ 578{
579 xs_html *head = html_base_head(); 579 xs_html *head = html_base_head();
580 580
@@ -664,6 +664,13 @@ xs_html *html_user_head(snac *user, char *desc)
664 xs_html_attr("title", "RSS"), 664 xs_html_attr("title", "RSS"),
665 xs_html_attr("href", rss_url))); 665 xs_html_attr("href", rss_url)));
666 666
667 /* ActivityPub alternate link (actor id) */
668 xs_html_add(head,
669 xs_html_sctag("link",
670 xs_html_attr("rel", "alternate"),
671 xs_html_attr("type", "application/activity+json"),
672 xs_html_attr("href", url ? url : user->actor)));
673
667 return head; 674 return head;
668} 675}
669 676
@@ -1974,6 +1981,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
1974 double t = ftime(); 1981 double t = ftime();
1975 1982
1976 xs *desc = NULL; 1983 xs *desc = NULL;
1984 xs *alternate = NULL;
1977 1985
1978 if (xs_list_len(list) == 1) { 1986 if (xs_list_len(list) == 1) {
1979 /* only one element? pick the description from the source */ 1987 /* only one element? pick the description from the source */
@@ -1982,13 +1990,15 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
1982 object_get_by_md5(id, &d); 1990 object_get_by_md5(id, &d);
1983 if (d && (v = xs_dict_get(d, "sourceContent")) != NULL) 1991 if (d && (v = xs_dict_get(d, "sourceContent")) != NULL)
1984 desc = xs_dup(v); 1992 desc = xs_dup(v);
1993
1994 alternate = xs_dup(xs_dict_get(d, "id"));
1985 } 1995 }
1986 1996
1987 xs_html *head; 1997 xs_html *head;
1988 xs_html *body; 1998 xs_html *body;
1989 1999
1990 if (user) { 2000 if (user) {
1991 head = html_user_head(user, desc); 2001 head = html_user_head(user, desc, alternate);
1992 body = html_user_body(user, read_only); 2002 body = html_user_body(user, read_only);
1993 } 2003 }
1994 else { 2004 else {
@@ -2257,7 +2267,7 @@ xs_str *html_people(snac *user)
2257 xs *wers = follower_list(user); 2267 xs *wers = follower_list(user);
2258 2268
2259 xs_html *html = xs_html_tag("html", 2269 xs_html *html = xs_html_tag("html",
2260 html_user_head(user, NULL), 2270 html_user_head(user, NULL, NULL),
2261 xs_html_add(html_user_body(user, 0), 2271 xs_html_add(html_user_body(user, 0),
2262 xs_html_tag("div", 2272 xs_html_tag("div",
2263 xs_html_attr("class", "snac-posts"), 2273 xs_html_attr("class", "snac-posts"),
@@ -2277,7 +2287,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
2277 xs_html *body = html_user_body(user, 0); 2287 xs_html *body = html_user_body(user, 0);
2278 2288
2279 xs_html *html = xs_html_tag("html", 2289 xs_html *html = xs_html_tag("html",
2280 html_user_head(user, NULL), 2290 html_user_head(user, NULL, NULL),
2281 body); 2291 body);
2282 2292
2283 xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor); 2293 xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor);