diff options
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 79 |
1 files changed, 71 insertions, 8 deletions
| @@ -368,7 +368,8 @@ xs_html *html_note(snac *user, const char *summary, | |||
| 368 | const xs_val *mnt_only, const char *redir, | 368 | const xs_val *mnt_only, const char *redir, |
| 369 | const char *in_reply_to, int poll, | 369 | const char *in_reply_to, int poll, |
| 370 | const xs_list *att_files, const xs_list *att_alt_texts, | 370 | const xs_list *att_files, const xs_list *att_alt_texts, |
| 371 | int is_draft, const char *published) | 371 | int is_draft, const char *published, |
| 372 | const char *note_lang) | ||
| 372 | /* Yes, this is a FUCKTON of arguments and I'm a bit embarrased */ | 373 | /* Yes, this is a FUCKTON of arguments and I'm a bit embarrased */ |
| 373 | { | 374 | { |
| 374 | xs *action = xs_fmt("%s/admin/note", user->actor); | 375 | xs *action = xs_fmt("%s/admin/note", user->actor); |
| @@ -458,6 +459,40 @@ xs_html *html_note(snac *user, const char *summary, | |||
| 458 | xs_html_attr("name", "is_draft"), | 459 | xs_html_attr("name", "is_draft"), |
| 459 | xs_html_attr(is_draft ? "checked" : "", NULL)))); | 460 | xs_html_attr(is_draft ? "checked" : "", NULL)))); |
| 460 | 461 | ||
| 462 | const char *post_langs = xs_dict_get(user->config, "post_langs"); | ||
| 463 | |||
| 464 | if (xs_is_string(post_langs) && *post_langs) { | ||
| 465 | xs *ll = xs_split(post_langs, " "); | ||
| 466 | const char *lang; | ||
| 467 | |||
| 468 | xs_html *post_lang = xs_html_tag("select", | ||
| 469 | xs_html_attr("name", "post_lang")); | ||
| 470 | |||
| 471 | xs_list_foreach(ll, lang) { | ||
| 472 | if (*lang) { | ||
| 473 | if (xs_is_string(note_lang) && strcmp(lang, note_lang) == 0) { | ||
| 474 | xs_html_add(post_lang, | ||
| 475 | xs_html_tag("option", | ||
| 476 | xs_html_text(lang), | ||
| 477 | xs_html_attr("selected", NULL), | ||
| 478 | xs_html_attr("value", lang))); | ||
| 479 | } | ||
| 480 | else { | ||
| 481 | xs_html_add(post_lang, | ||
| 482 | xs_html_tag("option", | ||
| 483 | xs_html_text(lang), | ||
| 484 | xs_html_attr("value", lang))); | ||
| 485 | } | ||
| 486 | } | ||
| 487 | } | ||
| 488 | |||
| 489 | xs_html_add(form, | ||
| 490 | xs_html_tag("p", NULL), | ||
| 491 | xs_html_text(L("Language:")), | ||
| 492 | xs_html_text(" "), | ||
| 493 | post_lang); | ||
| 494 | } | ||
| 495 | |||
| 461 | /* post date and time */ | 496 | /* post date and time */ |
| 462 | xs *post_date = NULL; | 497 | xs *post_date = NULL; |
| 463 | xs *post_time = NULL; | 498 | xs *post_time = NULL; |
| @@ -1202,7 +1237,7 @@ xs_html *html_top_controls(snac *user) | |||
| 1202 | NULL, NULL, | 1237 | NULL, NULL, |
| 1203 | xs_stock(XSTYPE_FALSE), "", | 1238 | xs_stock(XSTYPE_FALSE), "", |
| 1204 | xs_stock(XSTYPE_FALSE), NULL, | 1239 | xs_stock(XSTYPE_FALSE), NULL, |
| 1205 | NULL, 1, NULL, NULL, 0, NULL), | 1240 | NULL, 1, NULL, NULL, 0, NULL, NULL), |
| 1206 | 1241 | ||
| 1207 | /** operations **/ | 1242 | /** operations **/ |
| 1208 | xs_html_tag("details", | 1243 | xs_html_tag("details", |
| @@ -1311,6 +1346,7 @@ xs_html *html_top_controls(snac *user) | |||
| 1311 | const char *latitude = xs_dict_get_def(user->config, "latitude", ""); | 1346 | const char *latitude = xs_dict_get_def(user->config, "latitude", ""); |
| 1312 | const char *longitude = xs_dict_get_def(user->config, "longitude", ""); | 1347 | const char *longitude = xs_dict_get_def(user->config, "longitude", ""); |
| 1313 | const char *webhook = xs_dict_get_def(user->config, "notify_webhook", ""); | 1348 | const char *webhook = xs_dict_get_def(user->config, "notify_webhook", ""); |
| 1349 | const char *post_langs = xs_dict_get_def(user->config, "post_langs", ""); | ||
| 1314 | 1350 | ||
| 1315 | xs *metadata = NULL; | 1351 | xs *metadata = NULL; |
| 1316 | const xs_dict *md = xs_dict_get(user->config, "metadata"); | 1352 | const xs_dict *md = xs_dict_get(user->config, "metadata"); |
| @@ -1587,6 +1623,15 @@ xs_html *html_top_controls(snac *user) | |||
| 1587 | tz_select), | 1623 | tz_select), |
| 1588 | 1624 | ||
| 1589 | xs_html_tag("p", | 1625 | xs_html_tag("p", |
| 1626 | xs_html_text(L("Languages you usually post in:")), | ||
| 1627 | xs_html_sctag("br", NULL), | ||
| 1628 | xs_html_sctag("input", | ||
| 1629 | xs_html_attr("type", "next"), | ||
| 1630 | xs_html_attr("name", "post_langs"), | ||
| 1631 | xs_html_attr("value", post_langs), | ||
| 1632 | xs_html_attr("placeholder", L("en fr es de_AT")))), | ||
| 1633 | |||
| 1634 | xs_html_tag("p", | ||
| 1590 | xs_html_text(L("New password:")), | 1635 | xs_html_text(L("New password:")), |
| 1591 | xs_html_sctag("br", NULL), | 1636 | xs_html_sctag("br", NULL), |
| 1592 | xs_html_sctag("input", | 1637 | xs_html_sctag("input", |
| @@ -1888,6 +1933,15 @@ xs_html *html_entry_controls(snac *user, const char *actor, | |||
| 1888 | } | 1933 | } |
| 1889 | } | 1934 | } |
| 1890 | 1935 | ||
| 1936 | const char *note_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, ¬e_lang, &dummy, &c); | ||
| 1943 | } | ||
| 1944 | |||
| 1891 | xs_html_add(controls, xs_html_tag("div", | 1945 | xs_html_add(controls, xs_html_tag("div", |
| 1892 | xs_html_tag("p", NULL), | 1946 | xs_html_tag("p", NULL), |
| 1893 | html_note(user, L("Edit..."), | 1947 | html_note(user, L("Edit..."), |
| @@ -1897,7 +1951,7 @@ xs_html *html_entry_controls(snac *user, const char *actor, | |||
| 1897 | xs_dict_get(msg, "sensitive"), xs_dict_get(msg, "summary"), | 1951 | xs_dict_get(msg, "sensitive"), xs_dict_get(msg, "summary"), |
| 1898 | xs_stock(is_msg_public(msg) ? XSTYPE_FALSE : XSTYPE_TRUE), redir, | 1952 | xs_stock(is_msg_public(msg) ? XSTYPE_FALSE : XSTYPE_TRUE), redir, |
| 1899 | NULL, 0, att_files, att_alt_texts, is_draft(user, id), | 1953 | NULL, 0, att_files, att_alt_texts, is_draft(user, id), |
| 1900 | xs_dict_get(msg, "published"))), | 1954 | xs_dict_get(msg, "published"), note_lang)), |
| 1901 | xs_html_tag("p", NULL)); | 1955 | xs_html_tag("p", NULL)); |
| 1902 | } | 1956 | } |
| 1903 | 1957 | ||
| @@ -1916,7 +1970,7 @@ xs_html *html_entry_controls(snac *user, const char *actor, | |||
| 1916 | NULL, NULL, | 1970 | NULL, NULL, |
| 1917 | xs_dict_get(msg, "sensitive"), xs_dict_get(msg, "summary"), | 1971 | xs_dict_get(msg, "sensitive"), xs_dict_get(msg, "summary"), |
| 1918 | xs_stock(is_msg_public(msg) ? XSTYPE_FALSE : XSTYPE_TRUE), redir, | 1972 | xs_stock(is_msg_public(msg) ? XSTYPE_FALSE : XSTYPE_TRUE), redir, |
| 1919 | id, 0, NULL, NULL, 0, NULL)), | 1973 | id, 0, NULL, NULL, 0, NULL, NULL)), |
| 1920 | xs_html_tag("p", NULL)); | 1974 | xs_html_tag("p", NULL)); |
| 1921 | } | 1975 | } |
| 1922 | 1976 | ||
| @@ -2855,7 +2909,7 @@ xs_html *html_footer(const snac *user) | |||
| 2855 | xs_html_attr("href", WHAT_IS_SNAC_URL), | 2909 | xs_html_attr("href", WHAT_IS_SNAC_URL), |
| 2856 | xs_html_tag("abbr", | 2910 | xs_html_tag("abbr", |
| 2857 | xs_html_attr("title", "Social Networks Are Crap"), | 2911 | xs_html_attr("title", "Social Networks Are Crap"), |
| 2858 | xs_html_text("snac")))); | 2912 | xs_html_text(USER_AGENT)))); |
| 2859 | } | 2913 | } |
| 2860 | 2914 | ||
| 2861 | 2915 | ||
| @@ -3002,7 +3056,13 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 3002 | const char *ht; | 3056 | const char *ht; |
| 3003 | 3057 | ||
| 3004 | xs_list_foreach(followed_hashtags, ht) { | 3058 | xs_list_foreach(followed_hashtags, ht) { |
| 3005 | xs *url = xs_fmt("%s/admin?q=%s", user->actor, ht); | 3059 | xs *url = NULL; |
| 3060 | |||
| 3061 | if (!xs_startswith(ht, "https:/""/")) | ||
| 3062 | url = xs_fmt("%s/admin?q=%s", user->actor, ht); | ||
| 3063 | else | ||
| 3064 | url = xs_dup(ht); | ||
| 3065 | |||
| 3006 | url = xs_replace_i(url, "#", "%23"); | 3066 | url = xs_replace_i(url, "#", "%23"); |
| 3007 | 3067 | ||
| 3008 | xs_html_add(loht, | 3068 | xs_html_add(loht, |
| @@ -3298,7 +3358,7 @@ xs_html *html_people_list(snac *user, xs_list *list, const char *header, const c | |||
| 3298 | NULL, actor_id, | 3358 | NULL, actor_id, |
| 3299 | xs_stock(XSTYPE_FALSE), "", | 3359 | xs_stock(XSTYPE_FALSE), "", |
| 3300 | xs_stock(XSTYPE_FALSE), NULL, | 3360 | xs_stock(XSTYPE_FALSE), NULL, |
| 3301 | NULL, 0, NULL, NULL, 0, NULL), | 3361 | NULL, 0, NULL, NULL, 0, NULL, NULL), |
| 3302 | xs_html_tag("p", NULL)); | 3362 | xs_html_tag("p", NULL)); |
| 3303 | 3363 | ||
| 3304 | xs_html_add(snac_post, snac_controls); | 3364 | xs_html_add(snac_post, snac_controls); |
| @@ -4384,6 +4444,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 4384 | const char *edit_id = xs_dict_get(p_vars, "edit_id"); | 4444 | const char *edit_id = xs_dict_get(p_vars, "edit_id"); |
| 4385 | const char *post_date = xs_dict_get_def(p_vars, "post_date", ""); | 4445 | const char *post_date = xs_dict_get_def(p_vars, "post_date", ""); |
| 4386 | const char *post_time = xs_dict_get_def(p_vars, "post_time", ""); | 4446 | const char *post_time = xs_dict_get_def(p_vars, "post_time", ""); |
| 4447 | const char *post_lang = xs_dict_get(p_vars, "post_lang"); | ||
| 4387 | int priv = !xs_is_null(xs_dict_get(p_vars, "mentioned_only")); | 4448 | int priv = !xs_is_null(xs_dict_get(p_vars, "mentioned_only")); |
| 4388 | int store_as_draft = !xs_is_null(xs_dict_get(p_vars, "is_draft")); | 4449 | int store_as_draft = !xs_is_null(xs_dict_get(p_vars, "is_draft")); |
| 4389 | xs *attach_list = xs_list_new(); | 4450 | xs *attach_list = xs_list_new(); |
| @@ -4467,7 +4528,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 4467 | enqueue_close_question(&snac, xs_dict_get(msg, "id"), end_secs); | 4528 | enqueue_close_question(&snac, xs_dict_get(msg, "id"), end_secs); |
| 4468 | } | 4529 | } |
| 4469 | else | 4530 | else |
| 4470 | msg = msg_note(&snac, content_2, to, in_reply_to, attach_list, priv, NULL, NULL); | 4531 | msg = msg_note(&snac, content_2, to, in_reply_to, attach_list, priv, post_lang, NULL); |
| 4471 | 4532 | ||
| 4472 | if (sensitive != NULL) { | 4533 | if (sensitive != NULL) { |
| 4473 | msg = xs_dict_set(msg, "sensitive", xs_stock(XSTYPE_TRUE)); | 4534 | msg = xs_dict_set(msg, "sensitive", xs_stock(XSTYPE_TRUE)); |
| @@ -4873,6 +4934,8 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 4873 | snac.config = xs_dict_set(snac.config, "lang", v); | 4934 | snac.config = xs_dict_set(snac.config, "lang", v); |
| 4874 | if ((v = xs_dict_get(p_vars, "tz")) != NULL) | 4935 | if ((v = xs_dict_get(p_vars, "tz")) != NULL) |
| 4875 | snac.config = xs_dict_set(snac.config, "tz", v); | 4936 | snac.config = xs_dict_set(snac.config, "tz", v); |
| 4937 | if ((v = xs_dict_get(p_vars, "post_langs")) != NULL) | ||
| 4938 | snac.config = xs_dict_set(snac.config, "post_langs", v); | ||
| 4876 | 4939 | ||
| 4877 | snac.config = xs_dict_set(snac.config, "latitude", xs_dict_get_def(p_vars, "latitude", "")); | 4940 | snac.config = xs_dict_set(snac.config, "latitude", xs_dict_get_def(p_vars, "latitude", "")); |
| 4878 | snac.config = xs_dict_set(snac.config, "longitude", xs_dict_get_def(p_vars, "longitude", "")); | 4941 | snac.config = xs_dict_set(snac.config, "longitude", xs_dict_get_def(p_vars, "longitude", "")); |