diff options
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 31 |
1 files changed, 17 insertions, 14 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 | ||
| @@ -1943,6 +1933,15 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1943 | return xs_html_tag("mark", | 1933 | return xs_html_tag("mark", |
| 1944 | xs_html_text(L("Truncated (too deep)"))); | 1934 | xs_html_text(L("Truncated (too deep)"))); |
| 1945 | 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 | |||
| 1946 | if (strcmp(type, "Follow") == 0) { | 1945 | if (strcmp(type, "Follow") == 0) { |
| 1947 | return xs_html_tag("div", | 1946 | return xs_html_tag("div", |
| 1948 | xs_html_attr("class", "snac-post"), | 1947 | xs_html_attr("class", "snac-post"), |
| @@ -1951,7 +1950,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1951 | xs_html_tag("div", | 1950 | xs_html_tag("div", |
| 1952 | xs_html_attr("class", "snac-origin"), | 1951 | xs_html_attr("class", "snac-origin"), |
| 1953 | xs_html_text(L("follows you"))), | 1952 | xs_html_text(L("follows you"))), |
| 1954 | 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))); |
| 1955 | } | 1954 | } |
| 1956 | else | 1955 | else |
| 1957 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { | 1956 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { |
| @@ -2132,13 +2131,17 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2132 | } | 2131 | } |
| 2133 | 2132 | ||
| 2134 | xs_html_add(post_header, | 2133 | xs_html_add(post_header, |
| 2135 | html_msg_icon(read_only ? NULL : user, actor, msg, proxy, md5)); | 2134 | html_msg_icon(read_only ? NULL : user, actor, msg, proxy, md5, lang)); |
| 2136 | 2135 | ||
| 2137 | /** post content **/ | 2136 | /** post content **/ |
| 2138 | 2137 | ||
| 2139 | xs_html *snac_content_wrap = xs_html_tag("div", | 2138 | xs_html *snac_content_wrap = xs_html_tag("div", |
| 2140 | xs_html_attr("class", "e-content snac-content")); | 2139 | xs_html_attr("class", "e-content snac-content")); |
| 2141 | 2140 | ||
| 2141 | if (xs_is_string(lang)) | ||
| 2142 | xs_html_add(snac_content_wrap, | ||
| 2143 | xs_html_attr("lang", lang)); | ||
| 2144 | |||
| 2142 | xs_html_add(entry, | 2145 | xs_html_add(entry, |
| 2143 | snac_content_wrap); | 2146 | snac_content_wrap); |
| 2144 | 2147 | ||