From 04b253200b04048abc5bdc5490d619532334ee51 Mon Sep 17 00:00:00 2001 From: default Date: Mon, 27 Nov 2023 21:54:57 +0100 Subject: [PATCH] More html_entry() refactoring. --- html.c | 81 +++++++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 44 deletions(-) diff --git a/html.c b/html.c index 976cd35..544cbad 100644 --- a/html.c +++ b/html.c @@ -1298,10 +1298,13 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local, else s = xs_str_cat(s, "
\n"); /** **/ - s = xs_str_cat(s, "
\n"); /** **/ + /** post header **/ - xs_html *score = xs_html_tag("div", - xs_html_attr("class", "snac-score")); + xs_html *score; + xs_html *post_header = xs_html_tag("div", + xs_html_attr("class", "snac-post-header"), + score = xs_html_tag("div", + xs_html_attr("class", "snac-score"))); if (user && is_pinned(user, id)) { /* add a pin emoji */ @@ -1339,11 +1342,6 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local, xs_html_raw(s1)); } - { - xs *s1 = xs_html_render(score); - s = xs_str_cat(s, s1); - } - if (boosts == NULL) boosts = object_announces(id); @@ -1354,33 +1352,28 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local, if (user && xs_list_in(boosts, user->md5) != -1) { /* we boosted this */ - xs_html *h = xs_html_tag("div", - xs_html_attr("class", "snac-origin"), - xs_html_tag("a", - xs_html_attr("href", user->actor), - xs_html_text(xs_dict_get(user->config, "name"))), - xs_html_text(" "), - xs_html_text(L("boosted"))); - - xs *s1 = xs_html_render(h); - s = xs_str_cat(s, s1); + xs_html_add(post_header, + xs_html_tag("div", + xs_html_attr("class", "snac-origin"), + xs_html_tag("a", + xs_html_attr("href", user->actor), + xs_html_text(xs_dict_get(user->config, "name"))), + xs_html_text(" "), + xs_html_text(L("boosted")))); } else if (valid_status(object_get_by_md5(p, &actor_r))) { xs *name = actor_name(actor_r); if (!xs_is_null(name)) { - xs_html *h = xs_html_tag("div", - xs_html_attr("class", "snac-origin"), - xs_html_tag("a", - xs_html_attr("href", xs_dict_get(actor_r, "id")), - xs_html_text(name)), - xs_html_text(" "), - xs_html_text(L("boosted"))); - - xs *s1 = xs_html_render(h); - - s = xs_str_cat(s, s1); + xs_html_add(post_header, + xs_html_tag("div", + xs_html_attr("class", "snac-origin"), + xs_html_tag("a", + xs_html_attr("href", xs_dict_get(actor_r, "id")), + xs_html_text(name)), + xs_html_text(" "), + xs_html_text(L("boosted")))); } } } @@ -1391,29 +1384,29 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local, char *parent = xs_dict_get(msg, "inReplyTo"); if (user && !xs_is_null(parent) && *parent && !timeline_here(user, parent)) { - xs_html *h = xs_html_tag("div", - xs_html_attr("class", "snac-origin"), - xs_html_text(L("in reply to")), - xs_html_text(" "), - xs_html_tag("a", - xs_html_attr("href", parent), - xs_html_text("»"))); - - xs *s1 = xs_html_render(h); - - s = xs_str_cat(s, s1); + xs_html_add(post_header, + xs_html_tag("div", + xs_html_attr("class", "snac-origin"), + xs_html_text(L("in reply to")), + xs_html_text(" "), + xs_html_tag("a", + xs_html_attr("href", parent), + xs_html_text("»")))); } } } + xs_html_add(post_header, + html_msg_icon(msg)); + { - xs_html *h = html_msg_icon(msg); - xs *s1 = xs_html_render(h); + xs *s1 = xs_html_render(post_header); s = xs_str_cat(s, s1); } - /* add the content */ - s = xs_str_cat(s, "
\n
\n"); /** **/ + /** post content **/ + + s = xs_str_cat(s, "\n
\n"); /** **/ if (!xs_is_null(v = xs_dict_get(msg, "name"))) { xs *es1 = encode_html(v);