diff options
| author | 2024-02-21 08:09:57 +0100 | |
|---|---|---|
| committer | 2024-02-21 08:09:57 +0100 | |
| commit | b40e71c11c2451b541bd55238b0566a9ecc7570f (patch) | |
| tree | 7a6ee4381a4eb84f4ecc04e285af191d214824ed | |
| parent | Renamed 'local' argument to 'read_only', as it was a bit confusing. (diff) | |
| download | snac2-b40e71c11c2451b541bd55238b0566a9ecc7570f.tar.gz snac2-b40e71c11c2451b541bd55238b0566a9ecc7570f.tar.xz snac2-b40e71c11c2451b541bd55238b0566a9ecc7570f.zip | |
Added a page argument to html_timeline().
| -rw-r--r-- | html.c | 18 | ||||
| -rw-r--r-- | httpd.c | 6 | ||||
| -rw-r--r-- | snac.h | 2 |
3 files changed, 16 insertions, 10 deletions
| @@ -1880,7 +1880,7 @@ xs_html *html_footer(void) | |||
| 1880 | 1880 | ||
| 1881 | 1881 | ||
| 1882 | xs_str *html_timeline(snac *user, const xs_list *list, int local, | 1882 | xs_str *html_timeline(snac *user, const xs_list *list, int local, |
| 1883 | int skip, int show, int show_more, char *tag) | 1883 | int skip, int show, int show_more, char *tag, char *page) |
| 1884 | /* returns the HTML for the timeline */ | 1884 | /* returns the HTML for the timeline */ |
| 1885 | { | 1885 | { |
| 1886 | xs_list *p = (xs_list *)list; | 1886 | xs_list *p = (xs_list *)list; |
| @@ -2003,12 +2003,15 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local, | |||
| 2003 | xs *m = NULL; | 2003 | xs *m = NULL; |
| 2004 | xs *ss = xs_fmt("skip=%d&show=%d", skip + show, show); | 2004 | xs *ss = xs_fmt("skip=%d&show=%d", skip + show, show); |
| 2005 | 2005 | ||
| 2006 | xs *url = page == NULL || user == NULL ? | ||
| 2007 | xs_dup(srv_baseurl) : xs_fmt("%s%s", user->actor, page); | ||
| 2008 | |||
| 2006 | if (tag) { | 2009 | if (tag) { |
| 2007 | t = xs_fmt("%s?t=%s", srv_baseurl, tag); | 2010 | t = xs_fmt("%s?t=%s", url, tag); |
| 2008 | m = xs_fmt("%s&%s", t, ss); | 2011 | m = xs_fmt("%s&%s", t, ss); |
| 2009 | } | 2012 | } |
| 2010 | else { | 2013 | else { |
| 2011 | t = xs_fmt("%s%s", user ? user->actor : srv_baseurl, local ? "" : "/admin"); | 2014 | t = xs_dup(url); |
| 2012 | m = xs_fmt("%s?%s", t, ss); | 2015 | m = xs_fmt("%s?%s", t, ss); |
| 2013 | } | 2016 | } |
| 2014 | 2017 | ||
| @@ -2401,7 +2404,8 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2401 | xs *h = xs_str_localtime(0, "%Y-%m.html"); | 2404 | xs *h = xs_str_localtime(0, "%Y-%m.html"); |
| 2402 | 2405 | ||
| 2403 | if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) { | 2406 | if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) { |
| 2404 | *body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL); | 2407 | /** empty public timeline for private users **/ |
| 2408 | *body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL, ""); | ||
| 2405 | *b_size = strlen(*body); | 2409 | *b_size = strlen(*body); |
| 2406 | status = 200; | 2410 | status = 200; |
| 2407 | } | 2411 | } |
| @@ -2419,7 +2423,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2419 | xs *pins = pinned_list(&snac); | 2423 | xs *pins = pinned_list(&snac); |
| 2420 | pins = xs_list_cat(pins, list); | 2424 | pins = xs_list_cat(pins, list); |
| 2421 | 2425 | ||
| 2422 | *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL); | 2426 | *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL, ""); |
| 2423 | 2427 | ||
| 2424 | *b_size = strlen(*body); | 2428 | *b_size = strlen(*body); |
| 2425 | status = 200; | 2429 | status = 200; |
| @@ -2456,7 +2460,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2456 | xs *pins = pinned_list(&snac); | 2460 | xs *pins = pinned_list(&snac); |
| 2457 | pins = xs_list_cat(pins, list); | 2461 | pins = xs_list_cat(pins, list); |
| 2458 | 2462 | ||
| 2459 | *body = html_timeline(&snac, pins, 0, skip, show, xs_list_len(next), NULL); | 2463 | *body = html_timeline(&snac, pins, 0, skip, show, xs_list_len(next), NULL, "/admin"); |
| 2460 | 2464 | ||
| 2461 | *b_size = strlen(*body); | 2465 | *b_size = strlen(*body); |
| 2462 | status = 200; | 2466 | status = 200; |
| @@ -2504,7 +2508,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2504 | 2508 | ||
| 2505 | list = xs_list_append(list, md5); | 2509 | list = xs_list_append(list, md5); |
| 2506 | 2510 | ||
| 2507 | *body = html_timeline(&snac, list, 1, 0, 0, 0, NULL); | 2511 | *body = html_timeline(&snac, list, 1, 0, 0, 0, NULL, ""); |
| 2508 | *b_size = strlen(*body); | 2512 | *b_size = strlen(*body); |
| 2509 | status = 200; | 2513 | status = 200; |
| 2510 | } | 2514 | } |
| @@ -177,6 +177,7 @@ int server_get_handler(xs_dict *req, const char *q_path, | |||
| 177 | char *t = NULL; | 177 | char *t = NULL; |
| 178 | 178 | ||
| 179 | if (xs_type(q_vars) == XSTYPE_DICT && (t = xs_dict_get(q_vars, "t"))) { | 179 | if (xs_type(q_vars) == XSTYPE_DICT && (t = xs_dict_get(q_vars, "t"))) { |
| 180 | /** search by tag **/ | ||
| 180 | int skip = 0; | 181 | int skip = 0; |
| 181 | int show = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries")); | 182 | int show = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries")); |
| 182 | char *v; | 183 | char *v; |
| @@ -194,12 +195,13 @@ int server_get_handler(xs_dict *req, const char *q_path, | |||
| 194 | more = 1; | 195 | more = 1; |
| 195 | } | 196 | } |
| 196 | 197 | ||
| 197 | *body = html_timeline(NULL, tl, 0, skip, show, more, t); | 198 | *body = html_timeline(NULL, tl, 0, skip, show, more, t, NULL); |
| 198 | } | 199 | } |
| 199 | else | 200 | else |
| 200 | if (xs_type(xs_dict_get(srv_config, "show_instance_timeline")) == XSTYPE_TRUE) { | 201 | if (xs_type(xs_dict_get(srv_config, "show_instance_timeline")) == XSTYPE_TRUE) { |
| 202 | /** instance timeline **/ | ||
| 201 | xs *tl = timeline_instance_list(0, 30); | 203 | xs *tl = timeline_instance_list(0, 30); |
| 202 | *body = html_timeline(NULL, tl, 0, 0, 0, 0, NULL); | 204 | *body = html_timeline(NULL, tl, 0, 0, 0, 0, NULL, NULL); |
| 203 | } | 205 | } |
| 204 | else | 206 | else |
| 205 | *body = greeting_html(); | 207 | *body = greeting_html(); |
| @@ -297,7 +297,7 @@ xs_str *sanitize(const char *content); | |||
| 297 | xs_str *encode_html(const char *str); | 297 | xs_str *encode_html(const char *str); |
| 298 | 298 | ||
| 299 | xs_str *html_timeline(snac *user, const xs_list *list, int local, | 299 | xs_str *html_timeline(snac *user, const xs_list *list, int local, |
| 300 | int skip, int show, int show_more, char *tag); | 300 | int skip, int show, int show_more, char *tag, char *page); |
| 301 | 301 | ||
| 302 | int html_get_handler(const xs_dict *req, const char *q_path, | 302 | int html_get_handler(const xs_dict *req, const char *q_path, |
| 303 | char **body, int *b_size, char **ctype, xs_str **etag); | 303 | char **body, int *b_size, char **ctype, xs_str **etag); |