diff options
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 43 |
1 files changed, 19 insertions, 24 deletions
| @@ -332,7 +332,8 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, | |||
| 332 | } | 332 | } |
| 333 | 333 | ||
| 334 | 334 | ||
| 335 | xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, const char *proxy, const char *md5) | 335 | xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, |
| 336 | const char *proxy, const char *md5, const char *lang) | ||
| 336 | { | 337 | { |
| 337 | xs *actor = NULL; | 338 | xs *actor = NULL; |
| 338 | xs_html *actor_icon = NULL; | 339 | 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 | |||
| 341 | const char *date = NULL; | 342 | const char *date = NULL; |
| 342 | const char *udate = NULL; | 343 | const char *udate = NULL; |
| 343 | const char *url = NULL; | 344 | const char *url = NULL; |
| 344 | const char *lang = NULL; | ||
| 345 | int priv = 0; | 345 | int priv = 0; |
| 346 | const char *type = xs_dict_get(msg, "type"); | 346 | const char *type = xs_dict_get(msg, "type"); |
| 347 | 347 | ||
| @@ -353,16 +353,6 @@ xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, con | |||
| 353 | date = xs_dict_get(msg, "published"); | 353 | date = xs_dict_get(msg, "published"); |
| 354 | udate = xs_dict_get(msg, "updated"); | 354 | udate = xs_dict_get(msg, "updated"); |
| 355 | 355 | ||
| 356 | lang = xs_dict_get(msg, "contentMap"); | ||
| 357 | if (xs_is_dict(lang)) { | ||
| 358 | const char *v; | ||
| 359 | int c = 0; | ||
| 360 | |||
| 361 | xs_dict_next(lang, &lang, &v, &c); | ||
| 362 | } | ||
| 363 | else | ||
| 364 | lang = NULL; | ||
| 365 | |||
| 366 | actor_icon = html_actor_icon(user, actor, date, udate, url, priv, 0, proxy, lang, md5); | 356 | actor_icon = html_actor_icon(user, actor, date, udate, url, priv, 0, proxy, lang, md5); |
| 367 | } | 357 | } |
| 368 | 358 | ||
| @@ -821,11 +811,7 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url) | |||
| 821 | 811 | ||
| 822 | /* show metrics in og:description? */ | 812 | /* show metrics in og:description? */ |
| 823 | if (xs_is_true(xs_dict_get(user->config, "show_contact_metrics"))) { | 813 | if (xs_is_true(xs_dict_get(user->config, "show_contact_metrics"))) { |
| 824 | xs *fwers = follower_list(user); | 814 | xs *s1 = xs_fmt(L("%d following, %d followers"), following_list_len(user), follower_list_len(user)); |
| 825 | xs *fwing = following_list(user); | ||
| 826 | |||
| 827 | xs *s1 = xs_fmt(L("%d following, %d followers"), | ||
| 828 | xs_list_len(fwing), xs_list_len(fwers)); | ||
| 829 | 815 | ||
| 830 | s1 = xs_str_cat(s1, " · "); | 816 | s1 = xs_str_cat(s1, " · "); |
| 831 | 817 | ||
| @@ -1166,11 +1152,7 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 1166 | } | 1152 | } |
| 1167 | 1153 | ||
| 1168 | if (xs_is_true(xs_dict_get(user->config, "show_contact_metrics"))) { | 1154 | if (xs_is_true(xs_dict_get(user->config, "show_contact_metrics"))) { |
| 1169 | xs *fwers = follower_list(user); | 1155 | xs *s1 = xs_fmt(L("%d following, %d followers"), following_list_len(user), follower_list_len(user)); |
| 1170 | xs *fwing = following_list(user); | ||
| 1171 | |||
| 1172 | xs *s1 = xs_fmt(L("%d following, %d followers"), | ||
| 1173 | xs_list_len(fwing), xs_list_len(fwers)); | ||
| 1174 | 1156 | ||
| 1175 | xs_html_add(top_user, | 1157 | xs_html_add(top_user, |
| 1176 | xs_html_tag("p", | 1158 | xs_html_tag("p", |
| @@ -1951,6 +1933,15 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1951 | return xs_html_tag("mark", | 1933 | return xs_html_tag("mark", |
| 1952 | xs_html_text(L("Truncated (too deep)"))); | 1934 | xs_html_text(L("Truncated (too deep)"))); |
| 1953 | 1935 | ||
| 1936 | const char *lang = NULL; | ||
| 1937 | const xs_dict *cmap = xs_dict_get(msg, "contentMap"); | ||
| 1938 | if (xs_is_dict(cmap)) { | ||
| 1939 | const char *dummy; | ||
| 1940 | int c = 0; | ||
| 1941 | |||
| 1942 | xs_dict_next(cmap, &lang, &dummy, &c); | ||
| 1943 | } | ||
| 1944 | |||
| 1954 | if (strcmp(type, "Follow") == 0) { | 1945 | if (strcmp(type, "Follow") == 0) { |
| 1955 | return xs_html_tag("div", | 1946 | return xs_html_tag("div", |
| 1956 | xs_html_attr("class", "snac-post"), | 1947 | xs_html_attr("class", "snac-post"), |
| @@ -1959,7 +1950,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1959 | xs_html_tag("div", | 1950 | xs_html_tag("div", |
| 1960 | xs_html_attr("class", "snac-origin"), | 1951 | xs_html_attr("class", "snac-origin"), |
| 1961 | xs_html_text(L("follows you"))), | 1952 | xs_html_text(L("follows you"))), |
| 1962 | html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg, proxy, NULL))); | 1953 | html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg, proxy, NULL, lang))); |
| 1963 | } | 1954 | } |
| 1964 | else | 1955 | else |
| 1965 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { | 1956 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { |
| @@ -2140,13 +2131,17 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2140 | } | 2131 | } |
| 2141 | 2132 | ||
| 2142 | xs_html_add(post_header, | 2133 | xs_html_add(post_header, |
| 2143 | html_msg_icon(read_only ? NULL : user, actor, msg, proxy, md5)); | 2134 | html_msg_icon(read_only ? NULL : user, actor, msg, proxy, md5, lang)); |
| 2144 | 2135 | ||
| 2145 | /** post content **/ | 2136 | /** post content **/ |
| 2146 | 2137 | ||
| 2147 | xs_html *snac_content_wrap = xs_html_tag("div", | 2138 | xs_html *snac_content_wrap = xs_html_tag("div", |
| 2148 | xs_html_attr("class", "e-content snac-content")); | 2139 | xs_html_attr("class", "e-content snac-content")); |
| 2149 | 2140 | ||
| 2141 | if (xs_is_string(lang)) | ||
| 2142 | xs_html_add(snac_content_wrap, | ||
| 2143 | xs_html_attr("lang", lang)); | ||
| 2144 | |||
| 2150 | xs_html_add(entry, | 2145 | xs_html_add(entry, |
| 2151 | snac_content_wrap); | 2146 | snac_content_wrap); |
| 2152 | 2147 | ||