summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar grunfink2023-07-19 09:58:08 +0000
committerGravatar grunfink2023-07-19 09:58:08 +0000
commitb5eb51c4ab2e4b1e4de10ae74ab00684001d7eb6 (patch)
tree1188bd361d18d90457759ad8cb90080bc7e0e7d0 /html.c
parentVersion 2.38 RELEASED. (diff)
parenthtml.c: RSS: fix. (diff)
downloadsnac2-b5eb51c4ab2e4b1e4de10ae74ab00684001d7eb6.tar.gz
snac2-b5eb51c4ab2e4b1e4de10ae74ab00684001d7eb6.tar.xz
snac2-b5eb51c4ab2e4b1e4de10ae74ab00684001d7eb6.zip
Merge pull request '[Really optional PR?] html.c / UX: Give admin page more space & other...' (#71) from yonle/snac2:master into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/71
Diffstat (limited to 'html.c')
-rw-r--r--html.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/html.c b/html.c
index e4703d1..263a888 100644
--- a/html.c
+++ b/html.c
@@ -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,
@@ -1034,7 +1037,7 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
1034 1037
1035 if (n && i) { 1038 if (n && i) {
1036 char *u = xs_dict_get(i, "url"); 1039 char *u = xs_dict_get(i, "url");
1037 xs *img = xs_fmt("<img src=\"%s\" style=\"height: 1em\" " 1040 xs *img = xs_fmt("<img src=\"%s\" style=\"height: 2em; vertical-align: middle;\" "
1038 "loading=\"lazy\" title=\"%s\"/>", u, n); 1041 "loading=\"lazy\" title=\"%s\"/>", u, n);
1039 1042
1040 c = xs_replace_i(c, n, img); 1043 c = xs_replace_i(c, n, img);
@@ -1896,23 +1899,25 @@ int html_get_handler(const xs_dict *req, const char *q_path,
1896 if (!xs_startswith(id, snac.actor)) 1899 if (!xs_startswith(id, snac.actor))
1897 continue; 1900 continue;
1898 1901
1899 xs *es1 = sanitize(xs_dict_get(msg, "content")); 1902 xs *content = sanitize(xs_dict_get(msg, "content"));
1900 xs *content = encode_html(es1); 1903
1904 // We SHOULD only use sanitized one for description.
1905 // So, only encode for feed title, while the description just keep it sanitized as is.
1906 xs *es_title_enc = encode_html(xs_dict_get(msg, "content"));
1907 xs *es_title = xs_replace(es_title_enc, "<br>", "\n");
1901 xs *title = xs_str_new(NULL); 1908 xs *title = xs_str_new(NULL);
1902 int i; 1909 int i;
1903 1910
1904 for (i = 0; content[i] && content[i] != '<' && content[i] != '&' && i < 40; i++) 1911 for (i = 0; es_title[i] && es_title[i] != '\n' && i < 50; i++)
1905 title = xs_append_m(title, &content[i], 1); 1912 title = xs_append_m(title, &es_title[i], 1);
1906 1913
1907 xs *es11 = encode_html(title);
1908 xs *es12 = encode_html(content);
1909 xs *s = xs_fmt( 1914 xs *s = xs_fmt(
1910 "<item>\n" 1915 "<item>\n"
1911 "<title>%s...</title>\n" 1916 "<title>%s...</title>\n"
1912 "<link>%s</link>\n" 1917 "<link>%s</link>\n"
1913 "<description>%s</description>\n" 1918 "<description>%s</description>\n"
1914 "</item>\n", 1919 "</item>\n",
1915 es11, id, es12 1920 title, id, content
1916 ); 1921 );
1917 1922
1918 rss = xs_str_cat(rss, s); 1923 rss = xs_str_cat(rss, s);