diff options
| author | 2022-12-02 09:55:25 +0100 | |
|---|---|---|
| committer | 2022-12-04 10:05:53 +0100 | |
| commit | e4c26715a138862b17bb23562be28e6ea4d949f9 (patch) | |
| tree | 0cd6e7d50d42fce8c37af64e876307ebff778c3e | |
| parent | Updated TODO. (diff) | |
| download | snac2-e4c26715a138862b17bb23562be28e6ea4d949f9.tar.gz snac2-e4c26715a138862b17bb23562be28e6ea4d949f9.tar.xz snac2-e4c26715a138862b17bb23562be28e6ea4d949f9.zip | |
Add an option to always show sensitive content
- add a cw key to user.json
- add a cw checkbox to user setup form
- handle the cw parameter when updating user setup
- when rendering an entry, look at the cw config: if set, use a h3
heading for the summary; otherwise use details + summar + SENSITIVE
CONTENT like before
| -rw-r--r-- | html.c | 28 | ||||
| -rw-r--r-- | utils.c | 1 |
2 files changed, 23 insertions, 6 deletions
| @@ -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,11 +618,17 @@ 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 | char *cw = xs_dict_get(snac->config, "cw"); | |
| 617 | xs *s1 = xs_fmt("<details><summary>%s [%s]</summary>\n", v, L("SENSITIVE CONTENT")); | 622 | if (xs_is_null(cw)) |
| 618 | s = xs_str_cat(s, s1); | 623 | cw = ""; |
| 619 | 624 | if (strcmp(cw, "checked") == 0) { | |
| 620 | sensitive = 1; | 625 | xs *s1 = xs_fmt("<h3>%s</h3>", v); |
| 626 | s = xs_str_cat(s, s1); | ||
| 627 | } else { | ||
| 628 | xs *s1 = xs_fmt("<details><summary>%s [%s]</summary>\n", v, L("SENSITIVE CONTENT")); | ||
| 629 | s = xs_str_cat(s, s1); | ||
| 630 | sensitive = 1; | ||
| 631 | } | ||
| 621 | } | 632 | } |
| 622 | 633 | ||
| 623 | #if 0 | 634 | #if 0 |
| @@ -1379,6 +1390,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); | 1390 | snac.config = xs_dict_set(snac.config, "avatar", v); |
| 1380 | if ((v = xs_dict_get(p_vars, "bio")) != NULL) | 1391 | if ((v = xs_dict_get(p_vars, "bio")) != NULL) |
| 1381 | snac.config = xs_dict_set(snac.config, "bio", v); | 1392 | snac.config = xs_dict_set(snac.config, "bio", v); |
| 1393 | if ((v = xs_dict_get(p_vars, "cw")) != NULL && | ||
| 1394 | strcmp(v, "on") == 0) { | ||
| 1395 | snac.config = xs_dict_set(snac.config, "cw", "checked"); | ||
| 1396 | } else { /* if the checkbox is not set, the parameter is missing */ | ||
| 1397 | snac.config = xs_dict_set(snac.config, "cw", ""); | ||
| 1398 | } | ||
| 1382 | if ((v = xs_dict_get(p_vars, "email")) != NULL) | 1399 | if ((v = xs_dict_get(p_vars, "email")) != NULL) |
| 1383 | snac.config = xs_dict_set(snac.config, "email", v); | 1400 | snac.config = xs_dict_set(snac.config, "email", v); |
| 1384 | 1401 | ||
| @@ -1428,4 +1445,3 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, | |||
| 1428 | 1445 | ||
| 1429 | return status; | 1446 | return status; |
| 1430 | } | 1447 | } |
| 1431 | |||
| @@ -226,6 +226,7 @@ int adduser(char *uid) | |||
| 226 | config = xs_dict_append(config, "name", uid); | 226 | config = xs_dict_append(config, "name", uid); |
| 227 | config = xs_dict_append(config, "avatar", ""); | 227 | config = xs_dict_append(config, "avatar", ""); |
| 228 | config = xs_dict_append(config, "bio", ""); | 228 | config = xs_dict_append(config, "bio", ""); |
| 229 | config = xs_dict_append(config, "cw", ""); | ||
| 229 | config = xs_dict_append(config, "published", date); | 230 | config = xs_dict_append(config, "published", date); |
| 230 | config = xs_dict_append(config, "passwd", pwd_f); | 231 | config = xs_dict_append(config, "passwd", pwd_f); |
| 231 | 232 | ||