From 6317c9678de9e5a9d6100bcc520bcc15609a2f0b Mon Sep 17 00:00:00 2001 From: default Date: Thu, 29 Sep 2022 10:27:09 +0200 Subject: [PATCH] Simplified HTML. --- html.c | 58 ++++++++++++++++++---------------------------------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/html.c b/html.c index bdf0bbe..9c71453 100644 --- a/html.c +++ b/html.c @@ -371,6 +371,17 @@ d_char *html_top_controls(snac *snac, d_char *s) } +d_char *html_button(d_char *s, char *clss, char *label) +{ + xs *s1 = xs_fmt( + "\n", + clss, label); + + return xs_str_cat(s, s1); +} + + d_char *html_entry_controls(snac *snac, d_char *os, char *msg) { char *id = xs_dict_get(msg, "id"); @@ -410,63 +421,30 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg) l = xs_dict_get(meta, "liked_by"); if (xs_list_in(l, snac->actor) == -1) { /* not already liked; add button */ - xs *s1 = xs_fmt( - "\n", - L("Like") - ); - - s = xs_str_cat(s, s1); + s = html_button(s, "like", L("Like")); } l = xs_dict_get(meta, "announced_by"); if (xs_list_in(l, snac->actor) == -1) { /* not already boosted; add button */ - xs *s1 = xs_fmt( - "\n", - L("Boost") - ); - - s = xs_str_cat(s, s1); + s = html_button(s, "boost", L("Boost")); } if (following_check(snac, actor)) { - xs *s1 = xs_fmt( - "\n", - L("Unfollow") - ); - - s = xs_str_cat(s, s1); + s = html_button(s, "unfollow", L("Unfollow")); } else { - xs *s1 = xs_fmt( - "\n" - "\n", - L("Follow"), - L("MUTE") - ); - - s = xs_str_cat(s, s1); + s = html_button(s, "follow", L("Follow")); + s = html_button(s, "mute", L("MUTE")); } } - { - xs *s1 = xs_fmt( - "\n", - L("Delete") - ); - - s = xs_str_cat(s, s1); - } + s = html_button(s, "delete", L("Delete")); s = xs_str_cat(s, "\n"); { + /* the post textarea */ xs *ct = xs_str_new(""); xs *s1 = xs_fmt(