commit 8417a80
default
·
2023-11-08 09:14:56 +0000 UTC
parent 7787fc7
Added a tag argument to html_timeline().
M
html.c
+21,
-10
1@@ -1542,7 +1542,8 @@ xs_str *html_footer(xs_str *s)
2 }
3
4
5-xs_str *html_timeline(snac *user, const xs_list *list, int local, int skip, int show, int show_more)
6+xs_str *html_timeline(snac *user, const xs_list *list, int local,
7+ int skip, int show, int show_more, char *tag)
8 /* returns the HTML for the timeline */
9 {
10 xs_str *s = xs_str_new(NULL);
11@@ -1628,15 +1629,25 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local, int skip, int
12 }
13
14 if (show_more) {
15- const char *base_url = user ? user->actor : srv_baseurl;
16+ xs *t = NULL;
17+ xs *m = NULL;
18+
19+ if (tag) {
20+ t = xs_fmt("%s?t=%s", srv_baseurl, tag);
21+ m = xs_fmt("%s&skip=%d&show=%d", t, skip + show, show);
22+ }
23+ else {
24+ t = xs_fmt("%s%s", user ? user->actor : srv_baseurl, local ? "" : "/admin");
25+ m = xs_fmt("%s?&skip=%d&show=%d", t, skip + show, show);
26+ }
27
28 xs *s1 = xs_fmt(
29 "<p>"
30- "<a href=\"%s%s\" name=\"snac-more\">%s</a> - "
31- "<a href=\"%s%s?skip=%d&show=%d\" name=\"snac-more\">%s</a>"
32+ "<a href=\"%s\" name=\"snac-more\">%s</a> - "
33+ "<a href=\"%s\" name=\"snac-more\">%s</a>"
34 "</p>\n",
35- base_url, local ? "" : "/admin", L("Back to top"),
36- base_url, local ? "" : "/admin", skip + show, show, L("More...")
37+ t, L("Back to top"),
38+ m, L("More...")
39 );
40
41 s = xs_str_cat(s, s1);
42@@ -1968,7 +1979,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
43 xs *h = xs_str_localtime(0, "%Y-%m.html");
44
45 if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) {
46- *body = html_timeline(&snac, NULL, 1, 0, 0, 0);
47+ *body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL);
48 *b_size = strlen(*body);
49 status = 200;
50 }
51@@ -1986,7 +1997,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
52 xs *pins = pinned_list(&snac);
53 pins = xs_list_cat(pins, list);
54
55- *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next));
56+ *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL);
57
58 *b_size = strlen(*body);
59 status = 200;
60@@ -2017,7 +2028,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
61 xs *pins = pinned_list(&snac);
62 pins = xs_list_cat(pins, list);
63
64- *body = html_timeline(&snac, pins, 0, skip, show, xs_list_len(next));
65+ *body = html_timeline(&snac, pins, 0, skip, show, xs_list_len(next), NULL);
66
67 *b_size = strlen(*body);
68 status = 200;
69@@ -2065,7 +2076,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
70
71 list = xs_list_append(list, md5);
72
73- *body = html_timeline(&snac, list, 1, 0, 0, 0);
74+ *body = html_timeline(&snac, list, 1, 0, 0, 0, NULL);
75 *b_size = strlen(*body);
76 status = 200;
77 }
M
httpd.c
+2,
-2
1@@ -162,12 +162,12 @@ int server_get_handler(xs_dict *req, const char *q_path,
2 more = 1;
3 }
4
5- *body = html_timeline(NULL, tl, 0, skip, show, more);
6+ *body = html_timeline(NULL, tl, 0, skip, show, more, t);
7 }
8 else
9 if (xs_type(xs_dict_get(srv_config, "show_instance_timeline")) == XSTYPE_TRUE) {
10 xs *tl = timeline_instance_list(0, 30);
11- *body = html_timeline(NULL, tl, 0, 0, 0, 0);
12+ *body = html_timeline(NULL, tl, 0, 0, 0, 0, NULL);
13 }
14 else
15 *body = greeting_html();
M
snac.h
+2,
-1
1@@ -269,7 +269,8 @@ xs_str *sanitize(const char *content);
2 xs_str *encode_html_strict(const char *str);
3 xs_str *encode_html(const char *str);
4
5-xs_str *html_timeline(snac *user, const xs_list *list, int local, int skip, int show, int show_more);
6+xs_str *html_timeline(snac *user, const xs_list *list, int local,
7+ int skip, int show, int show_more, char *tag);
8
9 int html_get_handler(const xs_dict *req, const char *q_path,
10 char **body, int *b_size, char **ctype, xs_str **etag);