diff options
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 71 |
1 files changed, 45 insertions, 26 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(void) |
| 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,16 +560,6 @@ static xs_html *html_instance_body(char *tag) | |||
| 560 | xs_html_text(handle))))); | 560 | xs_html_text(handle))))); |
| 561 | } | 561 | } |
| 562 | 562 | ||
| 563 | { | ||
| 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, | ||
| 568 | xs_html_tag("h2", | ||
| 569 | xs_html_attr("class", "snac-header"), | ||
| 570 | xs_html_text(l))); | ||
| 571 | } | ||
| 572 | |||
| 573 | return body; | 563 | return body; |
| 574 | } | 564 | } |
| 575 | 565 | ||
| @@ -1996,7 +1986,7 @@ xs_html *html_footer(void) | |||
| 1996 | 1986 | ||
| 1997 | xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | 1987 | xs_str *html_timeline(snac *user, const xs_list *list, int read_only, |
| 1998 | int skip, int show, int show_more, | 1988 | int skip, int show, int show_more, |
| 1999 | char *tag, char *page, int utl) | 1989 | char *title, char *page, int utl) |
| 2000 | /* returns the HTML for the timeline */ | 1990 | /* returns the HTML for the timeline */ |
| 2001 | { | 1991 | { |
| 2002 | xs_list *p = (xs_list *)list; | 1992 | xs_list *p = (xs_list *)list; |
| @@ -2026,7 +2016,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2026 | } | 2016 | } |
| 2027 | else { | 2017 | else { |
| 2028 | head = html_instance_head(); | 2018 | head = html_instance_head(); |
| 2029 | body = html_instance_body(tag); | 2019 | body = html_instance_body(); |
| 2030 | } | 2020 | } |
| 2031 | 2021 | ||
| 2032 | xs_html *html = xs_html_tag("html", | 2022 | xs_html *html = xs_html_tag("html", |
| @@ -2037,6 +2027,13 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2037 | xs_html_add(body, | 2027 | xs_html_add(body, |
| 2038 | html_top_controls(user)); | 2028 | html_top_controls(user)); |
| 2039 | 2029 | ||
| 2030 | if (title) { | ||
| 2031 | xs_html_add(body, | ||
| 2032 | xs_html_tag("h2", | ||
| 2033 | xs_html_attr("class", "snac-header"), | ||
| 2034 | xs_html_text(title))); | ||
| 2035 | } | ||
| 2036 | |||
| 2040 | xs_html_add(body, | 2037 | xs_html_add(body, |
| 2041 | xs_html_tag("a", | 2038 | xs_html_tag("a", |
| 2042 | xs_html_attr("name", "snac-posts"))); | 2039 | xs_html_attr("name", "snac-posts"))); |
| @@ -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(" - "), |
| @@ -2652,12 +2646,37 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2652 | xs *next = timeline_instance_list(skip + show, 1); | 2646 | xs *next = timeline_instance_list(skip + show, 1); |
| 2653 | 2647 | ||
| 2654 | *body = html_timeline(&snac, list, 0, skip, show, | 2648 | *body = html_timeline(&snac, list, 0, skip, show, |
| 2655 | xs_list_len(next), NULL, "/instance", 0); | 2649 | xs_list_len(next), L("Showing instance timeline"), "/instance", 0); |
| 2656 | *b_size = strlen(*body); | 2650 | *b_size = strlen(*body); |
| 2657 | status = 200; | 2651 | status = 200; |
| 2658 | } | 2652 | } |
| 2659 | } | 2653 | } |
| 2660 | else | 2654 | else |
| 2655 | if (xs_startswith(p_path, "list/")) { /** list timelines **/ | ||
| 2656 | if (!login(&snac, req)) { | ||
| 2657 | *body = xs_dup(uid); | ||
| 2658 | status = 401; | ||
| 2659 | } | ||
| 2660 | else { | ||
| 2661 | xs *l = xs_split(p_path, "/"); | ||
| 2662 | char *lid = xs_list_get(l, -1); | ||
| 2663 | |||
| 2664 | xs *list = list_timeline(&snac, lid, skip, show); | ||
| 2665 | xs *next = list_timeline(&snac, lid, skip + show, 1); | ||
| 2666 | |||
| 2667 | if (list != NULL) { | ||
| 2668 | xs *base = xs_fmt("/list/%s", lid); | ||
| 2669 | xs *name = list_maint(&snac, lid, 3); | ||
| 2670 | xs *title = xs_fmt(L("Showing timeline for list %s"), name); | ||
| 2671 | |||
| 2672 | *body = html_timeline(&snac, list, 0, skip, show, | ||
| 2673 | xs_list_len(next), title, base, 1); | ||
| 2674 | *b_size = strlen(*body); | ||
| 2675 | status = 200; | ||
| 2676 | } | ||
| 2677 | } | ||
| 2678 | } | ||
| 2679 | else | ||
| 2661 | if (xs_startswith(p_path, "p/")) { /** a timeline with just one entry **/ | 2680 | if (xs_startswith(p_path, "p/")) { /** a timeline with just one entry **/ |
| 2662 | if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) | 2681 | if (xs_type(xs_dict_get(snac.config, "private")) == XSTYPE_TRUE) |
| 2663 | return 403; | 2682 | return 403; |