commit cac8eba

default  ·  2023-11-27 09:27:28 +0000 UTC
parent 1663adb
html_msg_icon() is full xs_html.
1 files changed,  +19, -15
M html.c
M html.c
+19, -15
 1@@ -200,10 +200,11 @@ xs_html *html_actor_icon(xs_dict *actor, const char *date,
 2 }
 3 
 4 
 5-xs_str *html_msg_icon(xs_str *os, const xs_dict *msg)
 6+xs_html *html_msg_icon(const xs_dict *msg)
 7 {
 8     char *actor_id;
 9     xs *actor = NULL;
10+    xs_html *actor_icon = NULL;
11 
12     if ((actor_id = xs_dict_get(msg, "attributedTo")) == NULL)
13         actor_id = xs_dict_get(msg, "actor");
14@@ -223,12 +224,10 @@ xs_str *html_msg_icon(xs_str *os, const xs_dict *msg)
15         date  = xs_dict_get(msg, "published");
16         udate = xs_dict_get(msg, "updated");
17 
18-        xs_html *actor_icon = html_actor_icon(actor, date, udate, url, priv);
19-        xs *s1 = xs_html_render(actor_icon);
20-        os = xs_str_cat(os, s1);
21+        actor_icon = html_actor_icon(actor, date, udate, url, priv);
22     }
23 
24-    return os;
25+    return actor_icon;
26 }
27 
28 
29@@ -1180,16 +1179,17 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
30     }
31 
32     if (strcmp(type, "Follow") == 0) {
33-        s = xs_str_cat(s, "<div class=\"snac-post\">\n<div class=\"snac-post-header\">\n");
34-
35-        xs *s1 = xs_fmt("<div class=\"snac-origin\">%s</div>\n", L("follows you"));
36-        s = xs_str_cat(s, s1);
37-
38-        s = html_msg_icon(s, msg);
39-
40-        s = xs_str_cat(s, "</div>\n</div>\n");
41+        xs_html *h = xs_html_tag("div",
42+            xs_html_attr("class", "snac-post"),
43+            xs_html_tag("div",
44+                xs_html_attr("class", "snac-post-header"),
45+                xs_html_tag("div",
46+                    xs_html_attr("class", "snac-origin"),
47+                    xs_html_text(L("follows you"))),
48+                html_msg_icon(msg)));
49 
50-        return xs_str_cat(os, s);
51+        xs *s1 = xs_html_render(h);
52+        return xs_str_cat(os, s1);
53     }
54     else
55     if (!xs_match(type, "Note|Question|Page|Article")) {
56@@ -1306,7 +1306,11 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
57         }
58     }
59 
60-    s = html_msg_icon(s, msg);
61+    {
62+        xs_html *h = html_msg_icon(msg);
63+        xs *s1 = xs_html_render(h);
64+        s = xs_str_cat(s, s1);
65+    }
66 
67     /* add the content */
68     s = xs_str_cat(s, "</div>\n<div class=\"e-content snac-content\">\n"); /** **/