From f67ac2517c1b72e56dedf195070bde226d64f0a6 Mon Sep 17 00:00:00 2001 From: default Date: Mon, 24 Jul 2023 13:31:13 +0200 Subject: [PATCH] Moved user settings to its own page. --- html.c | 44 +++++++++++++++++++++++++++++++++----------- 1 file 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) "%s - " "%s - " "%s%s - " - "%s\n", + "%s - " + "%s" + "\n", snac->actor, L("public"), snac->actor, L("private"), snac->actor, L("notifications"), n_str, - snac->actor, L("people")); + snac->actor, L("people"), + snac->actor, L("settings") + ); } s = xs_str_cat(s, s1); @@ -385,13 +389,13 @@ d_char *html_user_header(snac *snac, d_char *s, int local) } -d_char *html_top_controls(snac *snac, d_char *s) +xs_str *html_top_controls(snac *snac, xs_str *s, int settings) /* generates the top controls */ { char *_tmpl = "
\n" - "
\n" + "
\n" "
%s\n" "
\n" @@ -428,8 +432,8 @@ d_char *html_top_controls(snac *snac, d_char *s) "
\n" "\n" - "
\n" - "
%s\n" + "
\n" + "

%s\n" "\n" /** follow **/ "\n" @@ -440,8 +444,12 @@ d_char *html_top_controls(snac *snac, d_char *s) "\n" " %s\n" "

\n" + "

\n" + "
\n" - "
%s\n" + "
\n" + + "

%s

\n" "
\n" /** user setup **/ "
\n" "
\n" - "
\n" - "
\n" "
\n" "
\n"; @@ -530,6 +536,7 @@ d_char *html_top_controls(snac *snac, d_char *s) xs *es6 = encode_html(purge_days); xs *s1 = xs_fmt(_tmpl, + settings ? "style=\"display: none\"" : "", L("New Post..."), snac->actor, L("Sensitive content"), @@ -550,7 +557,8 @@ d_char *html_top_controls(snac *snac, d_char *s) L("Post"), - L("Preferences..."), + settings ? "style=\"display: none\"" : "", + L("Operations..."), snac->actor, L("Follow"), L("(by URL or user@host)"), @@ -558,6 +566,8 @@ d_char *html_top_controls(snac *snac, d_char *s) snac->actor, L("Boost"), L("(by URL)"), + !settings ? "style=\"display: none\"" : "", + L("User Settings"), snac->actor, L("Display name"), @@ -1376,7 +1386,7 @@ xs_str *html_timeline(snac *snac, const xs_list *list, int local, int skip, int s = html_user_header(snac, s, local); if (!local) - s = html_top_controls(snac, s); + s = html_top_controls(snac, s, list == NULL ? 1 : 0); s = xs_str_cat(s, "\n"); s = xs_str_cat(s, "
\n"); @@ -1813,6 +1823,18 @@ int html_get_handler(const xs_dict *req, const char *q_path, } } else + if (strcmp(p_path, "settings") == 0) { /** user settings **/ + if (!login(&snac, req)) { + *body = xs_dup(uid); + status = 401; + } + else { + *body = html_timeline(&snac, NULL, 0, 0, 0, 0); + *b_size = strlen(*body); + status = 200; + } + } + else if (strcmp(p_path, "notifications") == 0) { /** the list of notifications **/ if (!login(&snac, req)) { *body = xs_dup(uid);