diff options
| author | 2022-11-20 06:16:45 +0100 | |
|---|---|---|
| committer | 2022-11-20 06:16:45 +0100 | |
| commit | ecff88922f62634bbe6e466f30153ca119ec5061 (patch) | |
| tree | 4a0b364dbd4a3dfbf4cdfc4e89e4f9baad251185 /html.c | |
| parent | Fixed RSS link. (diff) | |
| download | snac2-ecff88922f62634bbe6e466f30153ca119ec5061.tar.gz snac2-ecff88922f62634bbe6e466f30153ca119ec5061.tar.xz snac2-ecff88922f62634bbe6e466f30153ca119ec5061.zip | |
More RSS tweaks.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 19 |
1 files changed, 5 insertions, 14 deletions
| @@ -1129,8 +1129,8 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char * | |||
| 1129 | continue; | 1129 | continue; |
| 1130 | 1130 | ||
| 1131 | xs *content = sanitize(xs_dict_get(msg, "content")); | 1131 | xs *content = sanitize(xs_dict_get(msg, "content")); |
| 1132 | xs *title = xs_dup(content); | 1132 | xs *title = xs_str_new(NULL); |
| 1133 | int i = -1; | 1133 | int i; |
| 1134 | 1134 | ||
| 1135 | /* add the post link */ | 1135 | /* add the post link */ |
| 1136 | xs *l = xs_fmt("<p><a href=\"%s\">%s</a><p>", id, id); | 1136 | xs *l = xs_fmt("<p><a href=\"%s\">%s</a><p>", id, id); |
| @@ -1140,21 +1140,12 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char * | |||
| 1140 | content = xs_replace_i(content, "<", "<"); | 1140 | content = xs_replace_i(content, "<", "<"); |
| 1141 | content = xs_replace_i(content, ">", ">"); | 1141 | content = xs_replace_i(content, ">", ">"); |
| 1142 | 1142 | ||
| 1143 | if (strlen(title) > 40) | 1143 | for (i = 0; content[i] && content[i] != '<' && content[i] != '&' && i < 40; i++) |
| 1144 | title = xs_crop(title, 0, i = 40); | 1144 | title = xs_append_m(title, &content[i], 1); |
| 1145 | |||
| 1146 | if ((v = strchr(title, '<'))) | ||
| 1147 | title = xs_crop(title, 0, i = (v - title)); | ||
| 1148 | |||
| 1149 | if ((v = strchr(title, '&'))) | ||
| 1150 | title = xs_crop(title, 0, i = (v - title)); | ||
| 1151 | |||
| 1152 | if (i != -1) | ||
| 1153 | title = xs_str_cat(xs_strip(title), "..."); | ||
| 1154 | 1145 | ||
| 1155 | xs *s = xs_fmt( | 1146 | xs *s = xs_fmt( |
| 1156 | "<item>\n" | 1147 | "<item>\n" |
| 1157 | "<title>%s</title>\n" | 1148 | "<title>%s...</title>\n" |
| 1158 | "<link>%s</link>\n" | 1149 | "<link>%s</link>\n" |
| 1159 | "<description>%s</description>\n" | 1150 | "<description>%s</description>\n" |
| 1160 | "</item>\n", | 1151 | "</item>\n", |