From daad4ee4c3dc0a07419ce57b75f709ae8cc7545f Mon Sep 17 00:00:00 2001 From: default Date: Sun, 26 Nov 2023 19:05:00 +0100 Subject: [PATCH] Convert the 'Operations...' top control to xs_html. --- html.c | 69 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/html.c b/html.c index fe0ef9f..f6c245b 100644 --- a/html.c +++ b/html.c @@ -713,8 +713,6 @@ xs_str *html_top_controls(snac *snac, xs_str *s) /* generates the top controls */ { char *_tmpl = - "
\n" - "
\n" "
%s\n" "
\n" "
\n"; - char *_tmpl2 = - "
\n" - "
%s\n" - - "\n" /** follow **/ - "\n" - " %s\n" - "

\n" - - "

\n" /** boost **/ - "\n" - " %s\n" - "

\n" - "

\n"; - char *_tmpl3 = "
%s\n" @@ -820,9 +803,7 @@ xs_str *html_top_controls(snac *snac, xs_str *s) "\n" "
\n" - "\n" - "
\n" - "\n"; + "\n"; const char *email = "[disabled by admin]"; @@ -879,6 +860,8 @@ xs_str *html_top_controls(snac *snac, xs_str *s) metadata = xs_str_cat(metadata, kp); } + xs_str_cat(s, "
\n"); + xs *s1 = xs_fmt(_tmpl, L("New Post..."), snac->actor, @@ -900,14 +883,46 @@ xs_str *html_top_controls(snac *snac, xs_str *s) L("Post")); - xs *s2 = xs_fmt(_tmpl2, - L("Operations..."), + xs *s2 = NULL; - snac->actor, - L("Follow"), L("(by URL or user@host)"), + { + xs *ops_action = xs_fmt("%s/admin/action", snac->actor); + xs_html *ops = xs_html_tag("details", + xs_html_tag("summary", + xs_html_text(L("Operations..."))), + xs_html_tag("form", + xs_html_attr("autocomplete", "off"), + xs_html_attr("method", "post"), + xs_html_attr("action", ops_action), + xs_html_sctag("input", + xs_html_attr("type", "text"), + xs_html_attr("name", "actor"), + xs_html_attr("required", "required"), + xs_html_attr("placeholder", "bob@example.com")), + xs_html_sctag("input", + xs_html_attr("type", "submit"), + xs_html_attr("name", "action"), + xs_html_attr("value", L("Follow"))), + xs_html_text(L("(by URL or user@host)"))), + xs_html_tag("p", NULL), + xs_html_tag("form", + xs_html_attr("autocomplete", "off"), + xs_html_attr("method", "post"), + xs_html_attr("action", ops_action), + xs_html_sctag("input", + xs_html_attr("type", "text"), + xs_html_attr("name", "id"), + xs_html_attr("required", "required"), + xs_html_attr("placeholder", "https:/" "/fedi.example.com/bob/...")), + xs_html_sctag("input", + xs_html_attr("type", "submit"), + xs_html_attr("name", "action"), + xs_html_attr("value", L("Boost"))), + xs_html_text(L("(by URL)"))), + xs_html_tag("p", NULL)); - snac->actor, - L("Boost"), L("(by URL)")); + s2 = xs_html_render(ops); + } xs *s3 = xs_fmt(_tmpl3, L("User Settings..."), @@ -942,7 +957,7 @@ xs_str *html_top_controls(snac *snac, xs_str *s) L("Update user info") ); - s = xs_str_cat(s, s1, s2, s3); + s = xs_str_cat(s, s1, s2, s3, "
\n"); return s; }