commit 67b21a9

default  ·  2023-05-24 10:12:06 +0000 UTC
parent 0d8a040
Show HTML form code for oneOf polls.
1 files changed,  +23, -0
M html.c
M html.c
+23, -0
 1@@ -919,6 +919,29 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
 2             }
 3             else {
 4                 /* poll still active */
 5+                xs *s1 = xs_fmt("<form method=\"post\" action=\"%s/admin/vote\">\n"
 6+                                "<input type=\"hidden\" name=\"irt\" value=\"%s\">\n",
 7+                    snac->actor, id);
 8+
 9+                while (xs_list_iter(&p, &v)) {
10+                    const char *name = xs_dict_get(v, "name");
11+
12+                    if (name) {
13+                        /* FIXME: process anyOf (checkbox) correctly */
14+                        xs *opt = xs_fmt("<input type=\"radio\""
15+                                    " id=\"%s\" value=\"%s\" name=\"question\"> %s<br>\n",
16+                                    name, name, name);
17+
18+                        s1 = xs_str_cat(s1, opt);
19+                    }
20+                }
21+
22+                xs *s2 = xs_fmt("<p><input type=\"submit\" "
23+                                "class=\"button\" value=\"%s\">\n</form>\n\n", L("Vote"));
24+
25+                s1 = xs_str_cat(s1, s2);
26+
27+                c = xs_str_cat(c, s1);
28             }
29         }
30