commit 85e5fc0
default
·
2023-11-27 19:35:58 +0000 UTC
parent c50e6c4
New function html_instance_body() (still unused).
1 files changed,
+66,
-1
M
html.c
M
html.c
+66,
-1
1@@ -456,7 +456,72 @@ xs_html *html_instance_head(void)
2 }
3
4
5-xs_str *html_instance_header(xs_str *s, char *tag)
6+xs_html *html_instance_body(char *tag)
7+{
8+ char *host = xs_dict_get(srv_config, "host");
9+ char *sdesc = xs_dict_get(srv_config, "short_description");
10+ char *email = xs_dict_get(srv_config, "admin_email");
11+ char *acct = xs_dict_get(srv_config, "admin_account");
12+
13+ xs *blurb = xs_replace(snac_blurb, "%host%", host);
14+
15+ xs_html *dl;
16+
17+ xs_html *body = xs_html_tag("body",
18+ xs_html_tag("div",
19+ xs_html_attr("class", "snac-instance-blurb"),
20+ xs_html_raw(blurb), /* pure html */
21+ dl = xs_html_tag("dl", NULL)));
22+
23+ if (sdesc && *sdesc) {
24+ xs_html_add(dl,
25+ xs_html_tag("di",
26+ xs_html_tag("dt",
27+ xs_html_text(L("Site description"))),
28+ xs_html_tag("dd",
29+ xs_html_text(sdesc))));
30+ }
31+ if (email && *email) {
32+ xs *mailto = xs_fmt("mailto:%s", email);
33+
34+ xs_html_add(dl,
35+ xs_html_tag("di",
36+ xs_html_tag("dt",
37+ xs_html_text(L("Admin email"))),
38+ xs_html_tag("dd",
39+ xs_html_tag("a",
40+ xs_html_attr("href", mailto),
41+ xs_html_text(email)))));
42+ }
43+ if (acct && *acct) {
44+ xs *url = xs_fmt("%s/%s", srv_baseurl, acct);
45+ xs *handle = xs_fmt("@%s@%s", acct, host);
46+
47+ xs_html_add(dl,
48+ xs_html_tag("di",
49+ xs_html_tag("dt",
50+ xs_html_text(L("Admin account"))),
51+ xs_html_tag("dd",
52+ xs_html_tag("a",
53+ xs_html_attr("href", url),
54+ xs_html_text(handle)))));
55+ }
56+
57+ {
58+ xs *l = tag ? xs_fmt(L("Search results for #%s"), tag) :
59+ xs_dup(L("Recent posts by users in this instance"));
60+
61+ xs_html_add(body,
62+ xs_html_tag("h2",
63+ xs_html_attr("class", "snac-header"),
64+ xs_html_text(l)));
65+ }
66+
67+ return body;
68+}
69+
70+
71+static xs_str *html_instance_header(xs_str *s, char *tag)
72 {
73 xs_html *head = html_instance_head();
74