diff options
| -rw-r--r-- | html.c | 34 | ||||
| -rw-r--r-- | httpd.c | 10 | ||||
| -rw-r--r-- | snac.h | 2 |
3 files changed, 22 insertions, 24 deletions
| @@ -509,7 +509,7 @@ xs_html *html_instance_head(void) | |||
| 509 | } | 509 | } |
| 510 | 510 | ||
| 511 | 511 | ||
| 512 | static xs_html *html_instance_body(char *tag) | 512 | static xs_html *html_instance_body(char *title) |
| 513 | { | 513 | { |
| 514 | char *host = xs_dict_get(srv_config, "host"); | 514 | char *host = xs_dict_get(srv_config, "host"); |
| 515 | char *sdesc = xs_dict_get(srv_config, "short_description"); | 515 | char *sdesc = xs_dict_get(srv_config, "short_description"); |
| @@ -560,14 +560,11 @@ static xs_html *html_instance_body(char *tag) | |||
| 560 | xs_html_text(handle))))); | 560 | xs_html_text(handle))))); |
| 561 | } | 561 | } |
| 562 | 562 | ||
| 563 | { | 563 | if (title != NULL) { |
| 564 | xs *l = tag ? xs_fmt(L("Search results for #%s"), tag) : | ||
| 565 | xs_dup(L("Recent posts by users in this instance")); | ||
| 566 | |||
| 567 | xs_html_add(body, | 564 | xs_html_add(body, |
| 568 | xs_html_tag("h2", | 565 | xs_html_tag("h2", |
| 569 | xs_html_attr("class", "snac-header"), | 566 | xs_html_attr("class", "snac-header"), |
| 570 | xs_html_text(l))); | 567 | xs_html_text(title))); |
| 571 | } | 568 | } |
| 572 | 569 | ||
| 573 | return body; | 570 | return body; |
| @@ -1996,7 +1993,7 @@ xs_html *html_footer(void) | |||
| 1996 | 1993 | ||
| 1997 | xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | 1994 | xs_str *html_timeline(snac *user, const xs_list *list, int read_only, |
| 1998 | int skip, int show, int show_more, | 1995 | int skip, int show, int show_more, |
| 1999 | char *tag, char *page, int utl) | 1996 | char *title, char *page, int utl) |
| 2000 | /* returns the HTML for the timeline */ | 1997 | /* returns the HTML for the timeline */ |
| 2001 | { | 1998 | { |
| 2002 | xs_list *p = (xs_list *)list; | 1999 | xs_list *p = (xs_list *)list; |
| @@ -2026,7 +2023,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2026 | } | 2023 | } |
| 2027 | else { | 2024 | else { |
| 2028 | head = html_instance_head(); | 2025 | head = html_instance_head(); |
| 2029 | body = html_instance_body(tag); | 2026 | body = html_instance_body(title); |
| 2030 | } | 2027 | } |
| 2031 | 2028 | ||
| 2032 | xs_html *html = xs_html_tag("html", | 2029 | xs_html *html = xs_html_tag("html", |
| @@ -2126,25 +2123,22 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2126 | } | 2123 | } |
| 2127 | 2124 | ||
| 2128 | if (show_more) { | 2125 | if (show_more) { |
| 2129 | xs *t = NULL; | ||
| 2130 | xs *m = NULL; | 2126 | xs *m = NULL; |
| 2131 | xs *ss = xs_fmt("skip=%d&show=%d", skip + show, show); | 2127 | xs *ss = xs_fmt("skip=%d&show=%d", skip + show, show); |
| 2132 | 2128 | ||
| 2133 | xs *url = page == NULL || user == NULL ? | 2129 | xs *url = xs_dup(user == NULL ? srv_baseurl : user->actor); |
| 2134 | xs_dup(srv_baseurl) : xs_fmt("%s%s", user->actor, page); | ||
| 2135 | 2130 | ||
| 2136 | if (tag) { | 2131 | if (page != NULL) |
| 2137 | t = xs_fmt("%s?t=%s", url, tag); | 2132 | url = xs_str_cat(url, page); |
| 2138 | m = xs_fmt("%s&%s", t, ss); | 2133 | |
| 2139 | } | 2134 | if (xs_str_in(url, "?") != -1) |
| 2140 | else { | 2135 | m = xs_fmt("%s&%s", url, ss); |
| 2141 | t = xs_dup(url); | 2136 | else |
| 2142 | m = xs_fmt("%s?%s", t, ss); | 2137 | m = xs_fmt("%s?%s", url, ss); |
| 2143 | } | ||
| 2144 | 2138 | ||
| 2145 | xs_html *more_links = xs_html_tag("p", | 2139 | xs_html *more_links = xs_html_tag("p", |
| 2146 | xs_html_tag("a", | 2140 | xs_html_tag("a", |
| 2147 | xs_html_attr("href", t), | 2141 | xs_html_attr("href", url), |
| 2148 | xs_html_attr("name", "snac-more"), | 2142 | xs_html_attr("name", "snac-more"), |
| 2149 | xs_html_text(L("Back to top"))), | 2143 | xs_html_text(L("Back to top"))), |
| 2150 | xs_html_text(" - "), | 2144 | xs_html_text(" - "), |
| @@ -200,14 +200,18 @@ int server_get_handler(xs_dict *req, const char *q_path, | |||
| 200 | *body = timeline_to_rss(NULL, tl, link, link, link); | 200 | *body = timeline_to_rss(NULL, tl, link, link, link); |
| 201 | *ctype = "application/rss+xml; charset=utf-8"; | 201 | *ctype = "application/rss+xml; charset=utf-8"; |
| 202 | } | 202 | } |
| 203 | else | 203 | else { |
| 204 | *body = html_timeline(NULL, tl, 0, skip, show, more, t, NULL, 0); | 204 | xs *page = xs_fmt("?t=%s", t); |
| 205 | xs *title = xs_fmt(L("Search results for #%s"), t); | ||
| 206 | *body = html_timeline(NULL, tl, 0, skip, show, more, title, page, 0); | ||
| 207 | } | ||
| 205 | } | 208 | } |
| 206 | else | 209 | else |
| 207 | if (xs_type(xs_dict_get(srv_config, "show_instance_timeline")) == XSTYPE_TRUE) { | 210 | if (xs_type(xs_dict_get(srv_config, "show_instance_timeline")) == XSTYPE_TRUE) { |
| 208 | /** instance timeline **/ | 211 | /** instance timeline **/ |
| 209 | xs *tl = timeline_instance_list(0, 30); | 212 | xs *tl = timeline_instance_list(0, 30); |
| 210 | *body = html_timeline(NULL, tl, 0, 0, 0, 0, NULL, NULL, 0); | 213 | *body = html_timeline(NULL, tl, 0, 0, 0, 0, |
| 214 | L("Recent posts by users in this instance"), NULL, 0); | ||
| 211 | } | 215 | } |
| 212 | else | 216 | else |
| 213 | *body = greeting_html(); | 217 | *body = greeting_html(); |
| @@ -318,7 +318,7 @@ xs_str *encode_html(const char *str); | |||
| 318 | 318 | ||
| 319 | xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | 319 | xs_str *html_timeline(snac *user, const xs_list *list, int read_only, |
| 320 | int skip, int show, int show_more, | 320 | int skip, int show, int show_more, |
| 321 | char *tag, char *page, int utl); | 321 | char *title, char *page, int utl); |
| 322 | 322 | ||
| 323 | int html_get_handler(const xs_dict *req, const char *q_path, | 323 | int html_get_handler(const xs_dict *req, const char *q_path, |
| 324 | char **body, int *b_size, char **ctype, xs_str **etag); | 324 | char **body, int *b_size, char **ctype, xs_str **etag); |