summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/html.c b/html.c
index 6573630..92a81cc 100644
--- a/html.c
+++ b/html.c
@@ -1514,6 +1514,38 @@ xs_html *html_top_controls(snac *user)
1514 xs_html_attr("class", "button"), 1514 xs_html_attr("class", "button"),
1515 xs_html_attr("value", L("Update hashtags"))))))); 1515 xs_html_attr("value", L("Update hashtags")))))));
1516 1516
1517 xs *blocked_hashtags_action = xs_fmt("%s/admin/blocked-hashtags", user->actor);
1518 xs *blocked_hashtags = xs_join(xs_dict_get_def(user->config,
1519 "blocked_hashtags", xs_stock(XSTYPE_LIST)), "\n");
1520
1521 xs_html_add(top_controls,
1522 xs_html_tag("details",
1523 xs_html_tag("summary",
1524 xs_html_text(L("Blocked hashtags..."))),
1525 xs_html_tag("p",
1526 xs_html_text(L("One hashtag per line"))),
1527 xs_html_tag("div",
1528 xs_html_attr("class", "snac-blocked-hashtags"),
1529 xs_html_tag("form",
1530 xs_html_attr("autocomplete", "off"),
1531 xs_html_attr("method", "post"),
1532 xs_html_attr("action", blocked_hashtags_action),
1533 xs_html_attr("enctype", "multipart/form-data"),
1534
1535 xs_html_tag("textarea",
1536 xs_html_attr("name", "blocked_hashtags"),
1537 xs_html_attr("cols", "40"),
1538 xs_html_attr("rows", "4"),
1539 xs_html_attr("placeholder", "#cats\n#windowfriday\n#classicalmusic"),
1540 xs_html_text(blocked_hashtags)),
1541
1542 xs_html_tag("br", NULL),
1543
1544 xs_html_sctag("input",
1545 xs_html_attr("type", "submit"),
1546 xs_html_attr("class", "button"),
1547 xs_html_attr("value", L("Update hashtags")))))));
1548
1517 return top_controls; 1549 return top_controls;
1518} 1550}
1519 1551
@@ -4683,6 +4715,35 @@ int html_post_handler(const xs_dict *req, const char *q_path,
4683 4715
4684 status = HTTP_STATUS_SEE_OTHER; 4716 status = HTTP_STATUS_SEE_OTHER;
4685 } 4717 }
4718 else
4719 if (p_path && strcmp(p_path, "admin/blocked-hashtags") == 0) { /** **/
4720 const char *hashtags = xs_dict_get(p_vars, "blocked_hashtags");
4721
4722 if (xs_is_string(hashtags)) {
4723 xs *new_hashtags = xs_list_new();
4724 xs *l = xs_split(hashtags, "\n");
4725 const char *v;
4726
4727 xs_list_foreach(l, v) {
4728 xs *s1 = xs_strip_i(xs_dup(v));
4729 s1 = xs_replace_i(s1, " ", "");
4730
4731 if (*s1 == '\0')
4732 continue;
4733
4734 xs *s2 = xs_utf8_to_lower(s1);
4735 if (*s2 != '#')
4736 s2 = xs_str_prepend_i(s2, "#");
4737
4738 new_hashtags = xs_list_append(new_hashtags, s2);
4739 }
4740
4741 snac.config = xs_dict_set(snac.config, "blocked_hashtags", new_hashtags);
4742 user_persist(&snac, 0);
4743 }
4744
4745 status = HTTP_STATUS_SEE_OTHER;
4746 }
4686 4747
4687 if (status == HTTP_STATUS_SEE_OTHER) { 4748 if (status == HTTP_STATUS_SEE_OTHER) {
4688 const char *redir = xs_dict_get(p_vars, "redir"); 4749 const char *redir = xs_dict_get(p_vars, "redir");