aboutsummaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/html.c b/html.c
index b27db7a..de2fdce 100644
--- a/html.c
+++ b/html.c
@@ -332,7 +332,8 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
}
-xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, const char *proxy, const char *md5)
+xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg,
+ const char *proxy, const char *md5, const char *lang)
{
xs *actor = NULL;
xs_html *actor_icon = NULL;
@@ -341,7 +342,6 @@ xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, con
const char *date = NULL;
const char *udate = NULL;
const char *url = NULL;
- const char *lang = NULL;
int priv = 0;
const char *type = xs_dict_get(msg, "type");
@@ -353,16 +353,6 @@ xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, con
date = xs_dict_get(msg, "published");
udate = xs_dict_get(msg, "updated");
- lang = xs_dict_get(msg, "contentMap");
- if (xs_is_dict(lang)) {
- const char *v;
- int c = 0;
-
- xs_dict_next(lang, &lang, &v, &c);
- }
- else
- lang = NULL;
-
actor_icon = html_actor_icon(user, actor, date, udate, url, priv, 0, proxy, lang, md5);
}
@@ -821,11 +811,7 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url)
/* show metrics in og:description? */
if (xs_is_true(xs_dict_get(user->config, "show_contact_metrics"))) {
- xs *fwers = follower_list(user);
- xs *fwing = following_list(user);
-
- xs *s1 = xs_fmt(L("%d following, %d followers"),
- xs_list_len(fwing), xs_list_len(fwers));
+ xs *s1 = xs_fmt(L("%d following, %d followers"), following_list_len(user), follower_list_len(user));
s1 = xs_str_cat(s1, " ยท ");
@@ -1166,11 +1152,7 @@ static xs_html *html_user_body(snac *user, int read_only)
}
if (xs_is_true(xs_dict_get(user->config, "show_contact_metrics"))) {
- xs *fwers = follower_list(user);
- xs *fwing = following_list(user);
-
- xs *s1 = xs_fmt(L("%d following, %d followers"),
- xs_list_len(fwing), xs_list_len(fwers));
+ xs *s1 = xs_fmt(L("%d following, %d followers"), following_list_len(user), follower_list_len(user));
xs_html_add(top_user,
xs_html_tag("p",
@@ -1951,6 +1933,15 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
return xs_html_tag("mark",
xs_html_text(L("Truncated (too deep)")));
+ const char *lang = NULL;
+ const xs_dict *cmap = xs_dict_get(msg, "contentMap");
+ if (xs_is_dict(cmap)) {
+ const char *dummy;
+ int c = 0;
+
+ xs_dict_next(cmap, &lang, &dummy, &c);
+ }
+
if (strcmp(type, "Follow") == 0) {
return xs_html_tag("div",
xs_html_attr("class", "snac-post"),
@@ -1959,7 +1950,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
xs_html_tag("div",
xs_html_attr("class", "snac-origin"),
xs_html_text(L("follows you"))),
- html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg, proxy, NULL)));
+ html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg, proxy, NULL, lang)));
}
else
if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) {
@@ -2140,13 +2131,17 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
}
xs_html_add(post_header,
- html_msg_icon(read_only ? NULL : user, actor, msg, proxy, md5));
+ html_msg_icon(read_only ? NULL : user, actor, msg, proxy, md5, lang));
/** post content **/
xs_html *snac_content_wrap = xs_html_tag("div",
xs_html_attr("class", "e-content snac-content"));
+ if (xs_is_string(lang))
+ xs_html_add(snac_content_wrap,
+ xs_html_attr("lang", lang));
+
xs_html_add(entry,
snac_content_wrap);