diff --git a/docs/full-configuration.md b/docs/full-configuration.md index 4ff75d1a..2750a812 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 681dde9d..8241ab9d 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 272f022e..5b6e3d6f 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 229dbff6..ff4abcaa 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 3c7e0868..870a1641 100644 --- a/templates/webadmin/login.html +++ b/templates/webadmin/login.html @@ -66,7 +66,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. {{if and .Branding.DisclaimerName .Branding.DisclaimerPath}} <hr> <div class="text-center"> - <a class="small" href="{{.StaticURL}}{{.Branding.DisclaimerPath}}" target="_blank">{{.Branding.DisclaimerName}}</a> + <a class="small" href="{{.Branding.DisclaimerPath}}" target="_blank">{{.Branding.DisclaimerName}}</a> </div> {{end}} {{end}} \ No newline at end of file diff --git a/templates/webclient/files.html b/templates/webclient/files.html index 76d8cf1d..dcc23981 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}} <div class="{{if .QuotaUsage.IsQuotaFilesLow}}text-warning{{else}}text-gray-700{{end}} fw-semibold fs-6"> - <span {{if gt $percentage 0}}data-i18n="fs.quota_usage.files_percentage" data-i18n-options='{ "val": "{{$files}}", "percentage": {{$percentage}} }'{{else}}data-i18n="fs.quota_usage.files" data-i18n-options='{ "num": "{{$files}}" }'{{end}}></span> + <span {{if gt $percentage 0}}data-i18n="fs.quota_usage.files_percentage" data-i18n-options='{ "val": "{{$files}}", "percentage": {{$percentage}} }'{{else}}data-i18n="fs.quota_usage.files" data-i18n-options='{ "val": "{{$files}}" }'{{end}}></span> </div> {{- end}} </div> diff --git a/templates/webclient/login.html b/templates/webclient/login.html index b0272448..affc377f 100644 --- a/templates/webclient/login.html +++ b/templates/webclient/login.html @@ -90,7 +90,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com). </a> {{- end}} {{- if and .Branding.DisclaimerName .Branding.DisclaimerPath}} - <a href="{{.StaticURL}}{{.Branding.DisclaimerPath}}" target="_blank" class="px-2"> + <a href="{{.Branding.DisclaimerPath}}" target="_blank" class="px-2"> <span data-i18n="custom.disclaimer_webclient">{{.Branding.DisclaimerName}}</span> </a> {{- end}}