1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-11 17:51:01 +00:00

Proxy support for several media types

closes #615
closes #635
This commit is contained in:
Romain de Laage 2023-02-25 09:36:19 +01:00 committed by Frédéric Guillot
parent 8f9ccc6540
commit 2c2700a31d
20 changed files with 534 additions and 200 deletions

View file

@ -61,17 +61,25 @@ func (f *funcMap) Map() template.FuncMap {
return template.HTML(str)
},
"proxyFilter": func(data string) string {
return proxy.ImageProxyRewriter(f.router, data)
return proxy.ProxyRewriter(f.router, data)
},
"proxyURL": func(link string) string {
proxyImages := config.Opts.ProxyImages()
proxyOption := config.Opts.ProxyOption()
if proxyImages == "all" || (proxyImages != "none" && !url.IsHTTPS(link)) {
if proxyOption == "all" || (proxyOption != "none" && !url.IsHTTPS(link)) {
return proxy.ProxifyURL(f.router, link)
}
return link
},
"mustBeProxyfied": func(mediaType string) bool {
for _, t := range config.Opts.ProxyMediaTypes() {
if t == mediaType {
return true
}
}
return false
},
"domain": func(websiteURL string) string {
return url.Domain(websiteURL)
},

View file

@ -159,18 +159,26 @@
{{ if hasPrefix .MimeType "audio/" }}
<div class="enclosure-audio">
<audio controls preload="metadata">
<source src="{{ .URL | safeURL }}" type="{{ .MimeType }}">
{{ if (and $.user (mustBeProxyfied "audio")) }}
<source src="{{ proxyURL .URL }}" type="{{ .MimeType }}">
{{ else }}
<source src="{{ .URL | safeURL }}" type="{{ .MimeType }}">
{{ end }}
</audio>
</div>
{{ else if hasPrefix .MimeType "video/" }}
<div class="enclosure-video">
<video controls preload="metadata">
<source src="{{ .URL | safeURL }}" type="{{ .MimeType }}">
{{ if (and $.user (mustBeProxyfied "video")) }}
<source src="{{ proxyURL .URL }}" type="{{ .MimeType }}">
{{ else }}
<source src="{{ .URL | safeURL }}" type="{{ .MimeType }}">
{{ end }}
</video>
</div>
{{ else if hasPrefix .MimeType "image/" }}
<div class="enclosure-image">
{{ if $.user }}
{{ if (and $.user (mustBeProxyfied "image")) }}
<img src="{{ proxyURL .URL }}" title="{{ .URL }} ({{ .MimeType }})" loading="lazy" alt="{{ .URL }} ({{ .MimeType }})">
{{ else }}
<img src="{{ .URL | safeURL }}" title="{{ .URL }} ({{ .MimeType }})" loading="lazy" alt="{{ .URL }} ({{ .MimeType }})">