summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--format.c27
-rw-r--r--html.c2
2 files changed, 26 insertions, 3 deletions
diff --git a/format.c b/format.c
index b2b585d..525edb0 100644
--- a/format.c
+++ b/format.c
@@ -154,10 +154,22 @@ static xs_str *format_line(const char *line, xs_list **attach)
154 xs *l = xs_split_n(w, "](", 1); 154 xs *l = xs_split_n(w, "](", 1);
155 155
156 if (xs_list_len(l) == 2) { 156 if (xs_list_len(l) == 2) {
157 xs *link = xs_fmt("<a href=\"%s\">%s</a>", 157 const char *name = xs_list_get(l, 0);
158 xs_list_get(l, 1), xs_list_get(l, 0)); 158 const char *url = xs_list_get(l, 1);
159
160 xs *link = xs_fmt("<a href=\"%s\">%s</a>", url, name);
159 161
160 s = xs_str_cat(s, link); 162 s = xs_str_cat(s, link);
163
164 /* also add the link as an attachment */
165 xs *d = xs_dict_new();
166
167 d = xs_dict_append(d, "mediaType", "text/html");
168 d = xs_dict_append(d, "url", url);
169 d = xs_dict_append(d, "name", name);
170 d = xs_dict_append(d, "type", "Link");
171
172 *attach = xs_list_append(*attach, d);
161 } 173 }
162 else 174 else
163 s = xs_str_cat(s, v); 175 s = xs_str_cat(s, v);
@@ -208,6 +220,7 @@ static xs_str *format_line(const char *line, xs_list **attach)
208 } 220 }
209 else 221 else
210 if (xs_str_in(v, ":/" "/") != -1) { 222 if (xs_str_in(v, ":/" "/") != -1) {
223 /* direct URLs in the post body */
211 xs *u = xs_replace_i(xs_replace(v, "#", "&#35;"), "@", "&#64;"); 224 xs *u = xs_replace_i(xs_replace(v, "#", "&#35;"), "@", "&#64;");
212 225
213 xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)"); 226 xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)");
@@ -240,6 +253,16 @@ static xs_str *format_line(const char *line, xs_list **attach)
240 else { 253 else {
241 xs *s1 = xs_fmt("<a href=\"%s\" target=\"_blank\">%s</a>", v2, u); 254 xs *s1 = xs_fmt("<a href=\"%s\" target=\"_blank\">%s</a>", v2, u);
242 s = xs_str_cat(s, s1); 255 s = xs_str_cat(s, s1);
256
257 /* also add the link as an attachment */
258 xs *d = xs_dict_new();
259
260 d = xs_dict_append(d, "mediaType", "text/html");
261 d = xs_dict_append(d, "url", v2);
262 d = xs_dict_append(d, "name", "");
263 d = xs_dict_append(d, "type", "Link");
264
265 *attach = xs_list_append(*attach, d);
243 } 266 }
244 } 267 }
245 else 268 else
diff --git a/html.c b/html.c
index 288968d..0652892 100644
--- a/html.c
+++ b/html.c
@@ -2388,7 +2388,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2388 const char *o_href = xs_dict_get(a, "href"); 2388 const char *o_href = xs_dict_get(a, "href");
2389 const char *name = xs_dict_get(a, "name"); 2389 const char *name = xs_dict_get(a, "name");
2390 2390
2391 /* if this image is already in the post content, skip */ 2391 /* if this URL is already in the post content, skip */
2392 if (content && xs_str_in(content, o_href) != -1) 2392 if (content && xs_str_in(content, o_href) != -1)
2393 continue; 2393 continue;
2394 2394