From 49134582055a174951b23314170ec42c33796325 Mon Sep 17 00:00:00 2001 From: default Date: Mon, 17 Mar 2025 08:18:41 +0100 Subject: mastoapi: added support for /api/v1/custom_emojis (contributed by violette). --- html.c | 1 + 1 file changed, 1 insertion(+) (limited to 'html.c') diff --git a/html.c b/html.c index a90a51f..a56b523 100644 --- a/html.c +++ b/html.c @@ -92,6 +92,7 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p xs_html *img = xs_html_sctag("img", xs_html_attr("loading", "lazy"), xs_html_attr("src", url), + xs_html_attr("alt", n), xs_html_attr("style", style)); xs *s1 = xs_html_render(img); -- cgit v1.2.3 From 83c2888a12fb4b3cedff0a8c033532e622f74d8c Mon Sep 17 00:00:00 2001 From: default Date: Mon, 17 Mar 2025 19:58:17 +0100 Subject: If a child post is from the same author, don't indent it. --- html.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index a56b523..fe3b4a1 100644 --- a/html.c +++ b/html.c @@ -2585,6 +2585,12 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, xs_html_add(entry, ch_details); + xs_html *fch_container = xs_html_tag("div", + xs_html_attr("class", "snac-thread-cont")); + + xs_html_add(ch_details, + fch_container); + xs_html *ch_container = xs_html_tag("div", xs_html_attr("class", level < 4 ? "snac-children" : "snac-children-too-deep")); @@ -2599,12 +2605,40 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, xs_html_text(L("Older..."))))); } - xs_list *p = children; + int ctxt = 0; const char *cmd5; int cnt = 0; int o_cnt = 0; - while (xs_list_iter(&p, &cmd5)) { + /* get the first child */ + xs_list_next(children, &cmd5, &ctxt); + xs *f_chd = NULL; + + if (user) + timeline_get_by_md5(user, cmd5, &f_chd); + else + object_get_by_md5(cmd5, &f_chd); + + if (f_chd != NULL && xs_is_null(xs_dict_get(f_chd, "name"))) { + const char *p_author = get_atto(msg); + const char *author = get_atto(f_chd); + + /* is the first child from the same author? */ + if (xs_is_string(p_author) && xs_is_string(author) && strcmp(p_author, author) == 0) { + /* then, don't add it to the children container, + so that it appears unindented just before the parent + like a fucking Twitter-like thread */ + xs_html_add(fch_container, + html_entry(user, f_chd, read_only, level + 1, cmd5, hide_children)); + + cnt++; + left--; + } + else + ctxt = 0; /* restart from the beginning */ + } + + while (xs_list_next(children, &cmd5, &ctxt)) { xs *chd = NULL; if (user) -- cgit v1.2.3 From 6f310aff4f38679b2f85e1e7e55705e2710e8bcc Mon Sep 17 00:00:00 2001 From: default Date: Wed, 19 Mar 2025 17:07:29 +0100 Subject: Hide the first child container if it's empty. --- html.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'html.c') diff --git a/html.c b/html.c index fe3b4a1..78a9854 100644 --- a/html.c +++ b/html.c @@ -2609,6 +2609,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, const char *cmd5; int cnt = 0; int o_cnt = 0; + int f_cnt = 0; /* get the first child */ xs_list_next(children, &cmd5, &ctxt); @@ -2632,6 +2633,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, html_entry(user, f_chd, read_only, level + 1, cmd5, hide_children)); cnt++; + f_cnt++; left--; } else @@ -2680,6 +2682,10 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, if (o_cnt == 0 && ch_older) xs_html_add(ch_older, xs_html_attr("style", "display: none")); + + if (f_cnt == 0) + xs_html_add(fch_container, + xs_html_attr("style", "display: none")); } } -- cgit v1.2.3