commit ebc2f36

default  ·  2024-04-09 04:32:07 +0000 UTC
parent 441c42d
Added rel="alternate" links to ActivityPub objects for the public timeline and single posts.
1 files changed,  +14, -4
M html.c
M html.c
+14, -4
 1@@ -574,7 +574,7 @@ static xs_html *html_instance_body(char *tag)
 2 }
 3 
 4 
 5-xs_html *html_user_head(snac *user, char *desc)
 6+xs_html *html_user_head(snac *user, char *desc, char *url)
 7 {
 8     xs_html *head = html_base_head();
 9 
10@@ -664,6 +664,13 @@ xs_html *html_user_head(snac *user, char *desc)
11             xs_html_attr("title", "RSS"),
12             xs_html_attr("href", rss_url)));
13 
14+    /* ActivityPub alternate link (actor id) */
15+    xs_html_add(head,
16+        xs_html_sctag("link",
17+            xs_html_attr("rel", "alternate"),
18+            xs_html_attr("type", "application/activity+json"),
19+            xs_html_attr("href", url ? url : user->actor)));
20+
21     return head;
22 }
23 
24@@ -1974,6 +1981,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
25     double t = ftime();
26 
27     xs *desc = NULL;
28+    xs *alternate = NULL;
29 
30     if (xs_list_len(list) == 1) {
31         /* only one element? pick the description from the source */
32@@ -1982,13 +1990,15 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
33         object_get_by_md5(id, &d);
34         if (d && (v = xs_dict_get(d, "sourceContent")) != NULL)
35             desc = xs_dup(v);
36+
37+        alternate = xs_dup(xs_dict_get(d, "id"));
38     }
39 
40     xs_html *head;
41     xs_html *body;
42 
43     if (user) {
44-        head = html_user_head(user, desc);
45+        head = html_user_head(user, desc, alternate);
46         body = html_user_body(user, read_only);
47     }
48     else {
49@@ -2257,7 +2267,7 @@ xs_str *html_people(snac *user)
50     xs *wers = follower_list(user);
51 
52     xs_html *html = xs_html_tag("html",
53-        html_user_head(user, NULL),
54+        html_user_head(user, NULL, NULL),
55         xs_html_add(html_user_body(user, 0),
56             xs_html_tag("div",
57                 xs_html_attr("class", "snac-posts"),
58@@ -2277,7 +2287,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
59     xs_html *body = html_user_body(user, 0);
60 
61     xs_html *html = xs_html_tag("html",
62-        html_user_head(user, NULL),
63+        html_user_head(user, NULL, NULL),
64         body);
65 
66     xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor);