mirror of
https://github.com/rystaf/mlmym.git
synced 2024-11-04 22:33:15 +00:00
fix youtube autoexpand
This commit is contained in:
parent
1347a2e949
commit
5ab5047ba7
|
@ -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"
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
</a>
|
||||
({{ domain . }})
|
||||
</div>
|
||||
<div class="expando-button{{ if and (not (and .Post.Body.IsValid .Post.Body.String )) (not (isImage .Post.URL.String)) }} hidden{{else if eq .Rank 0}} open{{ end }}"></div>
|
||||
<div class="expando-button{{ if and (not (and .Post.Body.IsValid .Post.Body.String )) (not (isImage .Post.URL.String)) (not (isYoutube .Post.URL.String)) }} hidden{{else if eq .Rank 0}} open{{ end }}"></div>
|
||||
<div class="meta">
|
||||
submitted
|
||||
<span title="{{.Post.Published.Time}}">{{ humanize .Post.Published.Time -}}</span>
|
||||
|
|
Loading…
Reference in a new issue