commit 009a1da

default  ·  2023-11-20 20:46:22 +0000 UTC
parent 4e01a3b
Refactored part of html_people_list() using xs_html.
1 files changed,  +44, -20
M html.c
M html.c
+44, -20
 1@@ -1781,26 +1781,50 @@ xs_str *html_people_list(snac *snac, xs_str *os, xs_list *list, const char *head
 2             s = xs_str_cat(s, "</form>\n");
 3 
 4             /* the post textarea */
 5-            xs *s2 = xs_fmt(
 6-                "<p><details><summary>%s</summary>\n"
 7-                "<p><div class=\"snac-note\" id=\"%s_%s_dm\">\n"
 8-                "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/note\" "
 9-                "enctype=\"multipart/form-data\" id=\"%s_reply_form\">\n"
10-                "<textarea class=\"snac-textarea\" name=\"content\" "
11-                "rows=\"4\" wrap=\"virtual\" required=\"required\"></textarea>\n"
12-                "<input type=\"hidden\" name=\"to\" value=\"%s\">\n"
13-                "<p><input type=\"file\" name=\"attach\">\n"
14-                "<p><input type=\"submit\" class=\"button\" value=\"%s\">\n"
15-                "</form><p></div>\n"
16-                "</details><p>\n",
17-
18-                L("Direct Message..."),
19-                md5, t,
20-                snac->actor, md5,
21-                actor_id,
22-                L("Post")
23-            );
24-            s = xs_str_cat(s, s2);
25+            xs *dm_form_id  = xs_fmt("%s_%s_dm", md5, t);
26+            xs *dm_action   = xs_fmt("%s/admin/note", snac->actor);
27+            xs *dm_form_id2 = xs_fmt("%s_reply_form", md5);
28+
29+            xs_html *dm_textarea = xs_html_tag("div",
30+                xs_html_tag("details",
31+                    xs_html_tag("summary",
32+                        xs_html_text(L("Direct Message..."))),
33+                    xs_html_sctag("p", NULL),
34+                    xs_html_tag("div",
35+                        xs_html_attr("class", "snac-note"),
36+                        xs_html_attr("id",    dm_form_id),
37+                        xs_html_tag("form",
38+                            xs_html_attr("autocomplete", "off"),
39+                            xs_html_attr("method",       "post"),
40+                            xs_html_attr("action",       dm_action),
41+                            xs_html_attr("enctype",      "multipart/form-data"),
42+                            xs_html_attr("id",           dm_form_id2),
43+                            xs_html_tag("textarea",
44+                                xs_html_attr("class",    "snac-textarea"),
45+                                xs_html_attr("name",     "content"),
46+                                xs_html_attr("rows",     "4"),
47+                                xs_html_attr("wrap",     "virtual"),
48+                                xs_html_attr("required", "required")),
49+                            xs_html_sctag("input",
50+                                xs_html_attr("type",     "hidden"),
51+                                xs_html_attr("name",     "to"),
52+                                xs_html_attr("value",    actor_id)),
53+                            xs_html_sctag("p", NULL),
54+                            xs_html_sctag("input",
55+                                xs_html_attr("type",     "file"),
56+                                xs_html_attr("name",     "attach")),
57+                            xs_html_sctag("p", NULL),
58+                            xs_html_sctag("input",
59+                                xs_html_attr("type",     "submit"),
60+                                xs_html_attr("class",    "button"),
61+                                xs_html_attr("value",    L("Post")))),
62+                        xs_html_sctag("p", NULL))),
63+                xs_html_sctag("p", NULL));
64+
65+            {
66+                xs *s1 = xs_html_render(dm_textarea);
67+                s = xs_str_cat(s, s1);
68+            }
69 
70             s = xs_str_cat(s, "</div>\n");
71