From c11bfae555e7fa0851bf2afada5e0d680c142f23 Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Fri, 18 Apr 2025 06:45:58 +0000 Subject: Modified generated HTML to match my stylesheet ehheh --- html.c | 122 +++++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 65 insertions(+), 57 deletions(-) diff --git a/html.c b/html.c index 7d748f9..ef061fc 100644 --- a/html.c +++ b/html.c @@ -880,18 +880,10 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url) } -static xs_html *html_user_body(snac *user, int read_only) +static xs_html *html_user_header(snac *user, int read_only) { - const char *proxy = NULL; - - if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media"))) - proxy = user->actor; - - xs_html *body = xs_html_tag("body", NULL); - /* top nav */ - xs_html *top_nav = xs_html_tag("nav", - xs_html_attr("class", "snac-top-nav")); + xs_html *top_nav = xs_html_tag("header", NULL); xs *avatar = xs_dup(xs_dict_get(user->config, "avatar")); @@ -903,7 +895,6 @@ static xs_html *html_user_body(snac *user, int read_only) xs_html_add(top_nav, xs_html_sctag("img", xs_html_attr("src", avatar), - xs_html_attr("class", "snac-avatar"), xs_html_attr("alt", ""))); if (read_only) { @@ -984,8 +975,18 @@ static xs_html *html_user_body(snac *user, int read_only) xs_html_attr("placeholder", L("Content search"))))); } - xs_html_add(body, - top_nav); + return top_nav; +} + + +static xs_html *html_user_main(snac *user, int read_only) +{ + const char *proxy = NULL; + + if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media"))) + proxy = user->actor; + + xs_html *main = xs_html_tag("main", NULL); /* user info */ xs_html *top_user = xs_html_tag("div", @@ -1180,10 +1181,10 @@ static xs_html *html_user_body(snac *user, int read_only) } } - xs_html_add(body, + xs_html_add(main, top_user); - return body; + return main; } @@ -2844,18 +2845,18 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, xs_html *html_footer(const snac *user) { - return xs_html_tag("div", - xs_html_attr("class", "snac-footer"), - xs_html_tag("a", - xs_html_attr("href", srv_baseurl), - xs_html_text(L("about this site"))), - xs_html_text(" - "), - xs_html_text(L("powered by ")), - xs_html_tag("a", - xs_html_attr("href", WHAT_IS_SNAC_URL), - xs_html_tag("abbr", - xs_html_attr("title", "Social Networks Are Crap"), - xs_html_text("snac")))); + return xs_html_tag("footer", + xs_html_tag("p", + xs_html_tag("a", + xs_html_attr("href", srv_baseurl), + xs_html_text(L("about this site"))), + xs_html_text(" - "), + xs_html_text(L("powered by ")), + xs_html_tag("a", + xs_html_attr("href", WHAT_IS_SNAC_URL), + xs_html_tag("abbr", + xs_html_attr("title", "Social Networks Are Crap"), + xs_html_text("snac"))))); } @@ -2886,27 +2887,33 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, } xs_html *head; - xs_html *body; + xs_html *header; + xs_html *main; if (user) { head = html_user_head(user, desc, alternate); - body = html_user_body(user, read_only); + header = html_user_header(user, read_only); + main = html_user_main(user, read_only); } else { head = html_instance_head(); - body = html_instance_body(); + header = xs_html_tag("header", NULL); + main = html_instance_body(); } xs_html *html = xs_html_tag("html", head, - body); + xs_html_tag("body", + header, + main, + html_footer(user))); if (user && !read_only) - xs_html_add(body, + xs_html_add(main, html_top_controls(user)); if (error != NULL) { - xs_html_add(body, + xs_html_add(main, xs_html_tag("dialog", xs_html_attr("open", NULL), xs_html_tag("p", @@ -2922,7 +2929,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, if (user && !read_only) { xs_html *lol = xs_html_tag("ul", xs_html_attr("class", "snac-list-of-lists")); - xs_html_add(body, lol); + xs_html_add(main, lol); xs *lists = list_maint(user, NULL, 0); /* get list of lists */ @@ -2997,7 +3004,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, if (xs_is_list(followed_hashtags) && xs_list_len(followed_hashtags)) { xs_html *loht = xs_html_tag("ul", xs_html_attr("class", "snac-list-of-lists")); - xs_html_add(body, loht); + xs_html_add(main, loht); const char *ht; @@ -3015,7 +3022,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, } } - xs_html_add(body, + xs_html_add(main, xs_html_tag("a", xs_html_attr("name", "snac-posts"))); @@ -3029,7 +3036,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, xs_html_text(title))); } - xs_html_add(body, + xs_html_add(main, posts); int mark_shown = 0; @@ -3121,14 +3128,14 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, xs_html_text(fn)))); } - xs_html_add(body, + xs_html_add(main, history); } } { xs *s1 = xs_fmt("\n\n", ftime() - t); - xs_html_add(body, + xs_html_add(main, xs_html_raw(s1)); } @@ -3157,13 +3164,10 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, xs_html_attr("name", "snac-more"), xs_html_text(L("More...")))); - xs_html_add(body, + xs_html_add(main, more_links); } - xs_html_add(body, - html_footer(user)); - return xs_html_render_s(html, "\n"); } @@ -3336,8 +3340,10 @@ xs_str *html_people(snac *user) xs_html *html = xs_html_tag("html", html_user_head(user, NULL, NULL), - xs_html_add(html_user_body(user, 0), - lists, + xs_html_tag("body", + html_user_header(user, 0), + xs_html_add(html_user_main(user, 0), + lists), html_footer(user))); return xs_html_render_s(html, "\n"); @@ -3354,15 +3360,18 @@ xs_str *html_notifications(snac *user, int skip, int show) xs *n_list = notify_list(user, skip, show); xs *n_time = notify_check_time(user, 0); - xs_html *body = html_user_body(user, 0); + xs_html *main = html_user_main(user, 0); xs_html *html = xs_html_tag("html", html_user_head(user, NULL, NULL), - body); + xs_html_tag("body", + html_user_header(user, 0), + main, + html_footer(user))); xs *clear_all_action = xs_fmt("%s/admin/clear-notifications", user->actor); - xs_html_add(body, + xs_html_add(main, xs_html_tag("form", xs_html_attr("autocomplete", "off"), xs_html_attr("method", "post"), @@ -3378,7 +3387,7 @@ xs_str *html_notifications(snac *user, int skip, int show) xs_html *posts = xs_html_tag("div", xs_html_attr("class", "snac-posts")); - xs_html_add(body, posts); + xs_html_add(main, posts); xs_set rep; xs_set_init(&rep); @@ -3579,7 +3588,7 @@ xs_str *html_notifications(snac *user, int skip, int show) } if (noti_new == NULL && noti_seen == NULL) - xs_html_add(body, + xs_html_add(main, xs_html_tag("h2", xs_html_attr("class", "snac-header"), xs_html_text(L("None")))); @@ -3590,7 +3599,7 @@ xs_str *html_notifications(snac *user, int skip, int show) xs *url = xs_fmt("%s/notifications?skip=%d&show=%d", user->actor, skip + show, show); - xs_html_add(body, + xs_html_add(main, xs_html_tag("p", xs_html_tag("a", xs_html_attr("href", url), @@ -3599,9 +3608,6 @@ xs_str *html_notifications(snac *user, int skip, int show) xs_set_free(&rep); - xs_html_add(body, - html_footer(user)); - /* set the check time to now */ xs *dummy = notify_check_time(user, 1); dummy = xs_free(dummy); @@ -3871,9 +3877,11 @@ int html_get_handler(const xs_dict *req, const char *q_path, xs_html *html = xs_html_tag("html", html_user_head(&snac, NULL, NULL), - xs_html_add(html_user_body(&snac, 0), - page, - html_footer(user))); + xs_html_tag("body", + html_user_header(&snac, 0), + xs_html_add(html_user_main(&snac, 0), + page), + html_footer(user))); *body = xs_html_render_s(html, "\n"); *b_size = strlen(*body); -- cgit v1.2.3