From 75e061a9f78939e3235125ec180186080bd57b58 Mon Sep 17 00:00:00 2001 From: Yonle Date: Sun, 23 Jul 2023 23:11:02 +0700 Subject: html.c & httpd.c: Fix hardlink. Some people may still want to post in the web client with such different way, Such as posting from Yggdrasil / SSH port forwarder, and so on. This commit gives the workaround for that purpose, However things will go messed up when current path were ends with / (Like: user/, admin/). But overall, If user just uses it like normal, Then things will just worked well as expected. Signed-off-by: Yonle --- html.c | 68 ++++++++++++++++++++++++++++++----------------------------------- httpd.c | 2 +- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/html.c b/html.c index 5543a2d..d808e3b 100644 --- a/html.c +++ b/html.c @@ -325,8 +325,8 @@ d_char *html_user_header(snac *snac, d_char *s, int local) s1 = xs_fmt( "%s - " "%s\n", - snac->actor, L("RSS"), - snac->actor, L("private")); + snac->uid, L("RSS"), + snac->uid, L("private")); else { xs *n_list = notify_list(snac, 1); int n_len = xs_list_len(n_list); @@ -340,18 +340,17 @@ d_char *html_user_header(snac *snac, d_char *s, int local) n_str = xs_str_new(""); s1 = xs_fmt( - "%s - " - "%s - " - "%s%s - " - "%s - " - "%s" - "\n", - snac->actor, L("public"), - snac->actor, L("private"), - snac->actor, L("notifications"), n_str, - snac->actor, L("people"), - snac->actor, L("settings") - ); + "%s - " + "%s - " + "%s%s - " + "%s\n" + "%s" + "" + snac->uid, L("public"), + L("private"), + L("notifications"), n_str, + L("people"), + L("settings")); } s = xs_str_cat(s, s1); @@ -398,7 +397,7 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) "
\n" "
%s\n" "
\n" + "action=\"admin/note\" enctype=\"multipart/form-data\">\n" "\n" "\n" @@ -435,12 +434,12 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) "
\n" "

%s\n" - "\n" /** follow **/ + "\n" /** follow **/ "\n" " %s\n" "

\n" - "

\n" /** boost **/ + "\n" /** boost **/ "\n" " %s\n" "

\n" @@ -453,7 +452,7 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) "

\n" /** user setup **/ "
\n" + "action=\"admin/user-setup\" enctype=\"multipart/form-data\">\n" "

%s:
\n" "

\n" @@ -538,7 +537,6 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) xs *s1 = xs_fmt(_tmpl, settings ? "style=\"display: none\"" : "", L("New Post..."), - snac->actor, L("Sensitive content"), L("Sensitive content description"), L("Only for mentioned people"), @@ -560,16 +558,12 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) settings ? "style=\"display: none\"" : "", L("Operations..."), - snac->actor, L("Follow"), L("(by URL or user@host)"), - - snac->actor, L("Boost"), L("(by URL)"), !settings ? "style=\"display: none\"" : "", L("User Settings"), - snac->actor, L("Display name"), es1, L("Avatar"), @@ -673,13 +667,13 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch { xs *s1 = xs_fmt( - "\n" + "\n" "\n" "\n" "\n" "\n", - snac->actor, id, actor, md5 + id, actor, md5 ); s = xs_str_cat(s, s1); @@ -733,7 +727,7 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch xs *s1 = xs_fmt( "

%s\n" "

\n" - "\n" "\n" @@ -784,7 +778,7 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch xs *s1 = xs_fmt( "

%s\n" "

\n" - "\n" "\n" @@ -807,7 +801,7 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch L("Reply..."), md5, - snac->actor, md5, + md5, ct, id, L("Sensitive content"), @@ -1102,10 +1096,10 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local, /* poll still active */ xs *s1 = xs_fmt("
\n" "\n" + "method=\"post\" action=\"admin/vote\">\n" "\n" "\n", - snac->actor, actor, id); + actor, id); while (xs_list_iter(&p, &v)) { const char *name = xs_dict_get(v, "name"); @@ -1495,11 +1489,11 @@ d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *heade s = xs_str_cat(s, "
\n"); xs *s1 = xs_fmt( - "

\n" + "

\n" "\n" "\n", - snac->actor, actor_id + actor_id ); s = xs_str_cat(s, s1); @@ -1523,7 +1517,7 @@ d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *heade xs *s2 = xs_fmt( "

%s\n" "

\n" - "\n" "\n" @@ -1535,7 +1529,7 @@ d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *heade L("Direct Message..."), md5, t, - snac->actor, md5, + md5, actor_id, L("Post") ); @@ -1586,9 +1580,9 @@ xs_str *html_notifications(snac *snac) xs *s1 = xs_fmt( "\n" + "method=\"post\" action=\"admin/clear-notifications\" id=\"clear\">\n" "\n" - "

\n", snac->actor, L("Clear all")); + "

\n", L("Clear all")); s = xs_str_cat(s, s1); while (xs_list_iter(&p, &v)) { @@ -2402,7 +2396,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, if (xs_is_null(redir)) redir = "snac-posts"; - *body = xs_fmt("%s/admin#%s", snac.actor, redir); + *body = xs_fmt("../admin#%s", redir); *b_size = strlen(*body); } diff --git a/httpd.c b/httpd.c index 9aac3b5..1d2200e 100644 --- a/httpd.c +++ b/httpd.c @@ -91,7 +91,7 @@ int server_get_handler(xs_dict *req, char *q_path, if (user_open(&snac, uid)) { xs *u = xs_fmt( "

  • @%s@%s (%s)
  • \n", - snac.actor, uid, host, + uid, uid, host, xs_dict_get(snac.config, "name")); ul = xs_str_cat(ul, u); -- cgit v1.2.3 From 68d03d6d514358bf07db012622eb940a981f1960 Mon Sep 17 00:00:00 2001 From: Yonle Date: Sun, 23 Jul 2023 23:26:33 +0700 Subject: html.c: No need to redirect to #snac-posts again. Form has been minimized with
    since commit c409d2e, So there is no need to redirect user to user/admin#snac-posts again. Signed-off-by: Yonle --- html.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html.c b/html.c index d808e3b..198269f 100644 --- a/html.c +++ b/html.c @@ -345,7 +345,7 @@ d_char *html_user_header(snac *snac, d_char *s, int local) "%s%s - " "%s\n" "%s" - "" + "", snac->uid, L("public"), L("private"), L("notifications"), n_str, @@ -750,7 +750,7 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch L("Edit..."), md5, - snac->actor, md5, + md5, prev_src, id, L("Sensitive content"), @@ -2394,7 +2394,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, char *redir = xs_dict_get(p_vars, "redir"); if (xs_is_null(redir)) - redir = "snac-posts"; + redir = ""; *body = xs_fmt("../admin#%s", redir); *b_size = strlen(*body); -- cgit v1.2.3 From e776bf7e2c81d2cd03efda14e06d375bf80f890b Mon Sep 17 00:00:00 2001 From: Yonle Date: Mon, 24 Jul 2023 20:36:35 +0700 Subject: html.c: Rollback to e9adaa1f7a, Put "User Settings..." outside of "Operations..."'s
    element Signed-off-by: Yonle --- html.c | 44 +++++++++++--------------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/html.c b/html.c index 198269f..725c064 100644 --- a/html.c +++ b/html.c @@ -1,4 +1,4 @@ -/* snac - A simple, minimalistic ActivityPub instance */ + /* snac - A simple, minimalistic ActivityPub instance */ /* copyright (c) 2022 - 2023 grunfink / MIT license */ #include "xs.h" @@ -343,14 +343,11 @@ d_char *html_user_header(snac *snac, d_char *s, int local) "%s - " "%s - " "%s%s - " - "%s\n" - "%s" - "", + "%s\n", snac->uid, L("public"), L("private"), L("notifications"), n_str, - L("people"), - L("settings")); + L("people")); } s = xs_str_cat(s, s1); @@ -388,13 +385,13 @@ d_char *html_user_header(snac *snac, d_char *s, int local) } -xs_str *html_top_controls(snac *snac, xs_str *s, int settings) +d_char *html_top_controls(snac *snac, d_char *s) /* generates the top controls */ { char *_tmpl = "
    \n" - "
    \n" + "
    \n" "
    %s\n" "
    \n" @@ -431,8 +428,8 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) "
    \n" "
    \n" - "
    \n" - "

    %s\n" + "
    \n" + "
    %s\n" "\n" /** follow **/ "\n" @@ -444,11 +441,8 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) " %s\n" "

    \n" "

    \n" - "
    \n" - - "
    \n" - "

    %s

    \n" + "
    %s\n" "
    \n" /** user setup **/ "
    \n" "
    \n" + "
    \n" "
    \n" "
    \n"; @@ -535,7 +530,6 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) xs *es6 = encode_html(purge_days); xs *s1 = xs_fmt(_tmpl, - settings ? "style=\"display: none\"" : "", L("New Post..."), L("Sensitive content"), L("Sensitive content description"), @@ -555,15 +549,11 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) L("Post"), - settings ? "style=\"display: none\"" : "", L("Operations..."), - L("Follow"), L("(by URL or user@host)"), L("Boost"), L("(by URL)"), - !settings ? "style=\"display: none\"" : "", - - L("User Settings"), + L("User Settings..."), L("Display name"), es1, L("Avatar"), @@ -1380,7 +1370,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, list == NULL ? 1 : 0); + s = html_top_controls(snac, s); s = xs_str_cat(s, "\n"); s = xs_str_cat(s, "
    \n"); @@ -1817,18 +1807,6 @@ 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); -- cgit v1.2.3