commit 9acba48
default
·
2024-05-11 17:35:33 +0000 UTC
parent 0a11d70
Add some special treatment to Event object display.
M
format.c
+1,
-0
1@@ -311,6 +311,7 @@ xs_str *sanitize(const char *content)
2
3 s = xs_str_cat(s, s2);
4 } else {
5+ /* treat end of divs as paragraph breaks */
6 if (strcmp(v, "</div>"))
7 s = xs_str_cat(s, "<p>");
8 }
M
html.c
+16,
-2
1@@ -1374,6 +1374,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2 char *type = xs_dict_get(msg, "type");
3 char *actor;
4 char *v;
5+ int has_title = 0;
6
7 /* do not show non-public messages in the public timeline */
8 if ((read_only || !user) && !is_msg_public(msg))
9@@ -1484,6 +1485,14 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
10 }
11 }
12
13+ if (strcmp(type, "Event") == 0) {
14+ /* add the calendar emoji */
15+ xs_html_add(score,
16+ xs_html_tag("span",
17+ xs_html_attr("title", L("Event")),
18+ xs_html_raw(" 📅 ")));
19+ }
20+
21 /* if it's a user from this same instance, add the score */
22 if (xs_startswith(id, srv_baseurl)) {
23 int n_likes = object_likes_len(id);
24@@ -1575,11 +1584,13 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
25 xs_html_add(entry,
26 snac_content_wrap);
27
28- if (!xs_is_null(v = xs_dict_get(msg, "name"))) {
29+ if (!has_title && !xs_is_null(v = xs_dict_get(msg, "name"))) {
30 xs_html_add(snac_content_wrap,
31 xs_html_tag("h3",
32 xs_html_attr("class", "snac-entry-title"),
33 xs_html_text(v)));
34+
35+ has_title = 1;
36 }
37
38 xs_html *snac_content = NULL;
39@@ -1604,12 +1615,15 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
40 }
41 else {
42 /* print the summary as a header (sites like e.g. Friendica can contain one) */
43- if (!xs_is_null(v) && *v)
44+ if (!has_title && !xs_is_null(v) && *v) {
45 xs_html_add(snac_content_wrap,
46 xs_html_tag("h3",
47 xs_html_attr("class", "snac-entry-title"),
48 xs_html_text(v)));
49
50+ has_title = 1;
51+ }
52+
53 snac_content = xs_html_tag("div", NULL);
54 }
55