commit 9419b80
default
·
2023-11-29 09:17:41 +0000 UTC
parent b1a9279
Got rid of dead code.
1 files changed,
+6,
-240
M
html.c
M
html.c
+6,
-240
1@@ -80,7 +80,8 @@ xs_str *actor_name(xs_dict *actor)
2
3 if (n && i) {
4 char *u = xs_dict_get(i, "url");
5- xs *img = xs_fmt("<img loading=\"lazy\" src=\"%s\" style=\"height: 1em; vertical-align: middle;\"/>", u);
6+ xs *img = xs_fmt("<img loading=\"lazy\" src=\"%s\" "
7+ "style=\"height: 1em; vertical-align: middle;\"/>", u);
8
9 name = xs_replace_i(name, n, img);
10 }
11@@ -499,67 +500,6 @@ static xs_html *html_instance_body(char *tag)
12 }
13
14
15-static xs_str *html_instance_header(xs_str *s, char *tag)
16-/* TO BE REPLACED BY html_instance_body() */
17-{
18- xs_html *head = html_instance_head();
19-
20- char *host = xs_dict_get(srv_config, "host");
21- char *sdesc = xs_dict_get(srv_config, "short_description");
22- char *email = xs_dict_get(srv_config, "admin_email");
23- char *acct = xs_dict_get(srv_config, "admin_account");
24-
25- {
26- xs *s1 = xs_html_render(head);
27- s = xs_str_cat(s, "<!DOCTYPE html><html>\n", s1);
28- }
29-
30- s = xs_str_cat(s, "<body>\n");
31-
32- s = xs_str_cat(s, "<div class=\"snac-instance-blurb\">\n");
33-
34- {
35- xs *s1 = xs_replace(snac_blurb, "%host%", host);
36- s = xs_str_cat(s, s1);
37- }
38-
39- s = xs_str_cat(s, "<dl>\n");
40-
41- if (sdesc && *sdesc) {
42- xs *s1 = xs_fmt("<di><dt>%s</dt><dd>%s</dd></di>\n", L("Site description"), sdesc);
43- s = xs_str_cat(s, s1);
44- }
45- if (email && *email) {
46- xs *s1 = xs_fmt("<di><dt>%s</dt><dd>"
47- "<a href=\"mailto:%s\">%s</a></dd></di>\n",
48- L("Admin email"), email, email);
49-
50- s = xs_str_cat(s, s1);
51- }
52- if (acct && *acct) {
53- xs *s1 = xs_fmt("<di><dt>%s</dt><dd>"
54- "<a href=\"%s/%s\">@%s@%s</a></dd></di>\n",
55- L("Admin account"), srv_baseurl, acct, acct, host);
56-
57- s = xs_str_cat(s, s1);
58- }
59-
60- s = xs_str_cat(s, "</dl>\n");
61-
62- s = xs_str_cat(s, "</div>\n");
63-
64- {
65- xs *l = tag ? xs_fmt(L("Search results for #%s"), tag) :
66- xs_dup(L("Recent posts by users in this instance"));
67-
68- xs *s1 = xs_fmt("<h2 class=\"snac-header\">%s</h2>\n", l);
69- s = xs_str_cat(s, s1);
70- }
71-
72- return s;
73-}
74-
75-
76 xs_html *html_user_head(snac *user)
77 {
78 xs_html *head = html_base_head();
79@@ -815,182 +755,6 @@ static xs_html *html_user_body(snac *user, int local)
80 }
81
82
83-static xs_str *html_user_header(snac *snac, xs_str *s, int local)
84-/* TO BE REPLACED BY html_user_body() */
85-{
86- xs_html *head = html_user_head(snac);
87-
88- {
89- xs *s1 = xs_html_render(head);
90- s = xs_str_cat(s, "<!DOCTYPE html><html>\n", s1);
91- }
92-
93- s = xs_str_cat(s, "\n<body>\n");
94-
95- /* top nav */
96- xs_html *top_nav = xs_html_tag("nav",
97- xs_html_attr("class", "snac-top-nav"));
98-
99- xs *avatar = xs_dup(xs_dict_get(snac->config, "avatar"));
100-
101- if (avatar == NULL || *avatar == '\0') {
102- xs_free(avatar);
103- avatar = xs_fmt("data:image/png;base64, %s", default_avatar_base64());
104- }
105-
106- xs_html_add(top_nav,
107- xs_html_sctag("img",
108- xs_html_attr("src", avatar),
109- xs_html_attr("class", "snac-avatar"),
110- xs_html_attr("alt", "")));
111-
112- {
113- if (local) {
114- xs *rss_url = xs_fmt("%s.rss", snac->actor);
115- xs *admin_url = xs_fmt("%s/admin", snac->actor);
116-
117- xs_html_add(top_nav,
118- xs_html_tag("a",
119- xs_html_attr("href", rss_url),
120- xs_html_text(L("RSS"))),
121- xs_html_text(" - "),
122- xs_html_tag("a",
123- xs_html_attr("href", admin_url),
124- xs_html_attr("rel", "nofollow"),
125- xs_html_text(L("private"))));
126- }
127- else {
128- xs *n_list = notify_list(snac, 1);
129- int n_len = xs_list_len(n_list);
130- xs *n_str = NULL;
131- xs_html *notify_count = NULL;
132-
133- /* show the number of new notifications, if there are any */
134- if (n_len) {
135- xs *n_len_str = xs_fmt(" %d ", n_len);
136- notify_count = xs_html_tag("sup",
137- xs_html_attr("style", "background-color: red; color: white;"),
138- xs_html_text(n_len_str));
139- }
140- else
141- notify_count = xs_html_text("");
142-
143- xs *admin_url = xs_fmt("%s/admin", snac->actor);
144- xs *notify_url = xs_fmt("%s/notifications", snac->actor);
145- xs *people_url = xs_fmt("%s/people", snac->actor);
146- xs_html_add(top_nav,
147- xs_html_tag("a",
148- xs_html_attr("href", snac->actor),
149- xs_html_text(L("public"))),
150- xs_html_text(" - "),
151- xs_html_tag("a",
152- xs_html_attr("href", admin_url),
153- xs_html_text(L("private"))),
154- xs_html_text(" - "),
155- xs_html_tag("a",
156- xs_html_attr("href", notify_url),
157- xs_html_text(L("notifications"))),
158- notify_count,
159- xs_html_text(" - "),
160- xs_html_tag("a",
161- xs_html_attr("href", people_url),
162- xs_html_text(L("people"))));
163- }
164- }
165-
166- {
167- xs *s1 = xs_html_render(top_nav);
168- s = xs_str_cat(s, s1);
169- }
170-
171- /* user info */
172- {
173- xs_html *top_user = xs_html_tag("div",
174- xs_html_attr("class", "h-card snac-top-user"));
175-
176- if (local) {
177- char *header = xs_dict_get(snac->config, "header");
178- if (header && *header) {
179- xs_html_add(top_user,
180- xs_html_tag("div",
181- xs_html_attr("class", "snac-top-user-banner"),
182- xs_html_attr("style", "clear: both"),
183- xs_html_sctag("br", NULL),
184- xs_html_sctag("img",
185- xs_html_attr("src", header))));
186- }
187- }
188-
189- xs *handle = xs_fmt("@%s@%s",
190- xs_dict_get(snac->config, "uid"),
191- xs_dict_get(srv_config, "host"));
192-
193- xs_html_add(top_user,
194- xs_html_tag("p",
195- xs_html_attr("class", "p-name snac-top-user-name"),
196- xs_html_text(xs_dict_get(snac->config, "name"))),
197- xs_html_tag("p",
198- xs_html_attr("class", "snac-top-user-id"),
199- xs_html_text(handle)));
200-
201- if (local) {
202- xs *es1 = encode_html(xs_dict_get(snac->config, "bio"));
203- xs *bio1 = not_really_markdown(es1, NULL);
204- xs *tags = xs_list_new();
205- xs *bio2 = process_tags(snac, bio1, &tags);
206-
207- xs_html *top_user_bio = xs_html_tag("div",
208- xs_html_attr("class", "p-note snac-top-user-bio"),
209- xs_html_raw(bio2)); /* already sanitized */
210-
211- xs_html_add(top_user,
212- top_user_bio);
213-
214- xs_dict *metadata = xs_dict_get(snac->config, "metadata");
215- if (xs_type(metadata) == XSTYPE_DICT) {
216- xs_str *k;
217- xs_str *v;
218-
219- xs_html *snac_metadata = xs_html_tag("div",
220- xs_html_attr("class", "snac-metadata"));
221-
222- while (xs_dict_iter(&metadata, &k, &v)) {
223- xs_html *value;
224-
225- if (xs_startswith(v, "https:/" "/"))
226- value = xs_html_tag("a",
227- xs_html_attr("href", v),
228- xs_html_text(v));
229- else
230- value = xs_html_text(v);
231-
232- xs_html_add(snac_metadata,
233- xs_html_tag("span",
234- xs_html_attr("class", "snac-property-name"),
235- xs_html_text(k)),
236- xs_html_text(":"),
237- xs_html_sctag("br", NULL),
238- xs_html_tag("span",
239- xs_html_attr("class", "snac-property-value"),
240- value),
241- xs_html_sctag("br", NULL));
242- }
243-
244- xs_html_add(top_user,
245- snac_metadata);
246- }
247- }
248-
249- {
250- xs *s1 = xs_html_render(top_user);
251- s = xs_str_cat(s, s1);
252- }
253- }
254-
255- return s;
256-}
257-
258-
259 xs_html *html_top_controls(snac *snac)
260 /* generates the top controls */
261 {
262@@ -1196,7 +960,8 @@ xs_html *html_top_controls(snac *snac)
263 xs_html_attr(xs_type(a_private) == XSTYPE_TRUE ? "checked" : "", NULL)),
264 xs_html_tag("label",
265 xs_html_attr("for", "private"),
266- xs_html_text(L("This account is private (posts are not shown through the web)")))),
267+ xs_html_text(L("This account is private "
268+ "(posts are not shown through the web)")))),
269 xs_html_tag("p",
270 xs_html_text(L("Profile metadata (key=value pairs in each line):")),
271 xs_html_sctag("br", NULL),
272@@ -1204,7 +969,8 @@ xs_html *html_top_controls(snac *snac)
273 xs_html_attr("name", "metadata"),
274 xs_html_attr("cols", "40"),
275 xs_html_attr("rows", "4"),
276- xs_html_attr("placeholder", "Blog=https:/" "/example.com/my-blog\nGPG Key=1FA54\n..."),
277+ xs_html_attr("placeholder", "Blog=https:/"
278+ "/example.com/my-blog\nGPG Key=1FA54\n..."),
279 xs_html_text(metadata))),
280
281 xs_html_tag("p",