diff options
author | default <nobody@localhost> | 2023-11-27 20:35:58 +0100 |
---|---|---|
committer | default <nobody@localhost> | 2023-11-27 20:35:58 +0100 |
commit | 85e5fc0576f402e976aa0e3ae35dcd9e93413cf5 (patch) | |
tree | 8b7502d4b3029a91198a8d63ef7684e34d0a9418 | |
parent | c50e6c41ea04c14604b87a5698156afb30cb3b94 (diff) |
New function html_instance_body() (still unused).
-rw-r--r-- | html.c | 67 |
1 files changed, 66 insertions, 1 deletions
@@ -456,7 +456,72 @@ xs_html *html_instance_head(void) } -xs_str *html_instance_header(xs_str *s, char *tag) +xs_html *html_instance_body(char *tag) +{ + 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 *blurb = xs_replace(snac_blurb, "%host%", host); + + xs_html *dl; + + xs_html *body = xs_html_tag("body", + xs_html_tag("div", + xs_html_attr("class", "snac-instance-blurb"), + xs_html_raw(blurb), /* pure html */ + dl = xs_html_tag("dl", NULL))); + + if (sdesc && *sdesc) { + xs_html_add(dl, + xs_html_tag("di", + xs_html_tag("dt", + xs_html_text(L("Site description"))), + xs_html_tag("dd", + xs_html_text(sdesc)))); + } + if (email && *email) { + xs *mailto = xs_fmt("mailto:%s", email); + + xs_html_add(dl, + xs_html_tag("di", + xs_html_tag("dt", + xs_html_text(L("Admin email"))), + xs_html_tag("dd", + xs_html_tag("a", + xs_html_attr("href", mailto), + xs_html_text(email))))); + } + if (acct && *acct) { + xs *url = xs_fmt("%s/%s", srv_baseurl, acct); + xs *handle = xs_fmt("@%s@%s", acct, host); + + xs_html_add(dl, + xs_html_tag("di", + xs_html_tag("dt", + xs_html_text(L("Admin account"))), + xs_html_tag("dd", + xs_html_tag("a", + xs_html_attr("href", url), + xs_html_text(handle))))); + } + + { + xs *l = tag ? xs_fmt(L("Search results for #%s"), tag) : + xs_dup(L("Recent posts by users in this instance")); + + xs_html_add(body, + xs_html_tag("h2", + xs_html_attr("class", "snac-header"), + xs_html_text(l))); + } + + return body; +} + + +static xs_str *html_instance_header(xs_str *s, char *tag) { xs_html *head = html_instance_head(); |