diff --git a/html.c b/html.c index b2c75fe..4161d83 100644 --- a/html.c +++ b/html.c @@ -251,9 +251,9 @@ d_char *html_user_header(snac *snac, d_char *s, int local) xs *s1; if (local) - s1 = xs_fmt("%s", snac->actor, L("admin")); + s1 = xs_fmt("%s\n", snac->actor, L("admin")); else - s1 = xs_fmt("%s", snac->actor, L("public")); + s1 = xs_fmt("%s\n", snac->actor, L("public")); s = xs_str_cat(s, s1); } @@ -408,8 +408,8 @@ d_char *html_entry(snac *snac, d_char *s, char *msg, xs_set *seen, int level) name = xs_dict_get(actor_r, "preferredUsername"); xs *s1 = xs_fmt( - "
\n" - "%s %s
", + "
" + "%s %s
\n", xs_dict_get(actor_r, "id"), name, "boosted" @@ -441,19 +441,54 @@ 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", c); - + xs *s1 = xs_fmt("
\n%s\n", c); s = xs_str_cat(s, s1); - s = xs_str_cat(s, "
\n"); + /* now 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 (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, name == NULL ? "" : name); + + s = xs_str_cat(s, s1); + } + } + } + } + + s = xs_str_cat(s, "
\n"); } - s = xs_str_cat(s, "\n"); + s = xs_str_cat(s, " \n"); return s; } +d_char *html_user_footer(snac *snac, d_char *s) +{ + xs *s1 = xs_fmt( + "
\n" + "%s - " + "powered by snac
\n", + srv_baseurl, + L("about this site") + ); + + return xs_str_cat(s, s1); +} + + d_char *html_timeline(snac *snac, char *list, int local) /* returns the HTML for the timeline */ { @@ -474,35 +509,9 @@ d_char *html_timeline(snac *snac, char *list, int local) s = html_entry(snac, s, msg, seen, 0); } - s = xs_str_cat(s, "\n"); + s = xs_str_cat(s, " \n"); -#if 0 - s = xs_str_cat(s, "

HI

\n"); - - s = xs_str_cat(s, xs_fmt("len() == %d\n", xs_list_len(list))); - - { - char *i = xs_list_get(list, 0); - xs *msg = timeline_get(snac, i); - - s = html_msg_icon(snac, s, msg); - } - - s = xs_str_cat(s, "\n"); -#endif - - { - /* footer */ - xs *s1 = xs_fmt( - "
\n" - "%s - " - "powered by snac
\n", - srv_baseurl, - L("about this site") - ); - - s = xs_str_cat(s, s1); - } + s = html_user_footer(snac, s); s = xs_str_cat(s, "\n\n");