commit 04b2532
default
·
2023-11-27 20:54:57 +0000 UTC
parent ae121bb
More html_entry() refactoring.
1 files changed,
+37,
-44
M
html.c
M
html.c
+37,
-44
1@@ -1298,10 +1298,13 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
2 else
3 s = xs_str_cat(s, "<div class=\"snac-child\">\n"); /** **/
4
5- s = xs_str_cat(s, "<div class=\"snac-post-header\">\n"); /** **/
6+ /** post header **/
7
8- xs_html *score = xs_html_tag("div",
9- xs_html_attr("class", "snac-score"));
10+ xs_html *score;
11+ xs_html *post_header = xs_html_tag("div",
12+ xs_html_attr("class", "snac-post-header"),
13+ score = xs_html_tag("div",
14+ xs_html_attr("class", "snac-score")));
15
16 if (user && is_pinned(user, id)) {
17 /* add a pin emoji */
18@@ -1339,11 +1342,6 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
19 xs_html_raw(s1));
20 }
21
22- {
23- xs *s1 = xs_html_render(score);
24- s = xs_str_cat(s, s1);
25- }
26-
27 if (boosts == NULL)
28 boosts = object_announces(id);
29
30@@ -1354,33 +1352,28 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
31
32 if (user && xs_list_in(boosts, user->md5) != -1) {
33 /* we boosted this */
34- xs_html *h = xs_html_tag("div",
35- xs_html_attr("class", "snac-origin"),
36- xs_html_tag("a",
37- xs_html_attr("href", user->actor),
38- xs_html_text(xs_dict_get(user->config, "name"))),
39- xs_html_text(" "),
40- xs_html_text(L("boosted")));
41-
42- xs *s1 = xs_html_render(h);
43- s = xs_str_cat(s, s1);
44+ xs_html_add(post_header,
45+ xs_html_tag("div",
46+ xs_html_attr("class", "snac-origin"),
47+ xs_html_tag("a",
48+ xs_html_attr("href", user->actor),
49+ xs_html_text(xs_dict_get(user->config, "name"))),
50+ xs_html_text(" "),
51+ xs_html_text(L("boosted"))));
52 }
53 else
54 if (valid_status(object_get_by_md5(p, &actor_r))) {
55 xs *name = actor_name(actor_r);
56
57 if (!xs_is_null(name)) {
58- xs_html *h = xs_html_tag("div",
59- xs_html_attr("class", "snac-origin"),
60- xs_html_tag("a",
61- xs_html_attr("href", xs_dict_get(actor_r, "id")),
62- xs_html_text(name)),
63- xs_html_text(" "),
64- xs_html_text(L("boosted")));
65-
66- xs *s1 = xs_html_render(h);
67-
68- s = xs_str_cat(s, s1);
69+ xs_html_add(post_header,
70+ xs_html_tag("div",
71+ xs_html_attr("class", "snac-origin"),
72+ xs_html_tag("a",
73+ xs_html_attr("href", xs_dict_get(actor_r, "id")),
74+ xs_html_text(name)),
75+ xs_html_text(" "),
76+ xs_html_text(L("boosted"))));
77 }
78 }
79 }
80@@ -1391,29 +1384,29 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
81 char *parent = xs_dict_get(msg, "inReplyTo");
82
83 if (user && !xs_is_null(parent) && *parent && !timeline_here(user, parent)) {
84- xs_html *h = xs_html_tag("div",
85- xs_html_attr("class", "snac-origin"),
86- xs_html_text(L("in reply to")),
87- xs_html_text(" "),
88- xs_html_tag("a",
89- xs_html_attr("href", parent),
90- xs_html_text("»")));
91-
92- xs *s1 = xs_html_render(h);
93-
94- s = xs_str_cat(s, s1);
95+ xs_html_add(post_header,
96+ xs_html_tag("div",
97+ xs_html_attr("class", "snac-origin"),
98+ xs_html_text(L("in reply to")),
99+ xs_html_text(" "),
100+ xs_html_tag("a",
101+ xs_html_attr("href", parent),
102+ xs_html_text("»"))));
103 }
104 }
105 }
106
107+ xs_html_add(post_header,
108+ html_msg_icon(msg));
109+
110 {
111- xs_html *h = html_msg_icon(msg);
112- xs *s1 = xs_html_render(h);
113+ xs *s1 = xs_html_render(post_header);
114 s = xs_str_cat(s, s1);
115 }
116
117- /* add the content */
118- s = xs_str_cat(s, "</div>\n<div class=\"e-content snac-content\">\n"); /** **/
119+ /** post content **/
120+
121+ s = xs_str_cat(s, "\n<div class=\"e-content snac-content\">\n"); /** **/
122
123 if (!xs_is_null(v = xs_dict_get(msg, "name"))) {
124 xs *es1 = encode_html(v);