commit b5eb51c

grunfink  ·  2023-07-19 09:58:08 +0000 UTC
parents e6d5ce2, 7e273a7
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
1 files changed,  +16, -11
M html.c
M html.c
+16, -11
 1@@ -66,7 +66,7 @@ xs_str *actor_name(xs_dict *actor)
 2 
 3                 if (n && i) {
 4                     char *u = xs_dict_get(i, "url");
 5-                    xs *img = xs_fmt("<img src=\"%s\" style=\"height: 1em\" loading=\"lazy\"/>", u);
 6+                    xs *img = xs_fmt("<img src=\"%s\" style=\"height: 1em; vertical-align: middle;\" loading=\"lazy\"/>", u);
 7 
 8                     name = xs_replace_i(name, n, img);
 9                 }
10@@ -392,6 +392,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
11         "<div class=\"snac-top-controls\">\n"
12 
13         "<div class=\"snac-note\">\n"
14+        "<details><summary>%s</summary>\n"
15         "<form autocomplete=\"off\" method=\"post\" "
16         "action=\"%s/admin/note\" enctype=\"multipart/form-data\">\n"
17         "<textarea class=\"snac-textarea\" name=\"content\" "
18@@ -425,6 +426,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
19         "<p><input type=\"submit\" class=\"button\" value=\"%s\">\n"
20         "</form><p>\n"
21         "</div>\n"
22+        "</details>\n"
23 
24         "<div class=\"snac-top-controls-more\">\n"
25         "<details><summary>%s</summary>\n"
26@@ -528,6 +530,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
27     xs *es6 = encode_html(purge_days);
28 
29     xs *s1 = xs_fmt(_tmpl,
30+        L("New Post..."),
31         snac->actor,
32         L("Sensitive content"),
33         L("Sensitive content description"),
34@@ -547,7 +550,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
35 
36         L("Post"),
37 
38-        L("More options..."),
39+        L("Preferences..."),
40 
41         snac->actor,
42         L("Follow"), L("(by URL or user@host)"),
43@@ -555,7 +558,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
44         snac->actor,
45         L("Boost"), L("(by URL)"),
46 
47-        L("User settings...."),
48+        L("User Settings"),
49         snac->actor,
50         L("Display name"),
51         es1,
52@@ -1034,7 +1037,7 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
53 
54                     if (n && i) {
55                         char *u = xs_dict_get(i, "url");
56-                        xs *img = xs_fmt("<img src=\"%s\" style=\"height: 1em\" "
57+                        xs *img = xs_fmt("<img src=\"%s\" style=\"height: 2em; vertical-align: middle;\" "
58                                          "loading=\"lazy\" title=\"%s\"/>", u, n);
59 
60                         c = xs_replace_i(c, n, img);
61@@ -1896,23 +1899,25 @@ int html_get_handler(const xs_dict *req, const char *q_path,
62             if (!xs_startswith(id, snac.actor))
63                 continue;
64 
65-            xs *es1     = sanitize(xs_dict_get(msg, "content"));
66-            xs *content = encode_html(es1);
67+            xs *content = sanitize(xs_dict_get(msg, "content"));
68+
69+            // We SHOULD only use sanitized one for description.
70+            // So, only encode for feed title, while the description just keep it sanitized as is.
71+            xs *es_title_enc = encode_html(xs_dict_get(msg, "content"));
72+            xs *es_title = xs_replace(es_title_enc, "<br>", "\n");
73             xs *title   = xs_str_new(NULL);
74             int i;
75 
76-            for (i = 0; content[i] && content[i] != '<' && content[i] != '&' && i < 40; i++)
77-                title = xs_append_m(title, &content[i], 1);
78+            for (i = 0; es_title[i] && es_title[i] != '\n' && i < 50; i++)
79+                title = xs_append_m(title, &es_title[i], 1);
80 
81-            xs *es11 = encode_html(title);
82-            xs *es12 = encode_html(content);
83             xs *s = xs_fmt(
84                 "<item>\n"
85                 "<title>%s...</title>\n"
86                 "<link>%s</link>\n"
87                 "<description>%s</description>\n"
88                 "</item>\n",
89-                es11, id, es12
90+                title, id, content
91             );
92 
93             rss = xs_str_cat(rss, s);