From 5647e675fd59d06b8a9a6016076b45978bdd4d4b Mon Sep 17 00:00:00 2001 From: default Date: Wed, 28 Sep 2022 17:12:39 +0200 Subject: [PATCH] More HTML work. --- html.c | 67 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/html.c b/html.c index c7c1b85..0ff00ea 100644 --- a/html.c +++ b/html.c @@ -175,7 +175,7 @@ d_char *html_msg_icon(snac *snac, d_char *s, char *msg) avatar = xs_fmt("data:image/png;base64, %s", susie); { - xs *s1 = xs_fmt("

\n", avatar); + xs *s1 = xs_fmt("

\"\"/\n", avatar); s = xs_str_cat(s, s1); } @@ -200,8 +200,6 @@ d_char *html_msg_icon(snac *snac, d_char *s, char *msg) xs *s1 = xs_fmt("
\n\n", v); s = xs_str_cat(s, s1); } - - s = xs_str_cat(s, "\n"); } return s; @@ -425,6 +423,8 @@ d_char *html_entry(snac *snac, d_char *s, char *msg, xs_set *seen, int level) s = html_msg_icon(snac, s, msg); /* add the content */ + s = xs_str_cat(s, "

\n"); + { xs *c = xs_dup(xs_dict_get(msg, "content")); @@ -441,32 +441,59 @@ d_char *html_entry(snac *snac, d_char *s, char *msg, xs_set *seen, int level) c = xs_fmt("

%s

", s1); } - xs *s1 = xs_fmt("
\n%s\n", c); - s = xs_str_cat(s, s1); + s = xs_str_cat(s, c); + } - /* now add the attachments */ - char *attach; + /* add the attachments */ + char *attach; - if ((attach = xs_dict_get(msg, "attachment")) != NULL) { - char *v; - while (xs_list_iter(&attach, &v)) { - char *t = xs_dict_get(v, "mediaType"); + if ((attach = xs_dict_get(msg, "attachment")) != NULL) { + char *v; + while (xs_list_iter(&attach, &v)) { + char *t = xs_dict_get(v, "mediaType"); - if (t && xs_startswith(t, "image/")) { - char *url = xs_dict_get(v, "url"); - char *name = xs_dict_get(v, "name"); + if (t && xs_startswith(t, "image/")) { + char *url = xs_dict_get(v, "url"); + char *name = xs_dict_get(v, "name"); - if (url != NULL) { - xs *s1 = xs_fmt("

\"%s\"/

\n", - url, xs_is_null(name) ? "" : name); + if (url != NULL) { + xs *s1 = xs_fmt("

\"%s\"/

\n", + url, xs_is_null(name) ? "" : name); - s = xs_str_cat(s, s1); - } + s = xs_str_cat(s, s1); } } } + } - s = xs_str_cat(s, "
\n"); + s = xs_str_cat(s, "
\n"); + + char *children = xs_dict_get(meta, "children"); + + if (xs_list_len(children)) { + int left = xs_list_len(children); + char *id; + + s = xs_str_cat(s, "
\n"); + + if (left > 3) + s = xs_str_cat(s, "
...\n"); + + while (xs_list_iter(&children, &id)) { + xs *chd = timeline_find(snac, id); + + if (left == 0) + s = xs_str_cat(s, "
\n"); + + if (chd != NULL) + s = html_entry(snac, s, chd, seen, level + 1); + else + snac_debug(snac, 1, xs_fmt("cannot read from timeline child %s", id)); + + left--; + } + + s = xs_str_cat(s, "
\n"); } s = xs_str_cat(s, " \n");