commit 6821d3d
default
·
2023-11-28 17:49:39 +0000 UTC
parent 5b2f361
Fixed poll xs_html.
1 files changed,
+19,
-11
M
html.c
M
html.c
+19,
-11
1@@ -1700,6 +1700,8 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
2 xs_dict *v;
3 int closed = 0;
4
5+ xs_html *poll = xs_html_tag("div", NULL);
6+
7 if (xs_dict_get(msg, "closed"))
8 closed = 2;
9 else
10@@ -1734,14 +1736,14 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
11 }
12 }
13
14- xs *s1 = xs_html_render(poll_result);
15- c = xs_str_cat(c, s1);
16+ xs_html_add(poll,
17+ poll_result);
18 }
19 else {
20 /* poll still active */
21 xs *vote_action = xs_fmt("%s/admin/vote", user->actor);
22 xs_html *form;
23- xs_html *poll = xs_html_tag("div",
24+ xs_html *poll_form = xs_html_tag("div",
25 xs_html_attr("class", "snac-poll-form"),
26 form = xs_html_tag("form",
27 xs_html_attr("autocomplete", "off"),
28@@ -1784,18 +1786,19 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
29 xs_html_attr("class", "button"),
30 xs_html_attr("value", L("Vote"))));
31
32- xs *s1 = xs_html_render(poll);
33- c = xs_str_cat(c, s1);
34+ xs_html_add(poll,
35+ poll_form);
36 }
37
38 /* if it's *really* closed, say it */
39 if (closed == 2) {
40- xs *s1 = xs_fmt("<p>%s</p>\n", L("Closed"));
41- c = xs_str_cat(c, s1);
42+ xs_html_add(poll,
43+ xs_html_tag("p",
44+ xs_html_text(L("Closed"))));
45 }
46 else {
47 /* show when the poll closes */
48- const char *end_time = xs_dict_get(msg, "endTime");
49+ char *end_time = xs_dict_get(msg, "endTime");
50 if (!xs_is_null(end_time)) {
51 time_t t0 = time(NULL);
52 time_t t1 = xs_parse_iso_date(end_time, 0);
53@@ -1808,12 +1811,17 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
54 /* skip leading zeros */
55 for (; *p == '0' || *p == ':'; p++);
56
57- xs *es1 = encode_html(p);
58- xs *s1 = xs_fmt("<p>%s %s</p>", L("Closes in"), es1);
59- c = xs_str_cat(c, s1);
60+ xs_html_add(poll,
61+ xs_html_tag("p",
62+ xs_html_text(L("Closes in")),
63+ xs_html_text(" "),
64+ xs_html_text(p)));
65 }
66 }
67 }
68+
69+ xs *s1 = xs_html_render(poll);
70+ c = xs_str_cat(c, s1);
71 }
72
73 s = xs_str_cat(s, c);