diff options
author | default <nobody@localhost> | 2022-11-19 06:15:35 +0100 |
---|---|---|
committer | default <nobody@localhost> | 2022-11-19 06:15:35 +0100 |
commit | 50d73a6e94c528693155466d4b5c374939fe20f5 (patch) | |
tree | 1044612e7cfe6699cbf3e96be1210e1bcabe8a7a /html.c | |
parent | 3598e61d742ae7a8d43659ee4e63152cc328433d (diff) |
RSS improvements.
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 28 |
1 files changed, 12 insertions, 16 deletions
@@ -1098,19 +1098,26 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char * /* public timeline in RSS format */ d_char *rss; xs *elems = local_list(&snac, 20); + xs *bio = not_really_markdown(xs_dict_get(snac.config, "bio")); char *p, *v; + /* escape tags */ + bio = xs_replace_i(bio, "<", "<"); + bio = xs_replace_i(bio, ">", ">"); + rss = xs_fmt( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<rss version=\"0.91\">\n" "<channel>\n" - "<title>%s</title>\n" + "<title>%s (@%s@%s)</title>\n" "<language>en</language>\n" "<link>%s.rss</link>\n" "<description>%s</description>\n", + xs_dict_get(snac.config, "name"), + snac.uid, + xs_dict_get(srv_config, "host"), snac.actor, - snac.actor, - snac.actor + bio ); p = elems; @@ -1122,30 +1129,19 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char * continue; xs *content = sanitize(xs_dict_get(msg, "content")); - xs *title = xs_dup(content); + char *title = xs_dict_get(msg, "published"); /* escape tags */ content = xs_replace_i(content, "<", "<"); content = xs_replace_i(content, ">", ">"); - /* cut title in the first tag start */ - if ((v = strchr(title, '<'))) - *v = '\0'; - if ((v = strchr(title, '&'))) - *v = '\0'; - - if (strlen(title) > 40) { - title = xs_crop(title, 0, 40); - title = xs_str_cat(title, "..."); - } - xs *s = xs_fmt( "<item>\n" "<title>%s</title>\n" "<link>%s</link>\n" "<description>%s</description>\n" "</item>\n", - *title ? title : "...", id, content + xs_is_null(title) ? "..." : title, id, content ); rss = xs_str_cat(rss, s); |