diff --git a/docs/full-configuration.md b/docs/full-configuration.md index 4ff75d1a075ee64ab290a3c488700eae4faea27d..2750a812dd55af2d2bbbd0b68aaa47e253321fd7 100644 --- a/docs/full-configuration.md +++ b/docs/full-configuration.md @@ -359,7 +359,7 @@ The configuration file contains the following sections: - `logo_path`, string. Path to your logo relative to `static_files_path`. The preferred image size is 256x256 pixel - `login_image_path`, string. Path to a custom image to show on the login screen relative to `static_files_path`. The preferred image size is 900x900 pixel - `disclaimer_name`, string. Name for your optional disclaimer - - `disclaimer_path`, string. Path to the HTML page with the disclaimer relative to `static_files_path` + - `disclaimer_path`, string. Path to the HTML page with the disclaimer relative to `static_files_path` or an absolute URL (http or https). - `default_css`, list of strings. Optional path to custom CSS files, relative to `static_files_path`, which replaces the default CSS - `extra_css`, list of strings. Defines the paths, relative to `static_files_path`, to additional CSS files - `templates_path`, string. Path to the HTML web templates. This can be an absolute path or a path relative to the config dir diff --git a/internal/httpd/httpd.go b/internal/httpd/httpd.go index 681dde9d93f928759097e9b423bcdd36d6632128..8241ab9d7b19ad2667fb51ae31d4c7f2ba51b9db 100644 --- a/internal/httpd/httpd.go +++ b/internal/httpd/httpd.go @@ -405,7 +405,8 @@ type UIBranding struct { FaviconPath string `json:"favicon_path" mapstructure:"favicon_path"` // DisclaimerName defines the name for the link to your optional disclaimer DisclaimerName string `json:"disclaimer_name" mapstructure:"disclaimer_name"` - // Path to the HTML page for your disclaimer relative to "static_files_path". + // Path to the HTML page for your disclaimer relative to "static_files_path" + // or an absolute http/https URL. DisclaimerPath string `json:"disclaimer_path" mapstructure:"disclaimer_path"` // Path to custom CSS files, relative to "static_files_path", which replaces // the default CSS files @@ -431,7 +432,9 @@ func (b *UIBranding) check(isWebClient bool) { b.FaviconPath = "/favicon.ico" } if b.DisclaimerPath != "" { - b.DisclaimerPath = util.CleanPath(b.DisclaimerPath) + if !strings.HasPrefix(b.DisclaimerPath, "https://") && !strings.HasPrefix(b.DisclaimerPath, "http://") { + b.DisclaimerPath = path.Join(webStaticFilesPath, util.CleanPath(b.DisclaimerPath)) + } } if len(b.DefaultCSS) > 0 { for idx := range b.DefaultCSS { @@ -1111,6 +1114,8 @@ func updateWebClientURLs(baseURL string) { webClientViewPDFPath = path.Join(baseURL, webClientViewPDFPathDefault) webClientGetPDFPath = path.Join(baseURL, webClientGetPDFPathDefault) webClientExistPath = path.Join(baseURL, webClientExistPathDefault) + webStaticFilesPath = path.Join(baseURL, webStaticFilesPathDefault) + webOpenAPIPath = path.Join(baseURL, webOpenAPIPathDefault) } func updateWebAdminURLs(baseURL string) { diff --git a/internal/httpd/internal_test.go b/internal/httpd/internal_test.go index 272f022e5fa164140e14c15f3981b29849484798..5b6e3d6f85a8cea392dfebcfff1552df61f71baa 100644 --- a/internal/httpd/internal_test.go +++ b/internal/httpd/internal_test.go @@ -348,11 +348,14 @@ func TestBrandingValidation(t *testing.T) { assert.Equal(t, []string{"/my.css"}, b.Branding.WebAdmin.DefaultCSS) assert.Len(t, b.Branding.WebAdmin.ExtraCSS, 0) assert.Equal(t, "/favicon1.ico", b.Branding.WebClient.FaviconPath) - assert.Equal(t, "/path2", b.Branding.WebClient.DisclaimerPath) + assert.Equal(t, path.Join(webStaticFilesPath, "/path2"), b.Branding.WebClient.DisclaimerPath) assert.Equal(t, "/img/login_image.png", b.Branding.WebClient.LoginImagePath) if assert.Len(t, b.Branding.WebClient.ExtraCSS, 1) { assert.Equal(t, "/1.css", b.Branding.WebClient.ExtraCSS[0]) } + b.Branding.WebAdmin.DisclaimerPath = "https://example.com" + b.checkBranding() + assert.Equal(t, "https://example.com", b.Branding.WebAdmin.DisclaimerPath) } func TestRedactedConf(t *testing.T) { diff --git a/static/locales/en/translation.json b/static/locales/en/translation.json index 229dbff64ded732aa6c2828526140631f15d5ba5..ff4abcaaff839626089ceafe56e7d43224a59bd2 100644 --- a/static/locales/en/translation.json +++ b/static/locales/en/translation.json @@ -239,7 +239,7 @@ "disk": "Disk quota", "size": "Size: {{- val}}", "size_percentage": "Size: {{- val}} ({{percentage}}%)", - "files": "Files: {{- num}}", + "files": "Files: {{- val}}", "files_percentage": "Files: {{- val}} ({{percentage}}%)", "transfer": "Transfer quota", "total": "Total: {{- val}}", diff --git a/templates/webadmin/login.html b/templates/webadmin/login.html index 3c7e08681bdcbda52392ad7953009ba9b904f210..870a16416036c7146573ada8a99aabd7a5e2bb72 100644 --- a/templates/webadmin/login.html +++ b/templates/webadmin/login.html @@ -66,7 +66,7 @@ along with this program. If not, see . {{if and .Branding.DisclaimerName .Branding.DisclaimerPath}}
- {{.Branding.DisclaimerName}} + {{.Branding.DisclaimerName}}
{{end}} {{end}} \ No newline at end of file diff --git a/templates/webclient/files.html b/templates/webclient/files.html index 76d8cf1daee6eb97035e3a4bbe4ba555cf3f539f..dcc239817686abe033b68537686c615d27110a52 100644 --- a/templates/webclient/files.html +++ b/templates/webclient/files.html @@ -2029,7 +2029,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). {{- if $files}} {{- $percentage := .QuotaUsage.GetQuotaFilesPercentage}}
- +
{{- end}} diff --git a/templates/webclient/login.html b/templates/webclient/login.html index b0272448306a89ec6454f147f5fc0517575a58b7..affc377f5d5bf539e793baa72dc4f8c7b150aec6 100644 --- a/templates/webclient/login.html +++ b/templates/webclient/login.html @@ -90,7 +90,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). {{- end}} {{- if and .Branding.DisclaimerName .Branding.DisclaimerPath}} - + {{.Branding.DisclaimerName}} {{- end}}