diff options
| author | 2023-07-19 11:58:22 +0200 | |
|---|---|---|
| committer | 2023-07-19 11:58:22 +0200 | |
| commit | 7950783d41cabd41f691c85dd9844a74f75a6431 (patch) | |
| tree | 65597268d0cea35146b0715515df9bbfb7527792 /html.c | |
| parent | Avoid too deep nesting of html_entry(). (diff) | |
| parent | Merge pull request '[Really optional PR?] html.c / UX: Give admin page more s... (diff) | |
| download | snac2-7950783d41cabd41f691c85dd9844a74f75a6431.tar.gz snac2-7950783d41cabd41f691c85dd9844a74f75a6431.tar.xz snac2-7950783d41cabd41f691c85dd9844a74f75a6431.zip | |
Merge branch 'master' of grunfink-codeberg:grunfink/snac2
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 27 |
1 files changed, 16 insertions, 11 deletions
| @@ -66,7 +66,7 @@ xs_str *actor_name(xs_dict *actor) | |||
| 66 | 66 | ||
| 67 | if (n && i) { | 67 | if (n && i) { |
| 68 | char *u = xs_dict_get(i, "url"); | 68 | char *u = xs_dict_get(i, "url"); |
| 69 | xs *img = xs_fmt("<img src=\"%s\" style=\"height: 1em\" loading=\"lazy\"/>", u); | 69 | xs *img = xs_fmt("<img src=\"%s\" style=\"height: 1em; vertical-align: middle;\" loading=\"lazy\"/>", u); |
| 70 | 70 | ||
| 71 | name = xs_replace_i(name, n, img); | 71 | name = xs_replace_i(name, n, img); |
| 72 | } | 72 | } |
| @@ -392,6 +392,7 @@ d_char *html_top_controls(snac *snac, d_char *s) | |||
| 392 | "<div class=\"snac-top-controls\">\n" | 392 | "<div class=\"snac-top-controls\">\n" |
| 393 | 393 | ||
| 394 | "<div class=\"snac-note\">\n" | 394 | "<div class=\"snac-note\">\n" |
| 395 | "<details><summary>%s</summary>\n" | ||
| 395 | "<form autocomplete=\"off\" method=\"post\" " | 396 | "<form autocomplete=\"off\" method=\"post\" " |
| 396 | "action=\"%s/admin/note\" enctype=\"multipart/form-data\">\n" | 397 | "action=\"%s/admin/note\" enctype=\"multipart/form-data\">\n" |
| 397 | "<textarea class=\"snac-textarea\" name=\"content\" " | 398 | "<textarea class=\"snac-textarea\" name=\"content\" " |
| @@ -425,6 +426,7 @@ d_char *html_top_controls(snac *snac, d_char *s) | |||
| 425 | "<p><input type=\"submit\" class=\"button\" value=\"%s\">\n" | 426 | "<p><input type=\"submit\" class=\"button\" value=\"%s\">\n" |
| 426 | "</form><p>\n" | 427 | "</form><p>\n" |
| 427 | "</div>\n" | 428 | "</div>\n" |
| 429 | "</details>\n" | ||
| 428 | 430 | ||
| 429 | "<div class=\"snac-top-controls-more\">\n" | 431 | "<div class=\"snac-top-controls-more\">\n" |
| 430 | "<details><summary>%s</summary>\n" | 432 | "<details><summary>%s</summary>\n" |
| @@ -528,6 +530,7 @@ d_char *html_top_controls(snac *snac, d_char *s) | |||
| 528 | xs *es6 = encode_html(purge_days); | 530 | xs *es6 = encode_html(purge_days); |
| 529 | 531 | ||
| 530 | xs *s1 = xs_fmt(_tmpl, | 532 | xs *s1 = xs_fmt(_tmpl, |
| 533 | L("New Post..."), | ||
| 531 | snac->actor, | 534 | snac->actor, |
| 532 | L("Sensitive content"), | 535 | L("Sensitive content"), |
| 533 | L("Sensitive content description"), | 536 | L("Sensitive content description"), |
| @@ -547,7 +550,7 @@ d_char *html_top_controls(snac *snac, d_char *s) | |||
| 547 | 550 | ||
| 548 | L("Post"), | 551 | L("Post"), |
| 549 | 552 | ||
| 550 | L("More options..."), | 553 | L("Preferences..."), |
| 551 | 554 | ||
| 552 | snac->actor, | 555 | snac->actor, |
| 553 | L("Follow"), L("(by URL or user@host)"), | 556 | L("Follow"), L("(by URL or user@host)"), |
| @@ -555,7 +558,7 @@ d_char *html_top_controls(snac *snac, d_char *s) | |||
| 555 | snac->actor, | 558 | snac->actor, |
| 556 | L("Boost"), L("(by URL)"), | 559 | L("Boost"), L("(by URL)"), |
| 557 | 560 | ||
| 558 | L("User settings...."), | 561 | L("User Settings"), |
| 559 | snac->actor, | 562 | snac->actor, |
| 560 | L("Display name"), | 563 | L("Display name"), |
| 561 | es1, | 564 | es1, |
| @@ -1038,7 +1041,7 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local, | |||
| 1038 | 1041 | ||
| 1039 | if (n && i) { | 1042 | if (n && i) { |
| 1040 | char *u = xs_dict_get(i, "url"); | 1043 | char *u = xs_dict_get(i, "url"); |
| 1041 | xs *img = xs_fmt("<img src=\"%s\" style=\"height: 1em\" " | 1044 | xs *img = xs_fmt("<img src=\"%s\" style=\"height: 2em; vertical-align: middle;\" " |
| 1042 | "loading=\"lazy\" title=\"%s\"/>", u, n); | 1045 | "loading=\"lazy\" title=\"%s\"/>", u, n); |
| 1043 | 1046 | ||
| 1044 | c = xs_replace_i(c, n, img); | 1047 | c = xs_replace_i(c, n, img); |
| @@ -1900,23 +1903,25 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 1900 | if (!xs_startswith(id, snac.actor)) | 1903 | if (!xs_startswith(id, snac.actor)) |
| 1901 | continue; | 1904 | continue; |
| 1902 | 1905 | ||
| 1903 | xs *es1 = sanitize(xs_dict_get(msg, "content")); | 1906 | xs *content = sanitize(xs_dict_get(msg, "content")); |
| 1904 | xs *content = encode_html(es1); | 1907 | |
| 1908 | // We SHOULD only use sanitized one for description. | ||
| 1909 | // So, only encode for feed title, while the description just keep it sanitized as is. | ||
| 1910 | xs *es_title_enc = encode_html(xs_dict_get(msg, "content")); | ||
| 1911 | xs *es_title = xs_replace(es_title_enc, "<br>", "\n"); | ||
| 1905 | xs *title = xs_str_new(NULL); | 1912 | xs *title = xs_str_new(NULL); |
| 1906 | int i; | 1913 | int i; |
| 1907 | 1914 | ||
| 1908 | for (i = 0; content[i] && content[i] != '<' && content[i] != '&' && i < 40; i++) | 1915 | for (i = 0; es_title[i] && es_title[i] != '\n' && i < 50; i++) |
| 1909 | title = xs_append_m(title, &content[i], 1); | 1916 | title = xs_append_m(title, &es_title[i], 1); |
| 1910 | 1917 | ||
| 1911 | xs *es11 = encode_html(title); | ||
| 1912 | xs *es12 = encode_html(content); | ||
| 1913 | xs *s = xs_fmt( | 1918 | xs *s = xs_fmt( |
| 1914 | "<item>\n" | 1919 | "<item>\n" |
| 1915 | "<title>%s...</title>\n" | 1920 | "<title>%s...</title>\n" |
| 1916 | "<link>%s</link>\n" | 1921 | "<link>%s</link>\n" |
| 1917 | "<description>%s</description>\n" | 1922 | "<description>%s</description>\n" |
| 1918 | "</item>\n", | 1923 | "</item>\n", |
| 1919 | es11, id, es12 | 1924 | title, id, content |
| 1920 | ); | 1925 | ); |
| 1921 | 1926 | ||
| 1922 | rss = xs_str_cat(rss, s); | 1927 | rss = xs_str_cat(rss, s); |