mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
More HTML work.
This commit is contained in:
parent
7ae3064210
commit
5647e675fd
1 changed files with 47 additions and 20 deletions
39
html.c
39
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);
|
avatar = xs_fmt("data:image/png;base64, %s", susie);
|
||||||
|
|
||||||
{
|
{
|
||||||
xs *s1 = xs_fmt("<p><img class=\"snac-avatar\" src=\"%s\"/>\n", avatar);
|
xs *s1 = xs_fmt("<p><img class=\"snac-avatar\" src=\"%s\" alt=\"\"/>\n", avatar);
|
||||||
s = xs_str_cat(s, s1);
|
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("<br>\n<time class=\"dt-published snac-pubdate\">%s</time>\n", v);
|
xs *s1 = xs_fmt("<br>\n<time class=\"dt-published snac-pubdate\">%s</time>\n", v);
|
||||||
s = xs_str_cat(s, s1);
|
s = xs_str_cat(s, s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
s = xs_str_cat(s, "</div>\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
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);
|
s = html_msg_icon(snac, s, msg);
|
||||||
|
|
||||||
/* add the content */
|
/* add the content */
|
||||||
|
s = xs_str_cat(s, "<div class=\"e-content snac-content\">\n");
|
||||||
|
|
||||||
{
|
{
|
||||||
xs *c = xs_dup(xs_dict_get(msg, "content"));
|
xs *c = xs_dup(xs_dict_get(msg, "content"));
|
||||||
|
|
||||||
|
@ -441,10 +441,10 @@ d_char *html_entry(snac *snac, d_char *s, char *msg, xs_set *seen, int level)
|
||||||
c = xs_fmt("<p>%s</p>", s1);
|
c = xs_fmt("<p>%s</p>", s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
xs *s1 = xs_fmt("<div class=\"e-content snac-content\">\n%s\n", c);
|
s = xs_str_cat(s, c);
|
||||||
s = xs_str_cat(s, s1);
|
}
|
||||||
|
|
||||||
/* now add the attachments */
|
/* add the attachments */
|
||||||
char *attach;
|
char *attach;
|
||||||
|
|
||||||
if ((attach = xs_dict_get(msg, "attachment")) != NULL) {
|
if ((attach = xs_dict_get(msg, "attachment")) != NULL) {
|
||||||
|
@ -467,6 +467,33 @@ d_char *html_entry(snac *snac, d_char *s, char *msg, xs_set *seen, int level)
|
||||||
}
|
}
|
||||||
|
|
||||||
s = xs_str_cat(s, "</div> <!-- e-content -->\n");
|
s = xs_str_cat(s, "</div> <!-- e-content -->\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, "<div class=\"snac-children\">\n");
|
||||||
|
|
||||||
|
if (left > 3)
|
||||||
|
s = xs_str_cat(s, "<details><summary>...</summary>\n");
|
||||||
|
|
||||||
|
while (xs_list_iter(&children, &id)) {
|
||||||
|
xs *chd = timeline_find(snac, id);
|
||||||
|
|
||||||
|
if (left == 0)
|
||||||
|
s = xs_str_cat(s, "</details>\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, "</div> <!-- snac-children -->\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
s = xs_str_cat(s, "</div> <!-- post or child -->\n");
|
s = xs_str_cat(s, "</div> <!-- post or child -->\n");
|
||||||
|
|
Loading…
Reference in a new issue