diff options
| author | 2025-01-19 17:02:43 +0100 | |
|---|---|---|
| committer | 2025-01-19 17:02:43 +0100 | |
| commit | ba5d978bf1385647d0f696f4d4cb3e3dd1cc544d (patch) | |
| tree | 7736be51df79aed308fc8b42a8d939b73e57c403 | |
| parent | Added controls for the followed hashtags. (diff) | |
| download | penes-snac2-ba5d978bf1385647d0f696f4d4cb3e3dd1cc544d.tar.gz penes-snac2-ba5d978bf1385647d0f696f4d4cb3e3dd1cc544d.tar.xz penes-snac2-ba5d978bf1385647d0f696f4d4cb3e3dd1cc544d.zip | |
Update user config from admin/followed-hashtags.
| -rw-r--r-- | html.c | 31 |
1 files changed, 30 insertions, 1 deletions
| @@ -1374,7 +1374,7 @@ xs_html *html_top_controls(snac *snac) | |||
| 1374 | xs_html_attr("enctype", "multipart/form-data"), | 1374 | xs_html_attr("enctype", "multipart/form-data"), |
| 1375 | 1375 | ||
| 1376 | xs_html_tag("textarea", | 1376 | xs_html_tag("textarea", |
| 1377 | xs_html_attr("name", "hashtags"), | 1377 | xs_html_attr("name", "followed_hashtags"), |
| 1378 | xs_html_attr("cols", "40"), | 1378 | xs_html_attr("cols", "40"), |
| 1379 | xs_html_attr("rows", "4"), | 1379 | xs_html_attr("rows", "4"), |
| 1380 | xs_html_attr("placeholder", "#cats\n#windowfriday\n#classicalmusic"), | 1380 | xs_html_attr("placeholder", "#cats\n#windowfriday\n#classicalmusic"), |
| @@ -4390,6 +4390,35 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 4390 | 4390 | ||
| 4391 | status = HTTP_STATUS_SEE_OTHER; | 4391 | status = HTTP_STATUS_SEE_OTHER; |
| 4392 | } | 4392 | } |
| 4393 | else | ||
| 4394 | if (p_path && strcmp(p_path, "admin/followed-hashtags") == 0) { /** **/ | ||
| 4395 | const char *followed_hashtags = xs_dict_get(p_vars, "followed_hashtags"); | ||
| 4396 | |||
| 4397 | if (xs_is_string(followed_hashtags)) { | ||
| 4398 | xs *new_hashtags = xs_list_new(); | ||
| 4399 | xs *l = xs_split(followed_hashtags, "\n"); | ||
| 4400 | const char *v; | ||
| 4401 | |||
| 4402 | xs_list_foreach(l, v) { | ||
| 4403 | xs *s1 = xs_strip_i(xs_dup(v)); | ||
| 4404 | s1 = xs_replace_i(s1, " ", ""); | ||
| 4405 | |||
| 4406 | if (*s1 == '\0') | ||
| 4407 | continue; | ||
| 4408 | |||
| 4409 | xs *s2 = xs_utf8_to_lower(s1); | ||
| 4410 | if (*s2 != '#') | ||
| 4411 | s2 = xs_str_prepend_i(s2, "#"); | ||
| 4412 | |||
| 4413 | new_hashtags = xs_list_append(new_hashtags, s2); | ||
| 4414 | } | ||
| 4415 | |||
| 4416 | snac.config = xs_dict_set(snac.config, "followed_hashtags", new_hashtags); | ||
| 4417 | user_persist(&snac, 0); | ||
| 4418 | } | ||
| 4419 | |||
| 4420 | status = HTTP_STATUS_SEE_OTHER; | ||
| 4421 | } | ||
| 4393 | 4422 | ||
| 4394 | if (status == HTTP_STATUS_SEE_OTHER) { | 4423 | if (status == HTTP_STATUS_SEE_OTHER) { |
| 4395 | const char *redir = xs_dict_get(p_vars, "redir"); | 4424 | const char *redir = xs_dict_get(p_vars, "redir"); |