mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-25 16:53:37 +00:00
RSS improvements.
This commit is contained in:
parent
3598e61d74
commit
50d73a6e94
1 changed files with 12 additions and 16 deletions
28
html.c
28
html.c
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue