summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-07-24 13:31:13 +0200
committerGravatar default2023-07-24 13:31:13 +0200
commitf67ac2517c1b72e56dedf195070bde226d64f0a6 (patch)
tree7109b93ee6d2086246e11f4975252e2113eda865
parentUpdated documentation. (diff)
downloadsnac2-f67ac2517c1b72e56dedf195070bde226d64f0a6.tar.gz
snac2-f67ac2517c1b72e56dedf195070bde226d64f0a6.tar.xz
snac2-f67ac2517c1b72e56dedf195070bde226d64f0a6.zip
Moved user settings to its own page.
-rw-r--r--html.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/html.c b/html.c
index ab23032..5543a2d 100644
--- a/html.c
+++ b/html.c
@@ -343,11 +343,15 @@ d_char *html_user_header(snac *snac, d_char *s, int local)
343 "<a href=\"%s\">%s</a> - " 343 "<a href=\"%s\">%s</a> - "
344 "<a href=\"%s/admin\">%s</a> - " 344 "<a href=\"%s/admin\">%s</a> - "
345 "<a href=\"%s/notifications\">%s</a>%s - " 345 "<a href=\"%s/notifications\">%s</a>%s - "
346 "<a href=\"%s/people\">%s</a></nav>\n", 346 "<a href=\"%s/people\">%s</a> - "
347 "<a href=\"%s/settings\">%s</a>"
348 "</nav>\n",
347 snac->actor, L("public"), 349 snac->actor, L("public"),
348 snac->actor, L("private"), 350 snac->actor, L("private"),
349 snac->actor, L("notifications"), n_str, 351 snac->actor, L("notifications"), n_str,
350 snac->actor, L("people")); 352 snac->actor, L("people"),
353 snac->actor, L("settings")
354 );
351 } 355 }
352 356
353 s = xs_str_cat(s, s1); 357 s = xs_str_cat(s, s1);
@@ -385,13 +389,13 @@ d_char *html_user_header(snac *snac, d_char *s, int local)
385} 389}
386 390
387 391
388d_char *html_top_controls(snac *snac, d_char *s) 392xs_str *html_top_controls(snac *snac, xs_str *s, int settings)
389/* generates the top controls */ 393/* generates the top controls */
390{ 394{
391 char *_tmpl = 395 char *_tmpl =
392 "<div class=\"snac-top-controls\">\n" 396 "<div class=\"snac-top-controls\">\n"
393 397
394 "<div class=\"snac-note\">\n" 398 "<div class=\"snac-note\" %s>\n"
395 "<details><summary>%s</summary>\n" 399 "<details><summary>%s</summary>\n"
396 "<form autocomplete=\"off\" method=\"post\" " 400 "<form autocomplete=\"off\" method=\"post\" "
397 "action=\"%s/admin/note\" enctype=\"multipart/form-data\">\n" 401 "action=\"%s/admin/note\" enctype=\"multipart/form-data\">\n"
@@ -428,8 +432,8 @@ d_char *html_top_controls(snac *snac, d_char *s)
428 "</div>\n" 432 "</div>\n"
429 "</details>\n" 433 "</details>\n"
430 434
431 "<div class=\"snac-top-controls-more\">\n" 435 "<div class=\"snac-top-controls-more\" %s>\n"
432 "<details><summary>%s</summary>\n" 436 "<p><details><summary>%s</summary>\n"
433 437
434 "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n" /** follow **/ 438 "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n" /** follow **/
435 "<input type=\"text\" name=\"actor\" required=\"required\" placeholder=\"bob@example.com\">\n" 439 "<input type=\"text\" name=\"actor\" required=\"required\" placeholder=\"bob@example.com\">\n"
@@ -440,8 +444,12 @@ d_char *html_top_controls(snac *snac, d_char *s)
440 "<input type=\"text\" name=\"id\" required=\"required\" placeholder=\"https://fedi.example.com/bob/....\">\n" 444 "<input type=\"text\" name=\"id\" required=\"required\" placeholder=\"https://fedi.example.com/bob/....\">\n"
441 "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n" 445 "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n"
442 "</form><p>\n" 446 "</form><p>\n"
447 "</details>\n"
448 "</div>\n"
443 449
444 "<details><summary>%s</summary>\n" 450 "<div class=\"snac-user-settings\" %s>\n"
451
452 "<h2 class=\"snac-header\">%s</h2>\n"
445 453
446 "<div class=\"snac-user-setup\">\n" /** user setup **/ 454 "<div class=\"snac-user-setup\">\n" /** user setup **/
447 "<form autocomplete=\"off\" method=\"post\" " 455 "<form autocomplete=\"off\" method=\"post\" "
@@ -483,8 +491,6 @@ d_char *html_top_controls(snac *snac, d_char *s)
483 "</form>\n" 491 "</form>\n"
484 492
485 "</div>\n" 493 "</div>\n"
486 "</details>\n"
487 "</details>\n"
488 "</div>\n" 494 "</div>\n"
489 "</div>\n"; 495 "</div>\n";
490 496
@@ -530,6 +536,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
530 xs *es6 = encode_html(purge_days); 536 xs *es6 = encode_html(purge_days);
531 537
532 xs *s1 = xs_fmt(_tmpl, 538 xs *s1 = xs_fmt(_tmpl,
539 settings ? "style=\"display: none\"" : "",
533 L("New Post..."), 540 L("New Post..."),
534 snac->actor, 541 snac->actor,
535 L("Sensitive content"), 542 L("Sensitive content"),
@@ -550,7 +557,8 @@ d_char *html_top_controls(snac *snac, d_char *s)
550 557
551 L("Post"), 558 L("Post"),
552 559
553 L("Preferences..."), 560 settings ? "style=\"display: none\"" : "",
561 L("Operations..."),
554 562
555 snac->actor, 563 snac->actor,
556 L("Follow"), L("(by URL or user@host)"), 564 L("Follow"), L("(by URL or user@host)"),
@@ -558,6 +566,8 @@ d_char *html_top_controls(snac *snac, d_char *s)
558 snac->actor, 566 snac->actor,
559 L("Boost"), L("(by URL)"), 567 L("Boost"), L("(by URL)"),
560 568
569 !settings ? "style=\"display: none\"" : "",
570
561 L("User Settings"), 571 L("User Settings"),
562 snac->actor, 572 snac->actor,
563 L("Display name"), 573 L("Display name"),
@@ -1376,7 +1386,7 @@ xs_str *html_timeline(snac *snac, const xs_list *list, int local, int skip, int
1376 s = html_user_header(snac, s, local); 1386 s = html_user_header(snac, s, local);
1377 1387
1378 if (!local) 1388 if (!local)
1379 s = html_top_controls(snac, s); 1389 s = html_top_controls(snac, s, list == NULL ? 1 : 0);
1380 1390
1381 s = xs_str_cat(s, "<a name=\"snac-posts\"></a>\n"); 1391 s = xs_str_cat(s, "<a name=\"snac-posts\"></a>\n");
1382 s = xs_str_cat(s, "<div class=\"snac-posts\">\n"); 1392 s = xs_str_cat(s, "<div class=\"snac-posts\">\n");
@@ -1813,6 +1823,18 @@ int html_get_handler(const xs_dict *req, const char *q_path,
1813 } 1823 }
1814 } 1824 }
1815 else 1825 else
1826 if (strcmp(p_path, "settings") == 0) { /** user settings **/
1827 if (!login(&snac, req)) {
1828 *body = xs_dup(uid);
1829 status = 401;
1830 }
1831 else {
1832 *body = html_timeline(&snac, NULL, 0, 0, 0, 0);
1833 *b_size = strlen(*body);
1834 status = 200;
1835 }
1836 }
1837 else
1816 if (strcmp(p_path, "notifications") == 0) { /** the list of notifications **/ 1838 if (strcmp(p_path, "notifications") == 0) { /** the list of notifications **/
1817 if (!login(&snac, req)) { 1839 if (!login(&snac, req)) {
1818 *body = xs_dup(uid); 1840 *body = xs_dup(uid);