Add dynamic favicon for trust center using file API
Use the trust center's logo as favicon via the public file API URL, falling back to the default favicon when no logo is configured. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
<link rel="icon" type="image/png" href="/favicons/favicon-32x32.png" sizes="32x32" />
|
<link rel="icon" type="image/png" href="/favicons/favicon-32x32.png" sizes="32x32" />
|
||||||
<link rel="icon" type="image/png" href="/favicons/favicon-16x16.png" sizes="16x16" />
|
<link rel="icon" type="image/png" href="/favicons/favicon-16x16.png" sizes="16x16" />
|
||||||
<link rel="icon" type="image/png" href="/favicons/favicon-128.png" sizes="128x128" /> -->
|
<link rel="icon" type="image/png" href="/favicons/favicon-128.png" sizes="128x128" /> -->
|
||||||
<link rel="icon" id="favicon" href="/favicons/favicon.ico">
|
<link rel="icon" id="favicon" href="{{if .FaviconURL}}{{.FaviconURL}}{{else}}/favicons/favicon.ico{{end}}">
|
||||||
|
|
||||||
<meta name="application-name" content=" " />
|
<meta name="application-name" content=" " />
|
||||||
<meta name="msapplication-TileColor" content="#FFFFFF" />
|
<meta name="msapplication-TileColor" content="#FFFFFF" />
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ func NewServer(cfg Config) (*Server, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
trustWebServer, err := trust_web.NewServer(compliancePageHeadData(cfg.Trust))
|
trustWebServer, err := trust_web.NewServer(compliancePageHeadData(cfg.BaseURL, cfg.Trust))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ func (s *Server) TrustCenterHandler() http.Handler {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func compliancePageHeadData(trustService *trust.Service) trust_web.HeadDataFunc {
|
func compliancePageHeadData(baseURL *baseurl.BaseURL, trustService *trust.Service) trust_web.HeadDataFunc {
|
||||||
return func(r *http.Request) trust_web.HeadData {
|
return func(r *http.Request) trust_web.HeadData {
|
||||||
tc := compliancepage.CompliancePageFromContext(r.Context())
|
tc := compliancepage.CompliancePageFromContext(r.Context())
|
||||||
if tc == nil {
|
if tc == nil {
|
||||||
@@ -209,12 +209,21 @@ func compliancePageHeadData(trustService *trust.Service) trust_web.HeadDataFunc
|
|||||||
return trust_web.HeadData{Title: "Compliance Page"}
|
return trust_web.HeadData{Title: "Compliance Page"}
|
||||||
}
|
}
|
||||||
|
|
||||||
baseURL := compliancepage.CompliancePageBaseURLFromContext(r.Context())
|
compliancePageBaseURL := compliancepage.CompliancePageBaseURLFromContext(r.Context())
|
||||||
|
|
||||||
return trust_web.HeadData{
|
headData := trust_web.HeadData{
|
||||||
Title: org.Name + " — Compliance",
|
Title: org.Name + " — Compliance",
|
||||||
Description: org.Name + " Compliance Page",
|
Description: org.Name + " Compliance Page",
|
||||||
OGURL: ref.UnrefOrZero(baseURL),
|
OGURL: ref.UnrefOrZero(compliancePageBaseURL),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if tc.LogoFileID != nil {
|
||||||
|
faviconURL, err := baseURL.WithPath("/api/files/v1/" + tc.LogoFileID.String()).String()
|
||||||
|
if err == nil {
|
||||||
|
headData.FaviconURL = faviconURL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return headData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ type (
|
|||||||
Title string
|
Title string
|
||||||
Description string
|
Description string
|
||||||
OGURL string
|
OGURL string
|
||||||
|
FaviconURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
HeadDataFunc func(r *http.Request) HeadData
|
HeadDataFunc func(r *http.Request) HeadData
|
||||||
|
|||||||
Reference in New Issue
Block a user