diff --git a/custom/conf/app.ini.sample b/custom/conf/app.ini.sample index 0212964750..832e6cf2e8 100644 --- a/custom/conf/app.ini.sample +++ b/custom/conf/app.ini.sample @@ -151,6 +151,8 @@ FILE_EXTENSIONS = .md,.markdown,.mdown,.mkd PROTOCOL = http DOMAIN = localhost ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/ +; when STATIC_URL_PREFIX is empty it will follow APP_URL +STATIC_URL_PREFIX = ; The address to listen on. Either a IPv4/IPv6 address or the path to a unix socket. HTTP_ADDR = 0.0.0.0 HTTP_PORT = 3000 diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 6a5c5a36d7..005f756b32 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -104,6 +104,7 @@ var ( LetsEncryptTOS bool LetsEncryptDirectory string LetsEncryptEmail string + StaticURLPrefix string SSH = struct { Disabled bool `ini:"DISABLE_SSH"` @@ -582,7 +583,7 @@ func NewContext() { defaultAppURL += ":" + HTTPPort } AppURL = sec.Key("ROOT_URL").MustString(defaultAppURL) - AppURL = strings.TrimRight(AppURL, "/") + "/" + AppURL = strings.TrimSuffix(AppURL, "/") + "/" // Check if has app suburl. appURL, err := url.Parse(AppURL) @@ -592,6 +593,7 @@ func NewContext() { // Suburl should start with '/' and end without '/', such as '/{subpath}'. // This value is empty if site does not have sub-url. AppSubURL = strings.TrimSuffix(appURL.Path, "/") + StaticURLPrefix = strings.TrimSuffix(sec.Key("STATIC_URL_PREFIX").MustString(AppSubURL), "/") AppSubURLDepth = strings.Count(AppSubURL, "/") // Check if Domain differs from AppURL domain than update it to AppURL's domain // TODO: Can be replaced with url.Hostname() when minimal GoLang version is 1.8 diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 5a3969c098..dc2865254c 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -48,6 +48,9 @@ func NewFuncMap() []template.FuncMap { "AppSubUrl": func() string { return setting.AppSubURL }, + "StaticUrlPrefix": func() string { + return setting.StaticURLPrefix + }, "AppUrl": func() string { return setting.AppURL }, @@ -110,12 +113,12 @@ func NewFuncMap() []template.FuncMap { } return str[start:end] }, - "EllipsisString": base.EllipsisString, - "DiffTypeToStr": DiffTypeToStr, - "DiffLineTypeToStr": DiffLineTypeToStr, - "Sha1": Sha1, - "ShortSha": base.ShortSha, - "MD5": base.EncodeMD5, + "EllipsisString": base.EllipsisString, + "DiffTypeToStr": DiffTypeToStr, + "DiffLineTypeToStr": DiffLineTypeToStr, + "Sha1": Sha1, + "ShortSha": base.ShortSha, + "MD5": base.EncodeMD5, "ActionContent2Commits": ActionContent2Commits, "PathEscape": url.PathEscape, "EscapePound": func(str string) string { diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl index 13718620da..802175ce7e 100644 --- a/templates/base/footer.tmpl +++ b/templates/base/footer.tmpl @@ -12,38 +12,38 @@ {{template "base/footer_content" .}} - - - + + + {{if .RequireSimpleMDE}} - - - + + + {{end}} {{if .RequireGitGraph}} - + {{end}} {{if .RequireHighlightJS}} - + {{end}} {{if .RequireMinicolors}} - + {{end}} {{if .RequireDatetimepicker}} - + {{end}} {{if .RequireDropzone}} - + {{end}} {{if .RequireU2F}} - + {{end}} {{if .EnableCaptcha}} {{if eq .CaptchaType "recaptcha"}} @@ -51,7 +51,7 @@ {{end}} {{end}} {{if .RequireTribute}} - + {{end}} - - - + + + - + {{if .EnableHeatmap}} - - + + diff --git a/templates/base/footer_content.tmpl b/templates/base/footer_content.tmpl index 6f680d4cb8..364e58a3d0 100644 --- a/templates/base/footer_content.tmpl +++ b/templates/base/footer_content.tmpl @@ -16,7 +16,7 @@ {{end}} - JavaScript licenses + JavaScript licenses {{if .EnableSwagger}}API{{end}} {{.i18n.Tr "website"}} {{if (or .ShowFooterVersion .PageIsAdmin)}}{{GoVer}}{{end}} diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 7cdfdd34be..658fb33a78 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -5,7 +5,7 @@