summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar default2023-11-28 18:49:39 +0100
committerGravatar default2023-11-28 18:49:39 +0100
commit6821d3df9fb1dd6c16bafe6f137f6997a5cb0377 (patch)
tree25c73f9f156d3baf43f69f92da55eb28fb72820e /html.c
parentFixed an excessive sanitization. (diff)
downloadsnac2-6821d3df9fb1dd6c16bafe6f137f6997a5cb0377.tar.gz
snac2-6821d3df9fb1dd6c16bafe6f137f6997a5cb0377.tar.xz
snac2-6821d3df9fb1dd6c16bafe6f137f6997a5cb0377.zip
Fixed poll xs_html.
Diffstat (limited to 'html.c')
-rw-r--r--html.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/html.c b/html.c
index 555e7bd..3461bfa 100644
--- a/html.c
+++ b/html.c
@@ -1700,6 +1700,8 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
1700 xs_dict *v; 1700 xs_dict *v;
1701 int closed = 0; 1701 int closed = 0;
1702 1702
1703 xs_html *poll = xs_html_tag("div", NULL);
1704
1703 if (xs_dict_get(msg, "closed")) 1705 if (xs_dict_get(msg, "closed"))
1704 closed = 2; 1706 closed = 2;
1705 else 1707 else
@@ -1734,14 +1736,14 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
1734 } 1736 }
1735 } 1737 }
1736 1738
1737 xs *s1 = xs_html_render(poll_result); 1739 xs_html_add(poll,
1738 c = xs_str_cat(c, s1); 1740 poll_result);
1739 } 1741 }
1740 else { 1742 else {
1741 /* poll still active */ 1743 /* poll still active */
1742 xs *vote_action = xs_fmt("%s/admin/vote", user->actor); 1744 xs *vote_action = xs_fmt("%s/admin/vote", user->actor);
1743 xs_html *form; 1745 xs_html *form;
1744 xs_html *poll = xs_html_tag("div", 1746 xs_html *poll_form = xs_html_tag("div",
1745 xs_html_attr("class", "snac-poll-form"), 1747 xs_html_attr("class", "snac-poll-form"),
1746 form = xs_html_tag("form", 1748 form = xs_html_tag("form",
1747 xs_html_attr("autocomplete", "off"), 1749 xs_html_attr("autocomplete", "off"),
@@ -1784,18 +1786,19 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
1784 xs_html_attr("class", "button"), 1786 xs_html_attr("class", "button"),
1785 xs_html_attr("value", L("Vote")))); 1787 xs_html_attr("value", L("Vote"))));
1786 1788
1787 xs *s1 = xs_html_render(poll); 1789 xs_html_add(poll,
1788 c = xs_str_cat(c, s1); 1790 poll_form);
1789 } 1791 }
1790 1792
1791 /* if it's *really* closed, say it */ 1793 /* if it's *really* closed, say it */
1792 if (closed == 2) { 1794 if (closed == 2) {
1793 xs *s1 = xs_fmt("<p>%s</p>\n", L("Closed")); 1795 xs_html_add(poll,
1794 c = xs_str_cat(c, s1); 1796 xs_html_tag("p",
1797 xs_html_text(L("Closed"))));
1795 } 1798 }
1796 else { 1799 else {
1797 /* show when the poll closes */ 1800 /* show when the poll closes */
1798 const char *end_time = xs_dict_get(msg, "endTime"); 1801 char *end_time = xs_dict_get(msg, "endTime");
1799 if (!xs_is_null(end_time)) { 1802 if (!xs_is_null(end_time)) {
1800 time_t t0 = time(NULL); 1803 time_t t0 = time(NULL);
1801 time_t t1 = xs_parse_iso_date(end_time, 0); 1804 time_t t1 = xs_parse_iso_date(end_time, 0);
@@ -1808,12 +1811,17 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
1808 /* skip leading zeros */ 1811 /* skip leading zeros */
1809 for (; *p == '0' || *p == ':'; p++); 1812 for (; *p == '0' || *p == ':'; p++);
1810 1813
1811 xs *es1 = encode_html(p); 1814 xs_html_add(poll,
1812 xs *s1 = xs_fmt("<p>%s %s</p>", L("Closes in"), es1); 1815 xs_html_tag("p",
1813 c = xs_str_cat(c, s1); 1816 xs_html_text(L("Closes in")),
1817 xs_html_text(" "),
1818 xs_html_text(p)));
1814 } 1819 }
1815 } 1820 }
1816 } 1821 }
1822
1823 xs *s1 = xs_html_render(poll);
1824 c = xs_str_cat(c, s1);
1817 } 1825 }
1818 1826
1819 s = xs_str_cat(s, c); 1827 s = xs_str_cat(s, c);