summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar grunfink2022-12-04 10:39:32 +0000
committerGravatar grunfink2022-12-04 10:39:32 +0000
commit1c8ff95670eaf1daab526addee22e0c957fd4c18 (patch)
treeeb8bdc540e597194a380a4f19b63408967b7a615 /html.c
parentBumped version. (diff)
parentNo sensitive content in the public timeline (diff)
downloadsnac2-1c8ff95670eaf1daab526addee22e0c957fd4c18.tar.gz
snac2-1c8ff95670eaf1daab526addee22e0c957fd4c18.tar.xz
snac2-1c8ff95670eaf1daab526addee22e0c957fd4c18.zip
Merge pull request 'Add an option to always show sensitive content' (#9) from kensanata/snac2:optional-cw into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/9
Diffstat (limited to 'html.c')
-rw-r--r--html.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/html.c b/html.c
index ea7830c..fbb313b 100644
--- a/html.c
+++ b/html.c
@@ -277,6 +277,9 @@ d_char *html_top_controls(snac *snac, d_char *s)
277 "<p>%s:<br>\n" 277 "<p>%s:<br>\n"
278 "<textarea name=\"bio\" cols=\"40\" rows=\"4\">%s</textarea></p>\n" 278 "<textarea name=\"bio\" cols=\"40\" rows=\"4\">%s</textarea></p>\n"
279 279
280 "<p><input type=\"checkbox\" name=\"cw\" id=\"cw\" %s>\n"
281 "<label for=\"cw\">%s</label></p>\n"
282
280 "<p>%s:<br>\n" 283 "<p>%s:<br>\n"
281 "<input type=\"text\" name=\"email\" value=\"%s\"></p>\n" 284 "<input type=\"text\" name=\"email\" value=\"%s\"></p>\n"
282 285
@@ -320,6 +323,8 @@ d_char *html_top_controls(snac *snac, d_char *s)
320 xs_dict_get(snac->config, "avatar"), 323 xs_dict_get(snac->config, "avatar"),
321 L("Bio"), 324 L("Bio"),
322 xs_dict_get(snac->config, "bio"), 325 xs_dict_get(snac->config, "bio"),
326 xs_dict_get(snac->config, "cw"),
327 L("Always show sensitive content"),
323 L("Email address for notifications"), 328 L("Email address for notifications"),
324 email, 329 email,
325 L("Password (only to change it)"), 330 L("Password (only to change it)"),
@@ -613,10 +618,12 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int
613 if (!xs_is_null(v = xs_dict_get(msg, "sensitive")) && xs_type(v) == XSTYPE_TRUE) { 618 if (!xs_is_null(v = xs_dict_get(msg, "sensitive")) && xs_type(v) == XSTYPE_TRUE) {
614 if (xs_is_null(v = xs_dict_get(msg, "summary")) || *v == '\0') 619 if (xs_is_null(v = xs_dict_get(msg, "summary")) || *v == '\0')
615 v = "..."; 620 v = "...";
616 621 /* only show it when not in the public timeline and the config setting is "open" */
617 xs *s1 = xs_fmt("<details><summary>%s [%s]</summary>\n", v, L("SENSITIVE CONTENT")); 622 char *cw = xs_dict_get(snac->config, "cw");
623 if (xs_is_null(cw) || local)
624 cw = "";
625 xs *s1 = xs_fmt("<details %s><summary>%s [%s]</summary>\n", cw, v, L("SENSITIVE CONTENT"));
618 s = xs_str_cat(s, s1); 626 s = xs_str_cat(s, s1);
619
620 sensitive = 1; 627 sensitive = 1;
621 } 628 }
622 629
@@ -1379,6 +1386,12 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
1379 snac.config = xs_dict_set(snac.config, "avatar", v); 1386 snac.config = xs_dict_set(snac.config, "avatar", v);
1380 if ((v = xs_dict_get(p_vars, "bio")) != NULL) 1387 if ((v = xs_dict_get(p_vars, "bio")) != NULL)
1381 snac.config = xs_dict_set(snac.config, "bio", v); 1388 snac.config = xs_dict_set(snac.config, "bio", v);
1389 if ((v = xs_dict_get(p_vars, "cw")) != NULL &&
1390 strcmp(v, "on") == 0) {
1391 snac.config = xs_dict_set(snac.config, "cw", "open");
1392 } else { /* if the checkbox is not set, the parameter is missing */
1393 snac.config = xs_dict_set(snac.config, "cw", "");
1394 }
1382 if ((v = xs_dict_get(p_vars, "email")) != NULL) 1395 if ((v = xs_dict_get(p_vars, "email")) != NULL)
1383 snac.config = xs_dict_set(snac.config, "email", v); 1396 snac.config = xs_dict_set(snac.config, "email", v);
1384 1397
@@ -1428,4 +1441,3 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
1428 1441
1429 return status; 1442 return status;
1430} 1443}
1431