commit daad4ee
default
·
2023-11-26 18:05:00 +0000 UTC
parent 1d7619a
Convert the 'Operations...' top control to xs_html.
1 files changed,
+42,
-27
M
html.c
M
html.c
+42,
-27
1@@ -713,8 +713,6 @@ xs_str *html_top_controls(snac *snac, xs_str *s)
2 /* generates the top controls */
3 {
4 char *_tmpl =
5- "<div class=\"snac-top-controls\">\n"
6-
7 "<div class=\"snac-note\">\n"
8 "<details><summary>%s</summary>\n"
9 "<form autocomplete=\"off\" method=\"post\" "
10@@ -752,21 +750,6 @@ xs_str *html_top_controls(snac *snac, xs_str *s)
11 "</details>\n"
12 "</div>\n";
13
14- char *_tmpl2 =
15- "<div class=\"snac-top-controls-more\">\n"
16- "<details><summary>%s</summary>\n"
17-
18- "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n" /** follow **/
19- "<input type=\"text\" name=\"actor\" required=\"required\" placeholder=\"bob@example.com\">\n"
20- "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n"
21- "</form><p>\n"
22-
23- "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n" /** boost **/
24- "<input type=\"text\" name=\"id\" required=\"required\" placeholder=\"https://fedi.example.com/bob/...\">\n"
25- "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n"
26- "</form><p>\n"
27- "</details>\n";
28-
29 char *_tmpl3 =
30 "<details><summary>%s</summary>\n"
31
32@@ -820,9 +803,7 @@ xs_str *html_top_controls(snac *snac, xs_str *s)
33 "</form>\n"
34
35 "</div>\n"
36- "</details>\n"
37- "</div>\n"
38- "</div>\n";
39+ "</details>\n";
40
41 const char *email = "[disabled by admin]";
42
43@@ -879,6 +860,8 @@ xs_str *html_top_controls(snac *snac, xs_str *s)
44 metadata = xs_str_cat(metadata, kp);
45 }
46
47+ xs_str_cat(s, "<div class=\"snac-top-controls\">\n");
48+
49 xs *s1 = xs_fmt(_tmpl,
50 L("New Post..."),
51 snac->actor,
52@@ -900,14 +883,46 @@ xs_str *html_top_controls(snac *snac, xs_str *s)
53
54 L("Post"));
55
56- xs *s2 = xs_fmt(_tmpl2,
57- L("Operations..."),
58+ xs *s2 = NULL;
59
60- snac->actor,
61- L("Follow"), L("(by URL or user@host)"),
62+ {
63+ xs *ops_action = xs_fmt("%s/admin/action", snac->actor);
64+ xs_html *ops = xs_html_tag("details",
65+ xs_html_tag("summary",
66+ xs_html_text(L("Operations..."))),
67+ xs_html_tag("form",
68+ xs_html_attr("autocomplete", "off"),
69+ xs_html_attr("method", "post"),
70+ xs_html_attr("action", ops_action),
71+ xs_html_sctag("input",
72+ xs_html_attr("type", "text"),
73+ xs_html_attr("name", "actor"),
74+ xs_html_attr("required", "required"),
75+ xs_html_attr("placeholder", "bob@example.com")),
76+ xs_html_sctag("input",
77+ xs_html_attr("type", "submit"),
78+ xs_html_attr("name", "action"),
79+ xs_html_attr("value", L("Follow"))),
80+ xs_html_text(L("(by URL or user@host)"))),
81+ xs_html_tag("p", NULL),
82+ xs_html_tag("form",
83+ xs_html_attr("autocomplete", "off"),
84+ xs_html_attr("method", "post"),
85+ xs_html_attr("action", ops_action),
86+ xs_html_sctag("input",
87+ xs_html_attr("type", "text"),
88+ xs_html_attr("name", "id"),
89+ xs_html_attr("required", "required"),
90+ xs_html_attr("placeholder", "https:/" "/fedi.example.com/bob/...")),
91+ xs_html_sctag("input",
92+ xs_html_attr("type", "submit"),
93+ xs_html_attr("name", "action"),
94+ xs_html_attr("value", L("Boost"))),
95+ xs_html_text(L("(by URL)"))),
96+ xs_html_tag("p", NULL));
97
98- snac->actor,
99- L("Boost"), L("(by URL)"));
100+ s2 = xs_html_render(ops);
101+ }
102
103 xs *s3 = xs_fmt(_tmpl3,
104 L("User Settings..."),
105@@ -942,7 +957,7 @@ xs_str *html_top_controls(snac *snac, xs_str *s)
106 L("Update user info")
107 );
108
109- s = xs_str_cat(s, s1, s2, s3);
110+ s = xs_str_cat(s, s1, s2, s3, "</div><!-- snac-top-controls -->\n");
111
112 return s;
113 }