commit 50d73a6

default  ·  2022-11-19 05:15:35 +0000 UTC
parent 3598e61
RSS improvements.
1 files changed,  +12, -16
M html.c
M html.c
+12, -16
 1@@ -1098,19 +1098,26 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
 2         /* public timeline in RSS format */
 3         d_char *rss;
 4         xs *elems = local_list(&snac, 20);
 5+        xs *bio   = not_really_markdown(xs_dict_get(snac.config, "bio"));
 6         char *p, *v;
 7 
 8+        /* escape tags */
 9+        bio = xs_replace_i(bio, "<", "&lt;");
10+        bio = xs_replace_i(bio, ">", "&gt;");
11+
12         rss = xs_fmt(
13             "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
14             "<rss version=\"0.91\">\n"
15             "<channel>\n"
16-            "<title>%s</title>\n"
17+            "<title>%s (@%s@%s)</title>\n"
18             "<language>en</language>\n"
19             "<link>%s.rss</link>\n"
20             "<description>%s</description>\n",
21+            xs_dict_get(snac.config, "name"),
22+            snac.uid,
23+            xs_dict_get(srv_config, "host"),
24             snac.actor,
25-            snac.actor,
26-            snac.actor
27+            bio
28         );
29 
30         p = elems;
31@@ -1122,30 +1129,19 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
32                 continue;
33 
34             xs *content = sanitize(xs_dict_get(msg, "content"));
35-            xs *title   = xs_dup(content);
36+            char *title = xs_dict_get(msg, "published");
37 
38             /* escape tags */
39             content = xs_replace_i(content, "<", "&lt;");
40             content = xs_replace_i(content, ">", "&gt;");
41 
42-            /* cut title in the first tag start */
43-            if ((v = strchr(title, '<')))
44-                *v = '\0';
45-            if ((v = strchr(title, '&')))
46-                *v = '\0';
47-
48-            if (strlen(title) > 40) {
49-                title = xs_crop(title, 0, 40);
50-                title = xs_str_cat(title, "...");
51-            }
52-
53             xs *s = xs_fmt(
54                 "<item>\n"
55                 "<title>%s</title>\n"
56                 "<link>%s</link>\n"
57                 "<description>%s</description>\n"
58                 "</item>\n",
59-                *title ? title : "...", id, content
60+                xs_is_null(title) ? "..." : title, id, content
61             );
62 
63             rss = xs_str_cat(rss, s);