mirror of
https://github.com/rystaf/mlmym.git
synced 2024-11-05 06:43:21 +00:00
fix youtube autoexpand
This commit is contained in:
parent
1347a2e949
commit
5ab5047ba7
|
@ -123,6 +123,13 @@ var funcMap = template.FuncMap{
|
||||||
}
|
}
|
||||||
return false
|
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 {
|
"thumbnail": func(p lemmy.Post) string {
|
||||||
if p.ThumbnailURL.IsValid() {
|
if p.ThumbnailURL.IsValid() {
|
||||||
return p.ThumbnailURL.String() + "?format=jpg&thumbnail=96"
|
return p.ThumbnailURL.String() + "?format=jpg&thumbnail=96"
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
</a>
|
</a>
|
||||||
({{ domain . }})
|
({{ domain . }})
|
||||||
</div>
|
</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">
|
<div class="meta">
|
||||||
submitted
|
submitted
|
||||||
<span title="{{.Post.Published.Time}}">{{ humanize .Post.Published.Time -}}</span>
|
<span title="{{.Post.Published.Time}}">{{ humanize .Post.Published.Time -}}</span>
|
||||||
|
|
Loading…
Reference in a new issue