commit b40e71c
default
·
2024-02-21 07:09:57 +0000 UTC
parent 2b81428
Added a page argument to html_timeline().
M
html.c
+11,
-7
1@@ -1880,7 +1880,7 @@ xs_html *html_footer(void)
2
3
4 xs_str *html_timeline(snac *user, const xs_list *list, int local,
5- int skip, int show, int show_more, char *tag)
6+ int skip, int show, int show_more, char *tag, char *page)
7 /* returns the HTML for the timeline */
8 {
9 xs_list *p = (xs_list *)list;
10@@ -2003,12 +2003,15 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local,
11 xs *m = NULL;
12 xs *ss = xs_fmt("skip=%d&show=%d", skip + show, show);
13
14+ xs *url = page == NULL || user == NULL ?
15+ xs_dup(srv_baseurl) : xs_fmt("%s%s", user->actor, page);
16+
17 if (tag) {
18- t = xs_fmt("%s?t=%s", srv_baseurl, tag);
19+ t = xs_fmt("%s?t=%s", url, tag);
20 m = xs_fmt("%s&%s", t, ss);
21 }
22 else {
23- t = xs_fmt("%s%s", user ? user->actor : srv_baseurl, local ? "" : "/admin");
24+ t = xs_dup(url);
25 m = xs_fmt("%s?%s", t, ss);
26 }
27
28@@ -2401,7 +2404,8 @@ int html_get_handler(const xs_dict *req, const char *q_path,
29 xs *h = xs_str_localtime(0, "%Y-%m.html");
30
31 if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) {
32- *body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL);
33+ /** empty public timeline for private users **/
34+ *body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL, "");
35 *b_size = strlen(*body);
36 status = 200;
37 }
38@@ -2419,7 +2423,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
39 xs *pins = pinned_list(&snac);
40 pins = xs_list_cat(pins, list);
41
42- *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL);
43+ *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL, "");
44
45 *b_size = strlen(*body);
46 status = 200;
47@@ -2456,7 +2460,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
48 xs *pins = pinned_list(&snac);
49 pins = xs_list_cat(pins, list);
50
51- *body = html_timeline(&snac, pins, 0, skip, show, xs_list_len(next), NULL);
52+ *body = html_timeline(&snac, pins, 0, skip, show, xs_list_len(next), NULL, "/admin");
53
54 *b_size = strlen(*body);
55 status = 200;
56@@ -2504,7 +2508,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
57
58 list = xs_list_append(list, md5);
59
60- *body = html_timeline(&snac, list, 1, 0, 0, 0, NULL);
61+ *body = html_timeline(&snac, list, 1, 0, 0, 0, NULL, "");
62 *b_size = strlen(*body);
63 status = 200;
64 }
M
httpd.c
+4,
-2
1@@ -177,6 +177,7 @@ int server_get_handler(xs_dict *req, const char *q_path,
2 char *t = NULL;
3
4 if (xs_type(q_vars) == XSTYPE_DICT && (t = xs_dict_get(q_vars, "t"))) {
5+ /** search by tag **/
6 int skip = 0;
7 int show = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries"));
8 char *v;
9@@ -194,12 +195,13 @@ int server_get_handler(xs_dict *req, const char *q_path,
10 more = 1;
11 }
12
13- *body = html_timeline(NULL, tl, 0, skip, show, more, t);
14+ *body = html_timeline(NULL, tl, 0, skip, show, more, t, NULL);
15 }
16 else
17 if (xs_type(xs_dict_get(srv_config, "show_instance_timeline")) == XSTYPE_TRUE) {
18+ /** instance timeline **/
19 xs *tl = timeline_instance_list(0, 30);
20- *body = html_timeline(NULL, tl, 0, 0, 0, 0, NULL);
21+ *body = html_timeline(NULL, tl, 0, 0, 0, 0, NULL, NULL);
22 }
23 else
24 *body = greeting_html();
M
snac.h
+1,
-1
1@@ -297,7 +297,7 @@ xs_str *sanitize(const char *content);
2 xs_str *encode_html(const char *str);
3
4 xs_str *html_timeline(snac *user, const xs_list *list, int local,
5- int skip, int show, int show_more, char *tag);
6+ int skip, int show, int show_more, char *tag, char *page);
7
8 int html_get_handler(const xs_dict *req, const char *q_path,
9 char **body, int *b_size, char **ctype, xs_str **etag);