diff options
| author | 2025-05-19 20:14:07 +0200 | |
|---|---|---|
| committer | 2025-05-19 20:14:07 +0200 | |
| commit | c950981cca0896558ffae7e66b76f43f1ec49969 (patch) | |
| tree | ad0ddf4a345a11f7a4cdc269387adf1f155553a7 /html.c | |
| parent | Operations on the 'people' page redirects back to it instead of 'admin'. (diff) | |
| download | snac2-c950981cca0896558ffae7e66b76f43f1ec49969.tar.gz snac2-c950981cca0896558ffae7e66b76f43f1ec49969.tar.xz snac2-c950981cca0896558ffae7e66b76f43f1ec49969.zip | |
Improved post language markup.
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 | ||
| @@ -1951,6 +1941,15 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1951 | return xs_html_tag("mark", | 1941 | return xs_html_tag("mark", |
| 1952 | xs_html_text(L("Truncated (too deep)"))); | 1942 | xs_html_text(L("Truncated (too deep)"))); |
| 1953 | 1943 | ||
| 1944 | const char *lang = NULL; | ||
| 1945 | const xs_dict *cmap = xs_dict_get(msg, "contentMap"); | ||
| 1946 | if (xs_is_dict(cmap)) { | ||
| 1947 | const char *dummy; | ||
| 1948 | int c = 0; | ||
| 1949 | |||
| 1950 | xs_dict_next(cmap, &lang, &dummy, &c); | ||
| 1951 | } | ||
| 1952 | |||
| 1954 | if (strcmp(type, "Follow") == 0) { | 1953 | if (strcmp(type, "Follow") == 0) { |
| 1955 | return xs_html_tag("div", | 1954 | return xs_html_tag("div", |
| 1956 | xs_html_attr("class", "snac-post"), | 1955 | xs_html_attr("class", "snac-post"), |
| @@ -1959,7 +1958,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1959 | xs_html_tag("div", | 1958 | xs_html_tag("div", |
| 1960 | xs_html_attr("class", "snac-origin"), | 1959 | xs_html_attr("class", "snac-origin"), |
| 1961 | xs_html_text(L("follows you"))), | 1960 | xs_html_text(L("follows you"))), |
| 1962 | html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg, proxy, NULL))); | 1961 | html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg, proxy, NULL, lang))); |
| 1963 | } | 1962 | } |
| 1964 | else | 1963 | else |
| 1965 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { | 1964 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { |
| @@ -2140,13 +2139,17 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2140 | } | 2139 | } |
| 2141 | 2140 | ||
| 2142 | xs_html_add(post_header, | 2141 | xs_html_add(post_header, |
| 2143 | html_msg_icon(read_only ? NULL : user, actor, msg, proxy, md5)); | 2142 | html_msg_icon(read_only ? NULL : user, actor, msg, proxy, md5, lang)); |
| 2144 | 2143 | ||
| 2145 | /** post content **/ | 2144 | /** post content **/ |
| 2146 | 2145 | ||
| 2147 | xs_html *snac_content_wrap = xs_html_tag("div", | 2146 | xs_html *snac_content_wrap = xs_html_tag("div", |
| 2148 | xs_html_attr("class", "e-content snac-content")); | 2147 | xs_html_attr("class", "e-content snac-content")); |
| 2149 | 2148 | ||
| 2149 | if (xs_is_string(lang)) | ||
| 2150 | xs_html_add(snac_content_wrap, | ||
| 2151 | xs_html_attr("lang", lang)); | ||
| 2152 | |||
| 2150 | xs_html_add(entry, | 2153 | xs_html_add(entry, |
| 2151 | snac_content_wrap); | 2154 | snac_content_wrap); |
| 2152 | 2155 | ||