From 4e01a3b33cdb45afe22eb9ccf0fb73011fe74f3d Mon Sep 17 00:00:00 2001 From: default Date: Mon, 20 Nov 2023 20:53:57 +0100 Subject: [PATCH] Some xs_html refactoring. --- html.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/html.c b/html.c index 8f2be75..13ba33f 100644 --- a/html.c +++ b/html.c @@ -1692,7 +1692,8 @@ xs_str *html_people_list(snac *snac, xs_str *os, xs_list *list, const char *head xs *s = xs_str_new(NULL); xs *es1 = encode_html(header); xs *h = xs_fmt("

%s

\n", es1); - char *p, *actor_id; + xs_list *p; + char *actor_id; s = xs_str_cat(s, h); @@ -1704,31 +1705,38 @@ xs_str *html_people_list(snac *snac, xs_str *os, xs_list *list, const char *head xs *actor = NULL; if (valid_status(actor_get(actor_id, &actor))) { - s = xs_str_cat(s, "
\n
\n"); + s = xs_str_cat(s, "
\n"); + + xs_html *snac_post_header = xs_html_tag("div", + xs_html_attr("class", "snac-post-header"), + html_actor_icon(actor, xs_dict_get(actor, "published"), NULL, NULL, 0)); { - xs_html *actor_icon = html_actor_icon(actor, - xs_dict_get(actor, "published"), NULL, NULL, 0); - xs *s1 = xs_html_render(actor_icon); - s = xs_str_cat(s, s1, "
\n"); + xs *s1 = xs_html_render(snac_post_header); + s = xs_str_cat(s, s1); } /* content (user bio) */ char *c = xs_dict_get(actor, "summary"); if (!xs_is_null(c)) { - s = xs_str_cat(s, "
\n"); - xs *sc = sanitize(c); + xs_html *snac_content = xs_html_tag("div", + xs_html_attr("class", "snac-content")); + if (xs_startswith(sc, "

")) - s = xs_str_cat(s, sc); - else { - xs *s1 = xs_fmt("

%s

", sc); + xs_html_add(snac_content, + xs_html_raw(sc)); /* already sanitized */ + else + xs_html_add(snac_content, + xs_html_tag("p", + xs_html_raw(sc))); /* already sanitized */ + + { + xs *s1 = xs_html_render(snac_content); s = xs_str_cat(s, s1); } - - s = xs_str_cat(s, "
\n"); }