From 5ab5047ba77093a3f4198b42ff421be85c8d2ea9 Mon Sep 17 00:00:00 2001 From: Ryan Stafford Date: Fri, 19 Apr 2024 22:49:22 -0400 Subject: [PATCH] fix youtube autoexpand --- routes.go | 7 +++++++ templates/post.html | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/routes.go b/routes.go index 937084c..2f6977d 100644 --- a/routes.go +++ b/routes.go @@ -123,6 +123,13 @@ var funcMap = template.FuncMap{ } return false }, + "isYoutube": func(u string) bool { + re := regexp.MustCompile(`^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube(-nocookie)?\.com|youtu.be))(\/(?:[\w\-]+\?v=|embed\/|live\/|v\/)?)([\w\-]+)(\S+)?$`) + if re.MatchString(u) { + return true + } + return false + }, "thumbnail": func(p lemmy.Post) string { if p.ThumbnailURL.IsValid() { return p.ThumbnailURL.String() + "?format=jpg&thumbnail=96" diff --git a/templates/post.html b/templates/post.html index 5add8e3..b3f65b4 100644 --- a/templates/post.html +++ b/templates/post.html @@ -41,7 +41,7 @@ ({{ domain . }}) -
+
submitted {{ humanize .Post.Published.Time -}}