commit f979604

Alexandre Oliva  ·  2025-02-06 08:24:27 +0000 UTC
parent 8e1a2c5
Merged 383bf2e2eeadcacfa519be7a56c9a301.
2 files changed,  +30, -9
M html.c
+2, -0
1@@ -14,6 +14,8 @@ Allow multiple editors for command-line posts (contributed by inz).
2 
3 Separated maximum and default timeline entry count, allowing larger timelines to be requested without having to increase the default (contributed by lxo).
4 
5+Turned message date into a link to the local post, so that it can be loaded into a separate tab for interacting with (contributed by lxo).
6+
7 Special thanks to fellow developer inz for bringing my attention to code places where I should have been more careful.
8 
9 ## 2.71
M html.c
+28, -9
  1@@ -13,6 +13,7 @@
  2 #include "xs_html.h"
  3 #include "xs_curl.h"
  4 #include "xs_unicode.h"
  5+#include "xs_url.h"
  6 
  7 #include "snac.h"
  8 
  9@@ -115,7 +116,8 @@ xs_str *actor_name(xs_dict *actor, const char *proxy)
 10 
 11 xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
 12                         const char *udate, const char *url, int priv,
 13-                        int in_people, const char *proxy, const char *lang)
 14+                        int in_people, const char *proxy, const char *lang,
 15+                        const char *md5)
 16 {
 17     xs_html *actor_icon = xs_html_tag("p", NULL);
 18 
 19@@ -224,12 +226,29 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
 20         if (xs_is_string(lang))
 21             date_title = xs_str_cat(date_title, " (", lang, ")");
 22 
 23+        xs_html *date_text = xs_html_text(date_label);
 24+
 25+        if (user && md5) {
 26+            xs *lpost_url = xs_fmt("%s/admin/p/%s",
 27+                                   user->actor, md5);
 28+            date_text = xs_html_tag("a",
 29+                                    xs_html_attr("href", lpost_url),
 30+                                    date_text);
 31+        }
 32+        else if (user && url) {
 33+            xs *lpost_url = xs_fmt("%s/admin?q=%s",
 34+                                   user->actor, xs_url_enc(url));
 35+            date_text = xs_html_tag("a",
 36+                                    xs_html_attr("href", lpost_url),
 37+                                    date_text);
 38+        }
 39+
 40         xs_html_add(actor_icon,
 41             xs_html_text(" "),
 42             xs_html_tag("time",
 43                 xs_html_attr("class", "dt-published snac-pubdate"),
 44                 xs_html_attr("title", date_title),
 45-                xs_html_text(date_label)));
 46+                date_text));
 47     }
 48 
 49     {
 50@@ -261,7 +280,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
 51 }
 52 
 53 
 54-xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, const char *proxy)
 55+xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, const char *proxy, const char *md5)
 56 {
 57     xs *actor = NULL;
 58     xs_html *actor_icon = NULL;
 59@@ -292,7 +311,7 @@ xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, con
 60         else
 61             lang = NULL;
 62 
 63-        actor_icon = html_actor_icon(user, actor, date, udate, url, priv, 0, proxy, lang);
 64+        actor_icon = html_actor_icon(user, actor, date, udate, url, priv, 0, proxy, lang, md5);
 65     }
 66 
 67     return actor_icon;
 68@@ -1706,7 +1725,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
 69                 xs_html_tag("div",
 70                     xs_html_attr("class", "snac-origin"),
 71                     xs_html_text(L("follows you"))),
 72-                html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg, proxy)));
 73+                html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg, proxy, NULL)));
 74     }
 75     else
 76     if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) {
 77@@ -1887,7 +1906,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
 78     }
 79 
 80     xs_html_add(post_header,
 81-        html_msg_icon(read_only ? NULL : user, actor, msg, proxy));
 82+        html_msg_icon(read_only ? NULL : user, actor, msg, proxy, md5));
 83 
 84     /** post content **/
 85 
 86@@ -2820,7 +2839,7 @@ xs_html *html_people_list(snac *snac, xs_list *list, char *header, char *t, cons
 87                 xs_html_tag("div",
 88                     xs_html_attr("class", "snac-post-header"),
 89                     html_actor_icon(snac, actor, xs_dict_get(actor, "published"),
 90-                                    NULL, NULL, 0, 1, proxy, NULL)));
 91+                                    NULL, NULL, 0, 1, proxy, NULL, NULL)));
 92 
 93             /* content (user bio) */
 94             const char *c = xs_dict_get(actor, "summary");
 95@@ -3118,7 +3137,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
 96             xs_html_add(entry,
 97                 xs_html_tag("div",
 98                     xs_html_attr("class", "snac-post"),
 99-                    html_actor_icon(user, actor, NULL, NULL, NULL, 0, 0, proxy, NULL)));
100+                    html_actor_icon(user, actor, NULL, NULL, NULL, 0, 0, proxy, NULL, NULL)));
101         }
102         else
103         if (strcmp(type, "Move") == 0) {
104@@ -3132,7 +3151,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
105                     xs_html_add(entry,
106                         xs_html_tag("div",
107                             xs_html_attr("class", "snac-post"),
108-                            html_actor_icon(user, old_actor, NULL, NULL, NULL, 0, 0, proxy, NULL)));
109+                            html_actor_icon(user, old_actor, NULL, NULL, NULL, 0, 0, proxy, NULL, NULL)));
110                 }
111             }
112         }