summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/html.c b/html.c
index c3a2efe..2274f74 100644
--- a/html.c
+++ b/html.c
@@ -786,6 +786,24 @@ static xs_html *html_user_body(snac *user, int read_only)
786 xs_html_attr("class", "snac-top-user-id"), 786 xs_html_attr("class", "snac-top-user-id"),
787 xs_html_text(handle))); 787 xs_html_text(handle)));
788 788
789 /** instance announcement **/
790
791 double la = 0.0;
792 xs *user_la = xs_dup(xs_dict_get(user->config, "last_announcement"));
793 if (user_la != NULL)
794 la = xs_number_get(user_la);
795
796 const t_announcement *an = announcement(la);
797 if (an != NULL && (an->text != NULL)) {
798 xs_html_add(top_user, xs_html_tag("div",
799 xs_html_attr("class", "snac-announcement"),
800 xs_html_text(an->text),
801 xs_html_text(" "),
802 xs_html_sctag("a",
803 xs_html_attr("href", xs_dup(xs_fmt("?da=%.0f", an->timestamp)))),
804 xs_html_text("Dismiss")));
805 }
806
789 if (read_only) { 807 if (read_only) {
790 xs *es1 = encode_html(xs_dict_get(user->config, "bio")); 808 xs *es1 = encode_html(xs_dict_get(user->config, "bio"));
791 xs *bio1 = not_really_markdown(es1, NULL, NULL); 809 xs *bio1 = not_really_markdown(es1, NULL, NULL);
@@ -2606,6 +2624,16 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2606 skip = atoi(v), cache = 0, save = 0; 2624 skip = atoi(v), cache = 0, save = 0;
2607 if ((v = xs_dict_get(q_vars, "show")) != NULL) 2625 if ((v = xs_dict_get(q_vars, "show")) != NULL)
2608 show = atoi(v), cache = 0, save = 0; 2626 show = atoi(v), cache = 0, save = 0;
2627 if ((v = xs_dict_get(q_vars, "da")) != NULL) {
2628 /* user dismissed an announcement */
2629 if (login(&snac, req)) {
2630 double ts = atof(v);
2631 xs *timestamp = xs_number_new(ts);
2632 srv_log(xs_fmt("user dismissed announcements until %d", ts));
2633 snac.config = xs_dict_set(snac.config, "last_announcement", timestamp);
2634 user_persist(&snac);
2635 }
2636 }
2609 2637
2610 if (p_path == NULL) { /** public timeline **/ 2638 if (p_path == NULL) { /** public timeline **/
2611 xs *h = xs_str_localtime(0, "%Y-%m.html"); 2639 xs *h = xs_str_localtime(0, "%Y-%m.html");