commit f67ac25

default  ·  2023-07-24 11:31:13 +0000 UTC
parent 86f5074
Moved user settings to its own page.
1 files changed,  +33, -11
M html.c
M html.c
+33, -11
  1@@ -343,11 +343,15 @@ d_char *html_user_header(snac *snac, d_char *s, int local)
  2                 "<a href=\"%s\">%s</a> - "
  3                 "<a href=\"%s/admin\">%s</a> - "
  4                 "<a href=\"%s/notifications\">%s</a>%s - "
  5-                "<a href=\"%s/people\">%s</a></nav>\n",
  6+                "<a href=\"%s/people\">%s</a> - "
  7+                "<a href=\"%s/settings\">%s</a>"
  8+                "</nav>\n",
  9                 snac->actor, L("public"),
 10                 snac->actor, L("private"),
 11                 snac->actor, L("notifications"), n_str,
 12-                snac->actor, L("people"));
 13+                snac->actor, L("people"),
 14+                snac->actor, L("settings")
 15+            );
 16         }
 17 
 18         s = xs_str_cat(s, s1);
 19@@ -385,13 +389,13 @@ d_char *html_user_header(snac *snac, d_char *s, int local)
 20 }
 21 
 22 
 23-d_char *html_top_controls(snac *snac, d_char *s)
 24+xs_str *html_top_controls(snac *snac, xs_str *s, int settings)
 25 /* generates the top controls */
 26 {
 27     char *_tmpl =
 28         "<div class=\"snac-top-controls\">\n"
 29 
 30-        "<div class=\"snac-note\">\n"
 31+        "<div class=\"snac-note\" %s>\n"
 32         "<details><summary>%s</summary>\n"
 33         "<form autocomplete=\"off\" method=\"post\" "
 34         "action=\"%s/admin/note\" enctype=\"multipart/form-data\">\n"
 35@@ -428,8 +432,8 @@ d_char *html_top_controls(snac *snac, d_char *s)
 36         "</div>\n"
 37         "</details>\n"
 38 
 39-        "<div class=\"snac-top-controls-more\">\n"
 40-        "<details><summary>%s</summary>\n"
 41+        "<div class=\"snac-top-controls-more\" %s>\n"
 42+        "<p><details><summary>%s</summary>\n"
 43 
 44         "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n" /** follow **/
 45         "<input type=\"text\" name=\"actor\" required=\"required\" placeholder=\"bob@example.com\">\n"
 46@@ -440,8 +444,12 @@ d_char *html_top_controls(snac *snac, d_char *s)
 47         "<input type=\"text\" name=\"id\" required=\"required\" placeholder=\"https://fedi.example.com/bob/....\">\n"
 48         "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n"
 49         "</form><p>\n"
 50+        "</details>\n"
 51+        "</div>\n"
 52 
 53-        "<details><summary>%s</summary>\n"
 54+        "<div class=\"snac-user-settings\" %s>\n"
 55+
 56+        "<h2 class=\"snac-header\">%s</h2>\n"
 57 
 58         "<div class=\"snac-user-setup\">\n" /** user setup **/
 59         "<form autocomplete=\"off\" method=\"post\" "
 60@@ -483,8 +491,6 @@ d_char *html_top_controls(snac *snac, d_char *s)
 61         "</form>\n"
 62 
 63         "</div>\n"
 64-        "</details>\n"
 65-        "</details>\n"
 66         "</div>\n"
 67         "</div>\n";
 68 
 69@@ -530,6 +536,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
 70     xs *es6 = encode_html(purge_days);
 71 
 72     xs *s1 = xs_fmt(_tmpl,
 73+        settings ? "style=\"display: none\"" : "",
 74         L("New Post..."),
 75         snac->actor,
 76         L("Sensitive content"),
 77@@ -550,7 +557,8 @@ d_char *html_top_controls(snac *snac, d_char *s)
 78 
 79         L("Post"),
 80 
 81-        L("Preferences..."),
 82+        settings ? "style=\"display: none\"" : "",
 83+        L("Operations..."),
 84 
 85         snac->actor,
 86         L("Follow"), L("(by URL or user@host)"),
 87@@ -558,6 +566,8 @@ d_char *html_top_controls(snac *snac, d_char *s)
 88         snac->actor,
 89         L("Boost"), L("(by URL)"),
 90 
 91+        !settings ? "style=\"display: none\"" : "",
 92+
 93         L("User Settings"),
 94         snac->actor,
 95         L("Display name"),
 96@@ -1376,7 +1386,7 @@ xs_str *html_timeline(snac *snac, const xs_list *list, int local, int skip, int
 97     s = html_user_header(snac, s, local);
 98 
 99     if (!local)
100-        s = html_top_controls(snac, s);
101+        s = html_top_controls(snac, s, list == NULL ? 1 : 0);
102 
103     s = xs_str_cat(s, "<a name=\"snac-posts\"></a>\n");
104     s = xs_str_cat(s, "<div class=\"snac-posts\">\n");
105@@ -1813,6 +1823,18 @@ int html_get_handler(const xs_dict *req, const char *q_path,
106         }
107     }
108     else
109+    if (strcmp(p_path, "settings") == 0) { /** user settings **/
110+        if (!login(&snac, req)) {
111+            *body  = xs_dup(uid);
112+            status = 401;
113+        }
114+        else {
115+            *body   = html_timeline(&snac, NULL, 0, 0, 0, 0);
116+            *b_size = strlen(*body);
117+            status  = 200;
118+        }
119+    }
120+    else
121     if (strcmp(p_path, "notifications") == 0) { /** the list of notifications **/
122         if (!login(&snac, req)) {
123             *body  = xs_dup(uid);