From 179a7ae014bae0c995f34b446d3868dd42a2207c Mon Sep 17 00:00:00 2001 From: default Date: Tue, 28 Nov 2023 10:13:27 +0100 Subject: [PATCH] Converted top_nav to xs_html. --- html.c | 79 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 28 deletions(-) diff --git a/html.c b/html.c index d49cfd6..95541d2 100644 --- a/html.c +++ b/html.c @@ -668,7 +668,8 @@ xs_str *html_user_header(snac *snac, xs_str *s, int local) s = xs_str_cat(s, "\n\n"); /* top nav */ - s = xs_str_cat(s, "\n", - snac->actor, L("RSS"), - snac->actor, L("private")); + xs_html_add(top_nav, + xs_html_tag("a", + xs_html_attr("href", rss_url), + xs_html_text(L("RSS"))), + xs_html_text(" - "), + xs_html_tag("a", + xs_html_attr("href", admin_url), + xs_html_attr("rel", "nofollow"), + xs_html_text(L("private")))); + } else { xs *n_list = notify_list(snac, 1); int n_len = xs_list_len(n_list); xs *n_str = NULL; + xs_html *notify_count = NULL; /* show the number of new notifications, if there are any */ - if (n_len) - n_str = xs_fmt(" %d ", n_len); + if (n_len) { + xs *n_len_str = xs_fmt(" %d ", n_len); + notify_count = xs_html_tag("sup", + xs_html_attr("style", "background-color: red; color: white;"), + xs_html_text(n_len_str)); + } else - n_str = xs_str_new(""); + notify_count = xs_html_text(""); - s1 = xs_fmt( - "%s - " - "%s - " - "%s%s - " - "%s\n", - snac->actor, L("public"), - snac->actor, L("private"), - snac->actor, L("notifications"), n_str, - snac->actor, L("people")); + xs *admin_url = xs_fmt("%s/admin", snac->actor); + xs *notify_url = xs_fmt("%s/notifications", snac->actor); + xs *people_url = xs_fmt("%s/people", snac->actor); + xs_html_add(top_nav, + xs_html_tag("a", + xs_html_attr("href", snac->actor), + xs_html_text(L("public"))), + xs_html_text(" - "), + xs_html_tag("a", + xs_html_attr("href", admin_url), + xs_html_text(L("private"))), + xs_html_text(" - "), + xs_html_tag("a", + xs_html_attr("href", notify_url), + xs_html_text(L("notifications"))), + notify_count, + xs_html_text(" - "), + xs_html_tag("a", + xs_html_attr("href", people_url), + xs_html_text(L("people")))); } + } + { + xs *s1 = xs_html_render(top_nav); s = xs_str_cat(s, s1); }