summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-11-29 10:14:37 +0100
committerdefault <nobody@localhost>2023-11-29 10:14:37 +0100
commitb1a9279f85a4a8201bbc27d0242712f6ccebb3b6 (patch)
tree386934e0bf82153be49545e94a0633e3889935e8
parent6c6dd060ebc27c4841111eebb856222d3bd2864f (diff)
html_timeline() now uses xs_html.
-rw-r--r--html.c75
-rw-r--r--main.c13
2 files changed, 40 insertions, 48 deletions
diff --git a/html.c b/html.c
index cfd64d8..ac7e372 100644
--- a/html.c
+++ b/html.c
@@ -2059,24 +2059,39 @@ 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 */
{
- xs_str *s = xs_str_new(NULL);
xs_list *p = (xs_list *)list;
char *v;
double t = ftime();
- if (user)
- s = html_user_header(user, s, local);
- else
- s = html_instance_header(s, tag);
+ xs_html *head;
+ xs_html *body;
- if (user && !local) {
- xs_html *h = html_top_controls(user);
- xs *s1 = xs_html_render(h);
- s = xs_str_cat(s, s1);
+ if (user) {
+ head = html_user_head(user);
+ body = html_user_body(user, local);
+ }
+ else {
+ head = html_instance_head();
+ body = html_instance_body(tag);
}
- s = xs_str_cat(s, "<a name=\"snac-posts\"></a>\n");
- s = xs_str_cat(s, "<div class=\"snac-posts\">\n");
+ xs_html *html = xs_html_tag("html",
+ head,
+ body);
+
+ if (user && !local)
+ xs_html_add(body,
+ html_top_controls(user));
+
+ xs_html_add(body,
+ xs_html_tag("a",
+ xs_html_attr("name", "snac-posts")));
+
+ xs_html *posts = xs_html_tag("div",
+ xs_html_attr("class", "snac-posts"));
+
+ xs_html_add(body,
+ posts);
while (xs_list_iter(&p, &v)) {
xs *msg = NULL;
@@ -2111,19 +2126,13 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local,
xs_html *entry = html_entry(user, msg, local, 0, v, user ? 0 : 1);
- if (entry != NULL) {
- xs *s1 = xs_html_render(entry);
- s = xs_str_cat(s, s1);
- }
+ if (entry != NULL)
+ xs_html_add(posts,
+ entry);
}
- s = xs_str_cat(s, "</div>\n");
-
if (list && user && local) {
- if (xs_type(xs_dict_get(srv_config, "disable_history")) == XSTYPE_TRUE) {
- s = xs_str_cat(s, "<!-- history disabled -->\n");
- }
- else {
+ if (xs_type(xs_dict_get(srv_config, "disable_history")) != XSTYPE_TRUE) {
xs_html *ul = xs_html_tag("ul", NULL);
xs_html *history = xs_html_tag("div",
@@ -2148,14 +2157,15 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local,
xs_html_text(fn))));
}
- xs *s1 = xs_html_render(history);
- s = xs_str_cat(s, s1);
+ xs_html_add(body,
+ history);
}
}
{
- xs *s1 = xs_fmt("<!-- %lf seconds -->\n", ftime() - t);
- s = xs_str_cat(s, s1);
+ xs *s1 = xs_fmt("\n<!-- %lf seconds -->\n", ftime() - t);
+ xs_html_add(body,
+ xs_html_raw(s1));
}
if (show_more) {
@@ -2183,19 +2193,14 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local,
xs_html_attr("name", "snac-more"),
xs_html_text(L("More..."))));
- xs *s1 = xs_html_render(more_links);
- s = xs_str_cat(s, s1);
- }
-
- {
- xs_html *h = html_footer();
- xs *s1 = xs_html_render(h);
- s = xs_str_cat(s, s1);
+ xs_html_add(body,
+ more_links);
}
- s = xs_str_cat(s, "</body>\n</html>\n");
+ xs_html_add(body,
+ html_footer());
- return s;
+ return xs_html_render_s(html, "<!DOCTYPE html>\n");
}
diff --git a/main.c b/main.c
index 67b44a6..756323c 100644
--- a/main.c
+++ b/main.c
@@ -209,19 +209,6 @@ int main(int argc, char *argv[])
srv_free();
#endif
- {
- xs_html *note = html_note(&snac, "Note...",
- "DIV_ID", "FORM_ID",
- "TEXTAREA_PLACEHOLDER", "TEXTAREA_CONTENT",
- "EDIT_ID", "ACTOR_ID",
- xs_stock_false, "CW_TEXT",
- xs_stock_false, "REDIR",
- "IN_REPLY_TO", 1);
-
- xs *s1 = xs_html_render(note);
- printf("\n%s\n", s1);
- }
-
xs *idx = xs_fmt("%s/private.idx", snac.basedir);
xs *list = index_list_desc(idx, 0, 256);
xs *tl = timeline_top_level(&snac, list);