From 9419b808094c5a9dbb134b9aaaee7303b8af188d Mon Sep 17 00:00:00 2001 From: default Date: Wed, 29 Nov 2023 10:17:41 +0100 Subject: [PATCH] Got rid of dead code. --- html.c | 246 ++------------------------------------------------------- 1 file changed, 6 insertions(+), 240 deletions(-) diff --git a/html.c b/html.c index ac7e372..a6c49de 100644 --- a/html.c +++ b/html.c @@ -80,7 +80,8 @@ xs_str *actor_name(xs_dict *actor) if (n && i) { char *u = xs_dict_get(i, "url"); - xs *img = xs_fmt("", u); + xs *img = xs_fmt("", u); name = xs_replace_i(name, n, img); } @@ -499,67 +500,6 @@ static xs_html *html_instance_body(char *tag) } -static xs_str *html_instance_header(xs_str *s, char *tag) -/* TO BE REPLACED BY html_instance_body() */ -{ - xs_html *head = html_instance_head(); - - char *host = xs_dict_get(srv_config, "host"); - char *sdesc = xs_dict_get(srv_config, "short_description"); - char *email = xs_dict_get(srv_config, "admin_email"); - char *acct = xs_dict_get(srv_config, "admin_account"); - - { - xs *s1 = xs_html_render(head); - s = xs_str_cat(s, "\n", s1); - } - - s = xs_str_cat(s, "\n"); - - s = xs_str_cat(s, "
\n"); - - { - xs *s1 = xs_replace(snac_blurb, "%host%", host); - s = xs_str_cat(s, s1); - } - - s = xs_str_cat(s, "
\n"); - - if (sdesc && *sdesc) { - xs *s1 = xs_fmt("
%s
%s
\n", L("Site description"), sdesc); - s = xs_str_cat(s, s1); - } - if (email && *email) { - xs *s1 = xs_fmt("
%s
" - "%s
\n", - L("Admin email"), email, email); - - s = xs_str_cat(s, s1); - } - if (acct && *acct) { - xs *s1 = xs_fmt("
%s
" - "@%s@%s
\n", - L("Admin account"), srv_baseurl, acct, acct, host); - - s = xs_str_cat(s, s1); - } - - s = xs_str_cat(s, "
\n"); - - s = xs_str_cat(s, "
\n"); - - { - xs *l = tag ? xs_fmt(L("Search results for #%s"), tag) : - xs_dup(L("Recent posts by users in this instance")); - - xs *s1 = xs_fmt("

%s

\n", l); - s = xs_str_cat(s, s1); - } - - return s; -} - - xs_html *html_user_head(snac *user) { xs_html *head = html_base_head(); @@ -815,182 +755,6 @@ static xs_html *html_user_body(snac *user, int local) } -static xs_str *html_user_header(snac *snac, xs_str *s, int local) -/* TO BE REPLACED BY html_user_body() */ -{ - xs_html *head = html_user_head(snac); - - { - xs *s1 = xs_html_render(head); - s = xs_str_cat(s, "\n", s1); - } - - s = xs_str_cat(s, "\n\n"); - - /* top nav */ - xs_html *top_nav = xs_html_tag("nav", - xs_html_attr("class", "snac-top-nav")); - - xs *avatar = xs_dup(xs_dict_get(snac->config, "avatar")); - - if (avatar == NULL || *avatar == '\0') { - xs_free(avatar); - avatar = xs_fmt("data:image/png;base64, %s", default_avatar_base64()); - } - - 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 (local) { - xs *rss_url = xs_fmt("%s.rss", snac->actor); - xs *admin_url = xs_fmt("%s/admin", snac->actor); - - 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) { - 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 - notify_count = xs_html_text(""); - - 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); - } - - /* user info */ - { - xs_html *top_user = xs_html_tag("div", - xs_html_attr("class", "h-card snac-top-user")); - - if (local) { - char *header = xs_dict_get(snac->config, "header"); - if (header && *header) { - xs_html_add(top_user, - xs_html_tag("div", - xs_html_attr("class", "snac-top-user-banner"), - xs_html_attr("style", "clear: both"), - xs_html_sctag("br", NULL), - xs_html_sctag("img", - xs_html_attr("src", header)))); - } - } - - xs *handle = xs_fmt("@%s@%s", - xs_dict_get(snac->config, "uid"), - xs_dict_get(srv_config, "host")); - - xs_html_add(top_user, - xs_html_tag("p", - xs_html_attr("class", "p-name snac-top-user-name"), - xs_html_text(xs_dict_get(snac->config, "name"))), - xs_html_tag("p", - xs_html_attr("class", "snac-top-user-id"), - xs_html_text(handle))); - - if (local) { - xs *es1 = encode_html(xs_dict_get(snac->config, "bio")); - xs *bio1 = not_really_markdown(es1, NULL); - xs *tags = xs_list_new(); - xs *bio2 = process_tags(snac, bio1, &tags); - - xs_html *top_user_bio = xs_html_tag("div", - xs_html_attr("class", "p-note snac-top-user-bio"), - xs_html_raw(bio2)); /* already sanitized */ - - xs_html_add(top_user, - top_user_bio); - - xs_dict *metadata = xs_dict_get(snac->config, "metadata"); - if (xs_type(metadata) == XSTYPE_DICT) { - xs_str *k; - xs_str *v; - - xs_html *snac_metadata = xs_html_tag("div", - xs_html_attr("class", "snac-metadata")); - - while (xs_dict_iter(&metadata, &k, &v)) { - xs_html *value; - - if (xs_startswith(v, "https:/" "/")) - value = xs_html_tag("a", - xs_html_attr("href", v), - xs_html_text(v)); - else - value = xs_html_text(v); - - xs_html_add(snac_metadata, - xs_html_tag("span", - xs_html_attr("class", "snac-property-name"), - xs_html_text(k)), - xs_html_text(":"), - xs_html_sctag("br", NULL), - xs_html_tag("span", - xs_html_attr("class", "snac-property-value"), - value), - xs_html_sctag("br", NULL)); - } - - xs_html_add(top_user, - snac_metadata); - } - } - - { - xs *s1 = xs_html_render(top_user); - s = xs_str_cat(s, s1); - } - } - - return s; -} - - xs_html *html_top_controls(snac *snac) /* generates the top controls */ { @@ -1196,7 +960,8 @@ xs_html *html_top_controls(snac *snac) xs_html_attr(xs_type(a_private) == XSTYPE_TRUE ? "checked" : "", NULL)), xs_html_tag("label", xs_html_attr("for", "private"), - xs_html_text(L("This account is private (posts are not shown through the web)")))), + xs_html_text(L("This account is private " + "(posts are not shown through the web)")))), xs_html_tag("p", xs_html_text(L("Profile metadata (key=value pairs in each line):")), xs_html_sctag("br", NULL), @@ -1204,7 +969,8 @@ xs_html *html_top_controls(snac *snac) xs_html_attr("name", "metadata"), xs_html_attr("cols", "40"), xs_html_attr("rows", "4"), - xs_html_attr("placeholder", "Blog=https:/" "/example.com/my-blog\nGPG Key=1FA54\n..."), + xs_html_attr("placeholder", "Blog=https:/" + "/example.com/my-blog\nGPG Key=1FA54\n..."), xs_html_text(metadata))), xs_html_tag("p",