summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2020-05-13 08:16:43 +0200
committerRicardo Wurmus <rekado@elephly.net>2020-05-13 08:16:43 +0200
commit05f00635785438b50abe1e39559196fa6da62d47 (patch)
tree1680d35b0945415c7cb27e6dbe3f8db04573af13
parent7f675ca5cdf10f4e6b0ec2696a8b81f5301a96b5 (diff)
view/utils: Mark up URLs.
-rw-r--r--mumi/web/view/utils.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/mumi/web/view/utils.scm b/mumi/web/view/utils.scm
index f863528..0735bf5 100644
--- a/mumi/web/view/utils.scm
+++ b/mumi/web/view/utils.scm
@@ -31,6 +31,7 @@
#:use-module (email email)
#:use-module (mumi messages)
#:use-module (rnrs bytevectors)
+ #:use-module (web uri)
#:export (prettify
avatar-color
display-message-body
@@ -111,6 +112,22 @@ with the next context."
(else 'text)))
(formatted-line
(cond
+ ((or (string-contains line "https://")
+ (string-contains line "http://")) =>
+ (lambda (index)
+ (let* ((pre (string-take line index))
+ (post (string-drop line index))
+ (uri+ (string-split post (char-set #\< #\> #\space))))
+ (match uri+
+ ((uri-string . rest)
+ (or (and=> (string->uri uri-string)
+ (lambda (uri)
+ `(span (@ (class "line"))
+ ,(string-trim-right pre #\<)
+ (a (@ (href ,uri-string))
+ ,uri-string)
+ ,@rest)))
+ `(span (@ (class "line")) ,line)))))))
((or (string-prefix? "Signed-off-by" line)
(string-prefix? "Co-authored-by" line))
`(span (@ (class "line commit attribution")) ,line))