mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-10 03:50:38 +03:00
Added a page argument to html_timeline().
This commit is contained in:
parent
2b814287fd
commit
b40e71c11c
18
html.c
18
html.c
@ -1880,7 +1880,7 @@ xs_html *html_footer(void)
|
|||||||
|
|
||||||
|
|
||||||
xs_str *html_timeline(snac *user, const xs_list *list, int local,
|
xs_str *html_timeline(snac *user, const xs_list *list, int local,
|
||||||
int skip, int show, int show_more, char *tag)
|
int skip, int show, int show_more, char *tag, char *page)
|
||||||
/* returns the HTML for the timeline */
|
/* returns the HTML for the timeline */
|
||||||
{
|
{
|
||||||
xs_list *p = (xs_list *)list;
|
xs_list *p = (xs_list *)list;
|
||||||
@ -2003,12 +2003,15 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local,
|
|||||||
xs *m = NULL;
|
xs *m = NULL;
|
||||||
xs *ss = xs_fmt("skip=%d&show=%d", skip + show, show);
|
xs *ss = xs_fmt("skip=%d&show=%d", skip + show, show);
|
||||||
|
|
||||||
|
xs *url = page == NULL || user == NULL ?
|
||||||
|
xs_dup(srv_baseurl) : xs_fmt("%s%s", user->actor, page);
|
||||||
|
|
||||||
if (tag) {
|
if (tag) {
|
||||||
t = xs_fmt("%s?t=%s", srv_baseurl, tag);
|
t = xs_fmt("%s?t=%s", url, tag);
|
||||||
m = xs_fmt("%s&%s", t, ss);
|
m = xs_fmt("%s&%s", t, ss);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
t = xs_fmt("%s%s", user ? user->actor : srv_baseurl, local ? "" : "/admin");
|
t = xs_dup(url);
|
||||||
m = xs_fmt("%s?%s", t, ss);
|
m = xs_fmt("%s?%s", t, ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2401,7 +2404,8 @@ int html_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
xs *h = xs_str_localtime(0, "%Y-%m.html");
|
xs *h = xs_str_localtime(0, "%Y-%m.html");
|
||||||
|
|
||||||
if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) {
|
if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) {
|
||||||
*body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL);
|
/** empty public timeline for private users **/
|
||||||
|
*body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL, "");
|
||||||
*b_size = strlen(*body);
|
*b_size = strlen(*body);
|
||||||
status = 200;
|
status = 200;
|
||||||
}
|
}
|
||||||
@ -2419,7 +2423,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
xs *pins = pinned_list(&snac);
|
xs *pins = pinned_list(&snac);
|
||||||
pins = xs_list_cat(pins, list);
|
pins = xs_list_cat(pins, list);
|
||||||
|
|
||||||
*body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL);
|
*body = html_timeline(&snac, pins, 1, skip, show, xs_list_len(next), NULL, "");
|
||||||
|
|
||||||
*b_size = strlen(*body);
|
*b_size = strlen(*body);
|
||||||
status = 200;
|
status = 200;
|
||||||
@ -2456,7 +2460,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
xs *pins = pinned_list(&snac);
|
xs *pins = pinned_list(&snac);
|
||||||
pins = xs_list_cat(pins, list);
|
pins = xs_list_cat(pins, list);
|
||||||
|
|
||||||
*body = html_timeline(&snac, pins, 0, skip, show, xs_list_len(next), NULL);
|
*body = html_timeline(&snac, pins, 0, skip, show, xs_list_len(next), NULL, "/admin");
|
||||||
|
|
||||||
*b_size = strlen(*body);
|
*b_size = strlen(*body);
|
||||||
status = 200;
|
status = 200;
|
||||||
@ -2504,7 +2508,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
|
|||||||
|
|
||||||
list = xs_list_append(list, md5);
|
list = xs_list_append(list, md5);
|
||||||
|
|
||||||
*body = html_timeline(&snac, list, 1, 0, 0, 0, NULL);
|
*body = html_timeline(&snac, list, 1, 0, 0, 0, NULL, "");
|
||||||
*b_size = strlen(*body);
|
*b_size = strlen(*body);
|
||||||
status = 200;
|
status = 200;
|
||||||
}
|
}
|
||||||
|
6
httpd.c
6
httpd.c
@ -177,6 +177,7 @@ int server_get_handler(xs_dict *req, const char *q_path,
|
|||||||
char *t = NULL;
|
char *t = NULL;
|
||||||
|
|
||||||
if (xs_type(q_vars) == XSTYPE_DICT && (t = xs_dict_get(q_vars, "t"))) {
|
if (xs_type(q_vars) == XSTYPE_DICT && (t = xs_dict_get(q_vars, "t"))) {
|
||||||
|
/** search by tag **/
|
||||||
int skip = 0;
|
int skip = 0;
|
||||||
int show = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries"));
|
int show = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries"));
|
||||||
char *v;
|
char *v;
|
||||||
@ -194,12 +195,13 @@ int server_get_handler(xs_dict *req, const char *q_path,
|
|||||||
more = 1;
|
more = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*body = html_timeline(NULL, tl, 0, skip, show, more, t);
|
*body = html_timeline(NULL, tl, 0, skip, show, more, t, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (xs_type(xs_dict_get(srv_config, "show_instance_timeline")) == XSTYPE_TRUE) {
|
if (xs_type(xs_dict_get(srv_config, "show_instance_timeline")) == XSTYPE_TRUE) {
|
||||||
|
/** instance timeline **/
|
||||||
xs *tl = timeline_instance_list(0, 30);
|
xs *tl = timeline_instance_list(0, 30);
|
||||||
*body = html_timeline(NULL, tl, 0, 0, 0, 0, NULL);
|
*body = html_timeline(NULL, tl, 0, 0, 0, 0, NULL, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*body = greeting_html();
|
*body = greeting_html();
|
||||||
|
2
snac.h
2
snac.h
@ -297,7 +297,7 @@ xs_str *sanitize(const char *content);
|
|||||||
xs_str *encode_html(const char *str);
|
xs_str *encode_html(const char *str);
|
||||||
|
|
||||||
xs_str *html_timeline(snac *user, const xs_list *list, int local,
|
xs_str *html_timeline(snac *user, const xs_list *list, int local,
|
||||||
int skip, int show, int show_more, char *tag);
|
int skip, int show, int show_more, char *tag, char *page);
|
||||||
|
|
||||||
int html_get_handler(const xs_dict *req, const char *q_path,
|
int html_get_handler(const xs_dict *req, const char *q_path,
|
||||||
char **body, int *b_size, char **ctype, xs_str **etag);
|
char **body, int *b_size, char **ctype, xs_str **etag);
|
||||||
|
Loading…
Reference in New Issue
Block a user