mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
More RSS tweaks.
This commit is contained in:
parent
50d73a6e94
commit
86aa0ff4b6
1 changed files with 15 additions and 2 deletions
17
html.c
17
html.c
|
@ -1129,19 +1129,32 @@ 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"));
|
||||
char *title = xs_dict_get(msg, "published");
|
||||
xs *title = xs_dup(content);
|
||||
int i = -1;
|
||||
|
||||
/* escape tags */
|
||||
content = xs_replace_i(content, "<", "<");
|
||||
content = xs_replace_i(content, ">", ">");
|
||||
|
||||
if (strlen(title) > 40)
|
||||
title[i = 40] = '\0';
|
||||
|
||||
if ((v = strchr(title, '<')))
|
||||
title[i = (v - title)] = '\0';
|
||||
|
||||
if ((v = strchr(title, '&')))
|
||||
title[i = (v - title)] = '\0';
|
||||
|
||||
if (i != -1)
|
||||
title = xs_str_cat(xs_strip(title), "...");
|
||||
|
||||
xs *s = xs_fmt(
|
||||
"<item>\n"
|
||||
"<title>%s</title>\n"
|
||||
"<link>%s</link>\n"
|
||||
"<description>%s</description>\n"
|
||||
"</item>\n",
|
||||
xs_is_null(title) ? "..." : title, id, content
|
||||
title, id, content
|
||||
);
|
||||
|
||||
rss = xs_str_cat(rss, s);
|
||||
|
|
Loading…
Reference in a new issue