mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-10 03:50:38 +03:00
Added a tag argument to html_timeline().
This commit is contained in:
parent
7787fc7d32
commit
8417a80fec
31
html.c
31
html.c
@ -1542,7 +1542,8 @@ xs_str *html_footer(xs_str *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xs_str *html_timeline(snac *user, const xs_list *list, int local, int skip, int show, int show_more)
|
xs_str *html_timeline(snac *user, const xs_list *list, int local,
|
||||||
|
int skip, int show, int show_more, char *tag)
|
||||||
/* returns the HTML for the timeline */
|
/* returns the HTML for the timeline */
|
||||||
{
|
{
|
||||||
xs_str *s = xs_str_new(NULL);
|
xs_str *s = xs_str_new(NULL);
|
||||||
@ -1628,15 +1629,25 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local, int skip, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (show_more) {
|
if (show_more) {
|
||||||
const char *base_url = user ? user->actor : srv_baseurl;
|
xs *t = NULL;
|
||||||
|
xs *m = NULL;
|
||||||
|
|
||||||
|
if (tag) {
|
||||||
|
t = xs_fmt("%s?t=%s", srv_baseurl, tag);
|
||||||
|
m = xs_fmt("%s&skip=%d&show=%d", t, skip + show, show);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
t = xs_fmt("%s%s", user ? user->actor : srv_baseurl, local ? "" : "/admin");
|
||||||
|
m = xs_fmt("%s?&skip=%d&show=%d", t, skip + show, show);
|
||||||
|
}
|
||||||
|
|
||||||
xs *s1 = xs_fmt(
|
xs *s1 = xs_fmt(
|
||||||
"<p>"
|
"<p>"
|
||||||
"<a href=\"%s%s\" name=\"snac-more\">%s</a> - "
|
"<a href=\"%s\" name=\"snac-more\">%s</a> - "
|
||||||
"<a href=\"%s%s?skip=%d&show=%d\" name=\"snac-more\">%s</a>"
|
"<a href=\"%s\" name=\"snac-more\">%s</a>"
|
||||||
"</p>\n",
|
"</p>\n",
|
||||||
base_url, local ? "" : "/admin", L("Back to top"),
|
t, L("Back to top"),
|
||||||
base_url, local ? "" : "/admin", skip + show, show, L("More...")
|
m, L("More...")
|
||||||
);
|
);
|
||||||
|
|
||||||
s = xs_str_cat(s, s1);
|
s = xs_str_cat(s, s1);
|
||||||
@ -1968,7 +1979,7 @@ 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);
|
*body = html_timeline(&snac, NULL, 1, 0, 0, 0, NULL);
|
||||||
*b_size = strlen(*body);
|
*b_size = strlen(*body);
|
||||||
status = 200;
|
status = 200;
|
||||||
}
|
}
|
||||||
@ -1986,7 +1997,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));
|
*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;
|
||||||
@ -2017,7 +2028,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));
|
*body = html_timeline(&snac, pins, 0, skip, show, xs_list_len(next), NULL);
|
||||||
|
|
||||||
*b_size = strlen(*body);
|
*b_size = strlen(*body);
|
||||||
status = 200;
|
status = 200;
|
||||||
@ -2065,7 +2076,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);
|
*body = html_timeline(&snac, list, 1, 0, 0, 0, NULL);
|
||||||
*b_size = strlen(*body);
|
*b_size = strlen(*body);
|
||||||
status = 200;
|
status = 200;
|
||||||
}
|
}
|
||||||
|
4
httpd.c
4
httpd.c
@ -162,12 +162,12 @@ int server_get_handler(xs_dict *req, const char *q_path,
|
|||||||
more = 1;
|
more = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*body = html_timeline(NULL, tl, 0, skip, show, more);
|
*body = html_timeline(NULL, tl, 0, skip, show, more, t);
|
||||||
}
|
}
|
||||||
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) {
|
||||||
xs *tl = timeline_instance_list(0, 30);
|
xs *tl = timeline_instance_list(0, 30);
|
||||||
*body = html_timeline(NULL, tl, 0, 0, 0, 0);
|
*body = html_timeline(NULL, tl, 0, 0, 0, 0, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*body = greeting_html();
|
*body = greeting_html();
|
||||||
|
3
snac.h
3
snac.h
@ -269,7 +269,8 @@ xs_str *sanitize(const char *content);
|
|||||||
xs_str *encode_html_strict(const char *str);
|
xs_str *encode_html_strict(const char *str);
|
||||||
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, int skip, int show, int show_more);
|
xs_str *html_timeline(snac *user, const xs_list *list, int local,
|
||||||
|
int skip, int show, int show_more, char *tag);
|
||||||
|
|
||||||
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