summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2024-12-26 03:55:27 +0100
committerGravatar default2024-12-26 03:55:27 +0100
commit2384a5409bc3a8a6ede4bf33bb1584a6bfae39af (patch)
treec6ba32c4ae336091dbb6ad645e8173241622b67e
parentAccept 'Audio' as a valid entry type. (diff)
downloadpenes-snac2-2384a5409bc3a8a6ede4bf33bb1584a6bfae39af.tar.gz
penes-snac2-2384a5409bc3a8a6ede4bf33bb1584a6bfae39af.tar.xz
penes-snac2-2384a5409bc3a8a6ede4bf33bb1584a6bfae39af.zip
Make xmpp and mailto URLs clickable.
-rw-r--r--format.c13
-rw-r--r--html.c2
2 files changed, 13 insertions, 2 deletions
diff --git a/format.c b/format.c
index 12783ae..41e4162 100644
--- a/format.c
+++ b/format.c
@@ -7,6 +7,7 @@
7#include "xs_html.h" 7#include "xs_html.h"
8#include "xs_json.h" 8#include "xs_json.h"
9#include "xs_time.h" 9#include "xs_time.h"
10#include "xs_match.h"
10 11
11#include "snac.h" 12#include "snac.h"
12 13
@@ -93,7 +94,8 @@ static xs_str *format_line(const char *line, xs_list **attach)
93 "\\*\\*?\\*?[^\\*]+\\*?\\*?\\*" "|" 94 "\\*\\*?\\*?[^\\*]+\\*?\\*?\\*" "|"
94 "!\\[[^]]+\\]\\([^\\)]+\\)" "|" 95 "!\\[[^]]+\\]\\([^\\)]+\\)" "|"
95 "\\[[^]]+\\]\\([^\\)]+\\)" "|" 96 "\\[[^]]+\\]\\([^\\)]+\\)" "|"
96 "[a-z]+:/" "/[^[:space:]]+" 97 "[a-z]+:/" "/[^[:space:]]+" "|"
98 "(mailto|xmpp):[^@[:space:]]+@[^[:space:]]+"
97 ")"); 99 ")");
98 int n = 0; 100 int n = 0;
99 101
@@ -230,6 +232,15 @@ static xs_str *format_line(const char *line, xs_list **attach)
230 } 232 }
231 } 233 }
232 else 234 else
235 if (xs_match(v, "mailto*|xmpp*")) {
236 xs *u = xs_replace_i(xs_replace(v, "#", "#"), "@", "@");
237
238 xs *v2 = xs_strip_chars_i(xs_dup(u), ".,)");
239
240 xs *s1 = xs_fmt("<a href=\"%s\" target=\"_blank\">%s</a>", v2, u);
241 s = xs_str_cat(s, s1);
242 }
243 else
233 s = xs_str_cat(s, v); 244 s = xs_str_cat(s, v);
234 } 245 }
235 else 246 else
diff --git a/html.c b/html.c
index 2c0a823..409023d 100644
--- a/html.c
+++ b/html.c
@@ -934,7 +934,7 @@ static xs_html *html_user_body(snac *user, int read_only)
934 } 934 }
935 } 935 }
936 else 936 else
937 if (xs_startswith(v, "gemini:/")) { 937 if (xs_startswith(v, "gemini:/") || xs_startswith(v, "xmpp:")) {
938 value = xs_html_tag("a", 938 value = xs_html_tag("a",
939 xs_html_attr("rel", "me"), 939 xs_html_attr("rel", "me"),
940 xs_html_attr("href", v), 940 xs_html_attr("href", v),