diff options
| author | 2022-11-19 06:15:35 +0100 | |
|---|---|---|
| committer | 2022-11-19 06:15:35 +0100 | |
| commit | 50d73a6e94c528693155466d4b5c374939fe20f5 (patch) | |
| tree | 1044612e7cfe6699cbf3e96be1210e1bcabe8a7a /html.c | |
| parent | Merge branch 'master' of /home/angel/git/snac2 (diff) | |
| download | snac2-50d73a6e94c528693155466d4b5c374939fe20f5.tar.gz snac2-50d73a6e94c528693155466d4b5c374939fe20f5.tar.xz snac2-50d73a6e94c528693155466d4b5c374939fe20f5.zip | |
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 * | |||
| 1098 | /* public timeline in RSS format */ | 1098 | /* public timeline in RSS format */ |
| 1099 | d_char *rss; | 1099 | d_char *rss; |
| 1100 | xs *elems = local_list(&snac, 20); | 1100 | xs *elems = local_list(&snac, 20); |
| 1101 | xs *bio = not_really_markdown(xs_dict_get(snac.config, "bio")); | ||
| 1101 | char *p, *v; | 1102 | char *p, *v; |
| 1102 | 1103 | ||
| 1104 | /* escape tags */ | ||
| 1105 | bio = xs_replace_i(bio, "<", "<"); | ||
| 1106 | bio = xs_replace_i(bio, ">", ">"); | ||
| 1107 | |||
| 1103 | rss = xs_fmt( | 1108 | rss = xs_fmt( |
| 1104 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" | 1109 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
| 1105 | "<rss version=\"0.91\">\n" | 1110 | "<rss version=\"0.91\">\n" |
| 1106 | "<channel>\n" | 1111 | "<channel>\n" |
| 1107 | "<title>%s</title>\n" | 1112 | "<title>%s (@%s@%s)</title>\n" |
| 1108 | "<language>en</language>\n" | 1113 | "<language>en</language>\n" |
| 1109 | "<link>%s.rss</link>\n" | 1114 | "<link>%s.rss</link>\n" |
| 1110 | "<description>%s</description>\n", | 1115 | "<description>%s</description>\n", |
| 1116 | xs_dict_get(snac.config, "name"), | ||
| 1117 | snac.uid, | ||
| 1118 | xs_dict_get(srv_config, "host"), | ||
| 1111 | snac.actor, | 1119 | snac.actor, |
| 1112 | snac.actor, | 1120 | bio |
| 1113 | snac.actor | ||
| 1114 | ); | 1121 | ); |
| 1115 | 1122 | ||
| 1116 | p = elems; | 1123 | p = elems; |
| @@ -1122,30 +1129,19 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char * | |||
| 1122 | continue; | 1129 | continue; |
| 1123 | 1130 | ||
| 1124 | xs *content = sanitize(xs_dict_get(msg, "content")); | 1131 | xs *content = sanitize(xs_dict_get(msg, "content")); |
| 1125 | xs *title = xs_dup(content); | 1132 | char *title = xs_dict_get(msg, "published"); |
| 1126 | 1133 | ||
| 1127 | /* escape tags */ | 1134 | /* escape tags */ |
| 1128 | content = xs_replace_i(content, "<", "<"); | 1135 | content = xs_replace_i(content, "<", "<"); |
| 1129 | content = xs_replace_i(content, ">", ">"); | 1136 | content = xs_replace_i(content, ">", ">"); |
| 1130 | 1137 | ||
| 1131 | /* cut title in the first tag start */ | ||
| 1132 | if ((v = strchr(title, '<'))) | ||
| 1133 | *v = '\0'; | ||
| 1134 | if ((v = strchr(title, '&'))) | ||
| 1135 | *v = '\0'; | ||
| 1136 | |||
| 1137 | if (strlen(title) > 40) { | ||
| 1138 | title = xs_crop(title, 0, 40); | ||
| 1139 | title = xs_str_cat(title, "..."); | ||
| 1140 | } | ||
| 1141 | |||
| 1142 | xs *s = xs_fmt( | 1138 | xs *s = xs_fmt( |
| 1143 | "<item>\n" | 1139 | "<item>\n" |
| 1144 | "<title>%s</title>\n" | 1140 | "<title>%s</title>\n" |
| 1145 | "<link>%s</link>\n" | 1141 | "<link>%s</link>\n" |
| 1146 | "<description>%s</description>\n" | 1142 | "<description>%s</description>\n" |
| 1147 | "</item>\n", | 1143 | "</item>\n", |
| 1148 | *title ? title : "...", id, content | 1144 | xs_is_null(title) ? "..." : title, id, content |
| 1149 | ); | 1145 | ); |
| 1150 | 1146 | ||
| 1151 | rss = xs_str_cat(rss, s); | 1147 | rss = xs_str_cat(rss, s); |