mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 22:45:05 +00:00
Fixed poll xs_html.
This commit is contained in:
parent
5b2f361b33
commit
6821d3df9f
1 changed files with 19 additions and 11 deletions
34
html.c
34
html.c
|
@ -1700,6 +1700,8 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
|
||||||
xs_dict *v;
|
xs_dict *v;
|
||||||
int closed = 0;
|
int closed = 0;
|
||||||
|
|
||||||
|
xs_html *poll = xs_html_tag("div", NULL);
|
||||||
|
|
||||||
if (xs_dict_get(msg, "closed"))
|
if (xs_dict_get(msg, "closed"))
|
||||||
closed = 2;
|
closed = 2;
|
||||||
else
|
else
|
||||||
|
@ -1734,14 +1736,14 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xs *s1 = xs_html_render(poll_result);
|
xs_html_add(poll,
|
||||||
c = xs_str_cat(c, s1);
|
poll_result);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* poll still active */
|
/* poll still active */
|
||||||
xs *vote_action = xs_fmt("%s/admin/vote", user->actor);
|
xs *vote_action = xs_fmt("%s/admin/vote", user->actor);
|
||||||
xs_html *form;
|
xs_html *form;
|
||||||
xs_html *poll = xs_html_tag("div",
|
xs_html *poll_form = xs_html_tag("div",
|
||||||
xs_html_attr("class", "snac-poll-form"),
|
xs_html_attr("class", "snac-poll-form"),
|
||||||
form = xs_html_tag("form",
|
form = xs_html_tag("form",
|
||||||
xs_html_attr("autocomplete", "off"),
|
xs_html_attr("autocomplete", "off"),
|
||||||
|
@ -1784,18 +1786,19 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
|
||||||
xs_html_attr("class", "button"),
|
xs_html_attr("class", "button"),
|
||||||
xs_html_attr("value", L("Vote"))));
|
xs_html_attr("value", L("Vote"))));
|
||||||
|
|
||||||
xs *s1 = xs_html_render(poll);
|
xs_html_add(poll,
|
||||||
c = xs_str_cat(c, s1);
|
poll_form);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if it's *really* closed, say it */
|
/* if it's *really* closed, say it */
|
||||||
if (closed == 2) {
|
if (closed == 2) {
|
||||||
xs *s1 = xs_fmt("<p>%s</p>\n", L("Closed"));
|
xs_html_add(poll,
|
||||||
c = xs_str_cat(c, s1);
|
xs_html_tag("p",
|
||||||
|
xs_html_text(L("Closed"))));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* show when the poll closes */
|
/* show when the poll closes */
|
||||||
const char *end_time = xs_dict_get(msg, "endTime");
|
char *end_time = xs_dict_get(msg, "endTime");
|
||||||
if (!xs_is_null(end_time)) {
|
if (!xs_is_null(end_time)) {
|
||||||
time_t t0 = time(NULL);
|
time_t t0 = time(NULL);
|
||||||
time_t t1 = xs_parse_iso_date(end_time, 0);
|
time_t t1 = xs_parse_iso_date(end_time, 0);
|
||||||
|
@ -1808,13 +1811,18 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
|
||||||
/* skip leading zeros */
|
/* skip leading zeros */
|
||||||
for (; *p == '0' || *p == ':'; p++);
|
for (; *p == '0' || *p == ':'; p++);
|
||||||
|
|
||||||
xs *es1 = encode_html(p);
|
xs_html_add(poll,
|
||||||
xs *s1 = xs_fmt("<p>%s %s</p>", L("Closes in"), es1);
|
xs_html_tag("p",
|
||||||
|
xs_html_text(L("Closes in")),
|
||||||
|
xs_html_text(" "),
|
||||||
|
xs_html_text(p)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xs *s1 = xs_html_render(poll);
|
||||||
c = xs_str_cat(c, s1);
|
c = xs_str_cat(c, s1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
s = xs_str_cat(s, c);
|
s = xs_str_cat(s, c);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue