diff options
| author | 2024-02-22 12:26:32 +0100 | |
|---|---|---|
| committer | 2024-02-22 12:26:32 +0100 | |
| commit | d4364e80f7b16126e5f6434b2b487603b8354dd9 (patch) | |
| tree | cc7da36ea96fc942b111a74f842735feba22cac8 | |
| parent | Reverted ae6aafeb881c075a49eddd834bcfc21e9fc63b18. (diff) | |
| download | snac2-d4364e80f7b16126e5f6434b2b487603b8354dd9.tar.gz snac2-d4364e80f7b16126e5f6434b2b487603b8354dd9.tar.xz snac2-d4364e80f7b16126e5f6434b2b487603b8354dd9.zip | |
Added *another argument* to html_timeline() to select where posts are taken from.
This way, the /instance logged-in timeline can show posts that are not
really into a user's timeline.
| -rw-r--r-- | html.c | 17 | ||||
| -rw-r--r-- | httpd.c | 4 | ||||
| -rw-r--r-- | snac.h | 3 |
3 files changed, 14 insertions, 10 deletions
| @@ -1886,7 +1886,8 @@ xs_html *html_footer(void) | |||
| 1886 | 1886 | ||
| 1887 | 1887 | ||
| 1888 | xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | 1888 | xs_str *html_timeline(snac *user, const xs_list *list, int read_only, |
| 1889 | int skip, int show, int show_more, char *tag, char *page) | 1889 | int skip, int show, int show_more, |
| 1890 | char *tag, char *page, int utl) | ||
| 1890 | /* returns the HTML for the timeline */ | 1891 | /* returns the HTML for the timeline */ |
| 1891 | { | 1892 | { |
| 1892 | xs_list *p = (xs_list *)list; | 1893 | xs_list *p = (xs_list *)list; |
| @@ -1938,7 +1939,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 1938 | xs *msg = NULL; | 1939 | xs *msg = NULL; |
| 1939 | int status; | 1940 | int status; |
| 1940 | 1941 | ||
| 1941 | if (user && !is_pinned_by_md5(user, v)) | 1942 | if (utl && user && !is_pinned_by_md5(user, v)) |
| 1942 | status = timeline_get_by_md5(user, v, &msg); | 1943 | status = timeline_get_by_md5(user, v, &msg); |
| 1943 | else | 1944 | else |
| 1944 | status = object_get_by_md5(v, &msg); | 1945 | status = object_get_by_md5(v, &msg); |
| @@ -2412,7 +2413,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2412 | 2413 | ||
| 2413 | if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) { | 2414 | if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) { |
| 2414 | /** empty public timeline for private users **/ | 2415 | /** empty public timeline for private users **/ |
| 2415 | *body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL, ""); | 2416 | *body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL, "", 1); |
| 2416 | *b_size = strlen(*body); | 2417 | *b_size = strlen(*body); |
| 2417 | status = 200; | 2418 | status = 200; |
| 2418 | } | 2419 | } |
| @@ -2430,7 +2431,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2430 | xs *pins = pinned_list(&snac); | 2431 | xs *pins = pinned_list(&snac); |
| 2431 | pins = xs_list_cat(pins, list); | 2432 | pins = xs_list_cat(pins, list); |
| 2432 | 2433 | ||
| 2433 | *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL, ""); | 2434 | *body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL, "", 1); |
| 2434 | 2435 | ||
| 2435 | *b_size = strlen(*body); | 2436 | *b_size = strlen(*body); |
| 2436 | status = 200; | 2437 | status = 200; |
| @@ -2467,7 +2468,8 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2467 | xs *pins = pinned_list(&snac); | 2468 | xs *pins = pinned_list(&snac); |
| 2468 | pins = xs_list_cat(pins, list); | 2469 | pins = xs_list_cat(pins, list); |
| 2469 | 2470 | ||
| 2470 | *body = html_timeline(&snac, pins, 0, skip, show, xs_list_len(next), NULL, "/admin"); | 2471 | *body = html_timeline(&snac, pins, 0, skip, show, |
| 2472 | xs_list_len(next), NULL, "/admin", 1); | ||
| 2471 | 2473 | ||
| 2472 | *b_size = strlen(*body); | 2474 | *b_size = strlen(*body); |
| 2473 | status = 200; | 2475 | status = 200; |
| @@ -2511,7 +2513,8 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2511 | xs *list = timeline_instance_list(skip, show); | 2513 | xs *list = timeline_instance_list(skip, show); |
| 2512 | xs *next = timeline_instance_list(skip + show, 1); | 2514 | xs *next = timeline_instance_list(skip + show, 1); |
| 2513 | 2515 | ||
| 2514 | *body = html_timeline(&snac, list, 0, skip, show, xs_list_len(next), NULL, "/instance"); | 2516 | *body = html_timeline(&snac, list, 0, skip, show, |
| 2517 | xs_list_len(next), NULL, "/instance", 0); | ||
| 2515 | *b_size = strlen(*body); | 2518 | *b_size = strlen(*body); |
| 2516 | status = 200; | 2519 | status = 200; |
| 2517 | } | 2520 | } |
| @@ -2530,7 +2533,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2530 | 2533 | ||
| 2531 | list = xs_list_append(list, md5); | 2534 | list = xs_list_append(list, md5); |
| 2532 | 2535 | ||
| 2533 | *body = html_timeline(&snac, list, 1, 0, 0, 0, NULL, ""); | 2536 | *body = html_timeline(&snac, list, 1, 0, 0, 0, NULL, "", 1); |
| 2534 | *b_size = strlen(*body); | 2537 | *b_size = strlen(*body); |
| 2535 | status = 200; | 2538 | status = 200; |
| 2536 | } | 2539 | } |
| @@ -195,13 +195,13 @@ int server_get_handler(xs_dict *req, const char *q_path, | |||
| 195 | more = 1; | 195 | more = 1; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | *body = html_timeline(NULL, tl, 0, skip, show, more, t, NULL); | 198 | *body = html_timeline(NULL, tl, 0, skip, show, more, t, NULL, 0); |
| 199 | } | 199 | } |
| 200 | else | 200 | else |
| 201 | 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 **/ | 202 | /** instance timeline **/ |
| 203 | xs *tl = timeline_instance_list(0, 30); | 203 | xs *tl = timeline_instance_list(0, 30); |
| 204 | *body = html_timeline(NULL, tl, 0, 0, 0, 0, NULL, NULL); | 204 | *body = html_timeline(NULL, tl, 0, 0, 0, 0, NULL, NULL, 0); |
| 205 | } | 205 | } |
| 206 | else | 206 | else |
| 207 | *body = greeting_html(); | 207 | *body = greeting_html(); |
| @@ -297,7 +297,8 @@ 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 read_only, | 299 | xs_str *html_timeline(snac *user, const xs_list *list, int read_only, |
| 300 | int skip, int show, int show_more, char *tag, char *page); | 300 | int skip, int show, int show_more, |
| 301 | char *tag, char *page, int utl); | ||
| 301 | 302 | ||
| 302 | int html_get_handler(const xs_dict *req, const char *q_path, | 303 | int html_get_handler(const xs_dict *req, const char *q_path, |
| 303 | char **body, int *b_size, char **ctype, xs_str **etag); | 304 | char **body, int *b_size, char **ctype, xs_str **etag); |