diff options
author | 2023-02-25 09:36:19 +0100 | |
---|---|---|
committer | 2023-02-25 15:57:59 -0800 | |
commit | 2c2700a31d7349f67016a3786125597f9ee38c56 (patch) | |
tree | 9a9cef0c5d6a17946be70e709cf1d0349d05bc77 /template/functions.go | |
parent | 8f9ccc6540be9d637b812985936f064bada8fcf3 (diff) | |
download | v2-2c2700a31d7349f67016a3786125597f9ee38c56.tar.gz v2-2c2700a31d7349f67016a3786125597f9ee38c56.tar.zst v2-2c2700a31d7349f67016a3786125597f9ee38c56.zip |
Proxy support for several media types
closes #615
closes #635
Diffstat (limited to '')
-rw-r--r-- | template/functions.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/template/functions.go b/template/functions.go index 92b482e9..fd2b44a7 100644 --- a/template/functions.go +++ b/template/functions.go @@ -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) }, |