forked from mystiq/dex
use web host url for asset hosting
Signed-off-by: Rui Yang <ruiya@vmware.com> Co-authored-by: Aidan Oldershaw <aoldershaw@pivotal.io>
This commit is contained in:
parent
10e9054811
commit
1eab25f89f
2 changed files with 10 additions and 2 deletions
|
@ -121,6 +121,9 @@ type WebConfig struct {
|
|||
|
||||
// Map of extra values passed into the templates
|
||||
Extra map[string]string
|
||||
|
||||
// Defaults to issuer URL
|
||||
HostURL string
|
||||
}
|
||||
|
||||
func value(val, defaultValue time.Duration) time.Duration {
|
||||
|
|
|
@ -53,12 +53,17 @@ func loadTemplates(c WebConfig, issuerPath string) (*templates, error) {
|
|||
c.LogoURL = "theme/logo.png"
|
||||
}
|
||||
|
||||
hostURL := issuerPath
|
||||
if c.HostURL != "" {
|
||||
hostURL = c.HostURL
|
||||
}
|
||||
|
||||
funcs := template.FuncMap{
|
||||
"issuer": func() string { return c.Issuer },
|
||||
"logo": func() string { return c.LogoURL },
|
||||
"url": func(reqPath, assetPath string) string { return relativeURL(issuerPath, reqPath, assetPath) },
|
||||
"url": func(reqPath, assetPath string) string { return relativeURL(hostURL, reqPath, assetPath) },
|
||||
"theme": func(reqPath, assetPath string) string {
|
||||
return relativeURL(issuerPath, reqPath, path.Join("themes", c.Theme, assetPath))
|
||||
return relativeURL(hostURL, reqPath, path.Join("themes", c.Theme, assetPath))
|
||||
},
|
||||
"lower": strings.ToLower,
|
||||
"extra": func(k string) string { return c.Extra[k] },
|
||||
|
|
Loading…
Reference in a new issue