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

Inline some templating functions

This commit is contained in:
jvoisin 2024-02-27 20:39:39 +01:00 committed by Frédéric Guillot
parent 5a7d6f8997
commit 6b3b8e8c9b

View file

@ -36,12 +36,8 @@ func (f *funcMap) Map() template.FuncMap {
"hasKey": hasKey, "hasKey": hasKey,
"truncate": truncate, "truncate": truncate,
"isEmail": isEmail, "isEmail": isEmail,
"baseURL": func() string { "baseURL": config.Opts.BaseURL,
return config.Opts.BaseURL() "rootURL": config.Opts.RootURL,
},
"rootURL": func() string {
return config.Opts.RootURL()
},
"hasOAuth2Provider": func(provider string) bool { "hasOAuth2Provider": func(provider string) bool {
return config.Opts.OAuth2Provider() == provider return config.Opts.OAuth2Provider() == provider
}, },
@ -75,24 +71,16 @@ func (f *funcMap) Map() template.FuncMap {
"mustBeProxyfied": func(mediaType string) bool { "mustBeProxyfied": func(mediaType string) bool {
return slices.Contains(config.Opts.ProxyMediaTypes(), mediaType) return slices.Contains(config.Opts.ProxyMediaTypes(), mediaType)
}, },
"domain": func(websiteURL string) string { "domain": urllib.Domain,
return urllib.Domain(websiteURL) "hasPrefix": strings.HasPrefix,
}, "contains": strings.Contains,
"hasPrefix": func(str, prefix string) bool {
return strings.HasPrefix(str, prefix)
},
"contains": func(str, substr string) bool {
return strings.Contains(str, substr)
},
"replace": func(str, old, new string) string { "replace": func(str, old, new string) string {
return strings.Replace(str, old, new, 1) return strings.Replace(str, old, new, 1)
}, },
"isodate": func(ts time.Time) string { "isodate": func(ts time.Time) string {
return ts.Format("2006-01-02 15:04:05") return ts.Format("2006-01-02 15:04:05")
}, },
"theme_color": func(theme, colorScheme string) string { "theme_color": model.ThemeColor,
return model.ThemeColor(theme, colorScheme)
},
"icon": func(iconName string) template.HTML { "icon": func(iconName string) template.HTML {
return template.HTML(fmt.Sprintf( return template.HTML(fmt.Sprintf(
`<svg class="icon" aria-hidden="true"><use xlink:href="%s#icon-%s"/></svg>`, `<svg class="icon" aria-hidden="true"><use xlink:href="%s#icon-%s"/></svg>`,