diff options
| -rw-r--r-- | html.c | 75 | ||||
| -rw-r--r-- | main.c | 13 |
2 files changed, 40 insertions, 48 deletions
| @@ -2059,24 +2059,39 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local, | |||
| 2059 | int skip, int show, int show_more, char *tag) | 2059 | int skip, int show, int show_more, char *tag) |
| 2060 | /* returns the HTML for the timeline */ | 2060 | /* returns the HTML for the timeline */ |
| 2061 | { | 2061 | { |
| 2062 | xs_str *s = xs_str_new(NULL); | ||
| 2063 | xs_list *p = (xs_list *)list; | 2062 | xs_list *p = (xs_list *)list; |
| 2064 | char *v; | 2063 | char *v; |
| 2065 | double t = ftime(); | 2064 | double t = ftime(); |
| 2066 | 2065 | ||
| 2067 | if (user) | 2066 | xs_html *head; |
| 2068 | s = html_user_header(user, s, local); | 2067 | xs_html *body; |
| 2069 | else | ||
| 2070 | s = html_instance_header(s, tag); | ||
| 2071 | 2068 | ||
| 2072 | if (user && !local) { | 2069 | if (user) { |
| 2073 | xs_html *h = html_top_controls(user); | 2070 | head = html_user_head(user); |
| 2074 | xs *s1 = xs_html_render(h); | 2071 | body = html_user_body(user, local); |
| 2075 | s = xs_str_cat(s, s1); | 2072 | } |
| 2073 | else { | ||
| 2074 | head = html_instance_head(); | ||
| 2075 | body = html_instance_body(tag); | ||
| 2076 | } | 2076 | } |
| 2077 | 2077 | ||
| 2078 | s = xs_str_cat(s, "<a name=\"snac-posts\"></a>\n"); | 2078 | xs_html *html = xs_html_tag("html", |
| 2079 | s = xs_str_cat(s, "<div class=\"snac-posts\">\n"); | 2079 | head, |
| 2080 | body); | ||
| 2081 | |||
| 2082 | if (user && !local) | ||
| 2083 | xs_html_add(body, | ||
| 2084 | html_top_controls(user)); | ||
| 2085 | |||
| 2086 | xs_html_add(body, | ||
| 2087 | xs_html_tag("a", | ||
| 2088 | xs_html_attr("name", "snac-posts"))); | ||
| 2089 | |||
| 2090 | xs_html *posts = xs_html_tag("div", | ||
| 2091 | xs_html_attr("class", "snac-posts")); | ||
| 2092 | |||
| 2093 | xs_html_add(body, | ||
| 2094 | posts); | ||
| 2080 | 2095 | ||
| 2081 | while (xs_list_iter(&p, &v)) { | 2096 | while (xs_list_iter(&p, &v)) { |
| 2082 | xs *msg = NULL; | 2097 | xs *msg = NULL; |
| @@ -2111,19 +2126,13 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local, | |||
| 2111 | 2126 | ||
| 2112 | xs_html *entry = html_entry(user, msg, local, 0, v, user ? 0 : 1); | 2127 | xs_html *entry = html_entry(user, msg, local, 0, v, user ? 0 : 1); |
| 2113 | 2128 | ||
| 2114 | if (entry != NULL) { | 2129 | if (entry != NULL) |
| 2115 | xs *s1 = xs_html_render(entry); | 2130 | xs_html_add(posts, |
| 2116 | s = xs_str_cat(s, s1); | 2131 | entry); |
| 2117 | } | ||
| 2118 | } | 2132 | } |
| 2119 | 2133 | ||
| 2120 | s = xs_str_cat(s, "</div>\n"); | ||
| 2121 | |||
| 2122 | if (list && user && local) { | 2134 | if (list && user && local) { |
| 2123 | if (xs_type(xs_dict_get(srv_config, "disable_history")) == XSTYPE_TRUE) { | 2135 | if (xs_type(xs_dict_get(srv_config, "disable_history")) != XSTYPE_TRUE) { |
| 2124 | s = xs_str_cat(s, "<!-- history disabled -->\n"); | ||
| 2125 | } | ||
| 2126 | else { | ||
| 2127 | xs_html *ul = xs_html_tag("ul", NULL); | 2136 | xs_html *ul = xs_html_tag("ul", NULL); |
| 2128 | 2137 | ||
| 2129 | xs_html *history = xs_html_tag("div", | 2138 | xs_html *history = xs_html_tag("div", |
| @@ -2148,14 +2157,15 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local, | |||
| 2148 | xs_html_text(fn)))); | 2157 | xs_html_text(fn)))); |
| 2149 | } | 2158 | } |
| 2150 | 2159 | ||
| 2151 | xs *s1 = xs_html_render(history); | 2160 | xs_html_add(body, |
| 2152 | s = xs_str_cat(s, s1); | 2161 | history); |
| 2153 | } | 2162 | } |
| 2154 | } | 2163 | } |
| 2155 | 2164 | ||
| 2156 | { | 2165 | { |
| 2157 | xs *s1 = xs_fmt("<!-- %lf seconds -->\n", ftime() - t); | 2166 | xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t); |
| 2158 | s = xs_str_cat(s, s1); | 2167 | xs_html_add(body, |
| 2168 | xs_html_raw(s1)); | ||
| 2159 | } | 2169 | } |
| 2160 | 2170 | ||
| 2161 | if (show_more) { | 2171 | if (show_more) { |
| @@ -2183,19 +2193,14 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local, | |||
| 2183 | xs_html_attr("name", "snac-more"), | 2193 | xs_html_attr("name", "snac-more"), |
| 2184 | xs_html_text(L("More...")))); | 2194 | xs_html_text(L("More...")))); |
| 2185 | 2195 | ||
| 2186 | xs *s1 = xs_html_render(more_links); | 2196 | xs_html_add(body, |
| 2187 | s = xs_str_cat(s, s1); | 2197 | more_links); |
| 2188 | } | ||
| 2189 | |||
| 2190 | { | ||
| 2191 | xs_html *h = html_footer(); | ||
| 2192 | xs *s1 = xs_html_render(h); | ||
| 2193 | s = xs_str_cat(s, s1); | ||
| 2194 | } | 2198 | } |
| 2195 | 2199 | ||
| 2196 | s = xs_str_cat(s, "</body>\n</html>\n"); | 2200 | xs_html_add(body, |
| 2201 | html_footer()); | ||
| 2197 | 2202 | ||
| 2198 | return s; | 2203 | return xs_html_render_s(html, "<!DOCTYPE html>\n"); |
| 2199 | } | 2204 | } |
| 2200 | 2205 | ||
| 2201 | 2206 | ||
| @@ -209,19 +209,6 @@ int main(int argc, char *argv[]) | |||
| 209 | srv_free(); | 209 | srv_free(); |
| 210 | #endif | 210 | #endif |
| 211 | 211 | ||
| 212 | { | ||
| 213 | xs_html *note = html_note(&snac, "Note...", | ||
| 214 | "DIV_ID", "FORM_ID", | ||
| 215 | "TEXTAREA_PLACEHOLDER", "TEXTAREA_CONTENT", | ||
| 216 | "EDIT_ID", "ACTOR_ID", | ||
| 217 | xs_stock_false, "CW_TEXT", | ||
| 218 | xs_stock_false, "REDIR", | ||
| 219 | "IN_REPLY_TO", 1); | ||
| 220 | |||
| 221 | xs *s1 = xs_html_render(note); | ||
| 222 | printf("\n%s\n", s1); | ||
| 223 | } | ||
| 224 | |||
| 225 | xs *idx = xs_fmt("%s/private.idx", snac.basedir); | 212 | xs *idx = xs_fmt("%s/private.idx", snac.basedir); |
| 226 | xs *list = index_list_desc(idx, 0, 256); | 213 | xs *list = index_list_desc(idx, 0, 256); |
| 227 | xs *tl = timeline_top_level(&snac, list); | 214 | xs *tl = timeline_top_level(&snac, list); |