1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-25 08:59:31 -05:00

Refactor setting.Other and remove unused SHOW_FOOTER_BRANDING (#24270)

The `SHOW_FOOTER_BRANDING` came from year 2015, and it seems nobody ever
uses it. It only shows an GitHub icon which seems unrelated to Gitea, it
doesn't do what document says. So, remove it.

## ⚠️ Breaking

Users can now remove the key `[other].SHOW_FOOTER_BRANDING` from their
app.ini.
This commit is contained in:
wxiaoguang 2023-04-23 07:38:25 +08:00 committed by GitHub
parent f1173d6879
commit d44e1565da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 25 additions and 28 deletions

View file

@ -2340,7 +2340,6 @@ ROUTER = console
;[other] ;[other]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;SHOW_FOOTER_BRANDING = false
;; Show version information about Gitea and Go in the footer ;; Show version information about Gitea and Go in the footer
;SHOW_FOOTER_VERSION = true ;SHOW_FOOTER_VERSION = true
;; Show template execution time in the footer ;; Show template execution time in the footer

View file

@ -1391,7 +1391,6 @@ although Github don't support this form.
## Other (`other`) ## Other (`other`)
- `SHOW_FOOTER_BRANDING`: **false**: Show Gitea branding in the footer.
- `SHOW_FOOTER_VERSION`: **true**: Show Gitea and Go version information in the footer. - `SHOW_FOOTER_VERSION`: **true**: Show Gitea and Go version information in the footer.
- `SHOW_FOOTER_TEMPLATE_LOAD_TIME`: **true**: Show time of template execution in the footer. - `SHOW_FOOTER_TEMPLATE_LOAD_TIME`: **true**: Show time of template execution in the footer.
- `ENABLE_SITEMAP`: **true**: Generate sitemap. - `ENABLE_SITEMAP`: **true**: Generate sitemap.

View file

@ -483,5 +483,4 @@ PROXY_HOSTS = *.github.com
## Other (`other`) ## Other (`other`)
- `SHOW_FOOTER_BRANDING`: 为真则在页面底部显示Gitea的字样。
- `SHOW_FOOTER_VERSION`: 为真则在页面底部显示Gitea的版本。 - `SHOW_FOOTER_VERSION`: 为真则在页面底部显示Gitea的版本。

View file

@ -741,8 +741,7 @@ func Contexter(ctx context.Context) func(next http.Handler) http.Handler {
ctx.Data["ShowRegistrationButton"] = setting.Service.ShowRegistrationButton ctx.Data["ShowRegistrationButton"] = setting.Service.ShowRegistrationButton
ctx.Data["ShowMilestonesDashboardPage"] = setting.Service.ShowMilestonesDashboardPage ctx.Data["ShowMilestonesDashboardPage"] = setting.Service.ShowMilestonesDashboardPage
ctx.Data["ShowFooterBranding"] = setting.ShowFooterBranding ctx.Data["ShowFooterVersion"] = setting.Other.ShowFooterVersion
ctx.Data["ShowFooterVersion"] = setting.ShowFooterVersion
ctx.Data["EnableSwagger"] = setting.API.EnableSwagger ctx.Data["EnableSwagger"] = setting.API.EnableSwagger
ctx.Data["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn ctx.Data["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn

View file

@ -452,7 +452,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
userName := ctx.Params(":username") userName := ctx.Params(":username")
repoName := ctx.Params(":reponame") repoName := ctx.Params(":reponame")
repoName = strings.TrimSuffix(repoName, ".git") repoName = strings.TrimSuffix(repoName, ".git")
if setting.EnableFeed { if setting.Other.EnableFeed {
repoName = strings.TrimSuffix(repoName, ".rss") repoName = strings.TrimSuffix(repoName, ".rss")
repoName = strings.TrimSuffix(repoName, ".atom") repoName = strings.TrimSuffix(repoName, ".atom")
} }
@ -540,7 +540,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
ctx.Data["RepoLink"] = ctx.Repo.RepoLink ctx.Data["RepoLink"] = ctx.Repo.RepoLink
ctx.Data["RepoRelPath"] = ctx.Repo.Owner.Name + "/" + ctx.Repo.Repository.Name ctx.Data["RepoRelPath"] = ctx.Repo.Owner.Name + "/" + ctx.Repo.Repository.Name
if setting.EnableFeed { if setting.Other.EnableFeed {
ctx.Data["EnableFeed"] = true ctx.Data["EnableFeed"] = true
ctx.Data["FeedURL"] = ctx.Repo.RepoLink ctx.Data["FeedURL"] = ctx.Repo.RepoLink
} }

View file

@ -3,20 +3,25 @@
package setting package setting
var ( import "code.gitea.io/gitea/modules/log"
// Other settings
ShowFooterBranding bool type OtherConfig struct {
ShowFooterVersion bool ShowFooterVersion bool
ShowFooterTemplateLoadTime bool ShowFooterTemplateLoadTime bool
EnableFeed bool EnableFeed bool
EnableSitemap bool EnableSitemap bool
) }
var Other = OtherConfig{
ShowFooterVersion: true,
ShowFooterTemplateLoadTime: true,
EnableSitemap: true,
EnableFeed: true,
}
func loadOtherFrom(rootCfg ConfigProvider) { func loadOtherFrom(rootCfg ConfigProvider) {
sec := rootCfg.Section("other") sec := rootCfg.Section("other")
ShowFooterBranding = sec.Key("SHOW_FOOTER_BRANDING").MustBool(false) if err := sec.MapTo(&Other); err != nil {
ShowFooterVersion = sec.Key("SHOW_FOOTER_VERSION").MustBool(true) log.Fatal("Failed to map [other] settings: %v", err)
ShowFooterTemplateLoadTime = sec.Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true) }
EnableSitemap = sec.Key("ENABLE_SITEMAP").MustBool(true)
EnableFeed = sec.Key("ENABLE_FEED").MustBool(true)
} }

View file

@ -33,8 +33,7 @@ func BaseVars() Vars {
"ShowRegistrationButton": setting.Service.ShowRegistrationButton, "ShowRegistrationButton": setting.Service.ShowRegistrationButton,
"ShowMilestonesDashboardPage": setting.Service.ShowMilestonesDashboardPage, "ShowMilestonesDashboardPage": setting.Service.ShowMilestonesDashboardPage,
"ShowFooterBranding": setting.ShowFooterBranding, "ShowFooterVersion": setting.Other.ShowFooterVersion,
"ShowFooterVersion": setting.ShowFooterVersion,
"DisableDownloadSourceArchives": setting.Repository.DisableDownloadSourceArchives, "DisableDownloadSourceArchives": setting.Repository.DisableDownloadSourceArchives,
"EnableSwagger": setting.API.EnableSwagger, "EnableSwagger": setting.API.EnableSwagger,

View file

@ -181,7 +181,7 @@ func NewFuncMap() []template.FuncMap {
return setting.UI.DefaultShowFullName return setting.UI.DefaultShowFullName
}, },
"ShowFooterTemplateLoadTime": func() bool { "ShowFooterTemplateLoadTime": func() bool {
return setting.ShowFooterTemplateLoadTime return setting.Other.ShowFooterTemplateLoadTime
}, },
"AllowedReactions": func() []string { "AllowedReactions": func() []string {
return setting.UI.Reactions return setting.UI.Reactions

View file

@ -695,7 +695,7 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {
// Home render repository home page // Home render repository home page
func Home(ctx *context.Context) { func Home(ctx *context.Context) {
if setting.EnableFeed { if setting.Other.EnableFeed {
isFeed, _, showFeedType := feed.GetFeedType(ctx.Params(":reponame"), ctx.Req) isFeed, _, showFeedType := feed.GetFeedType(ctx.Params(":reponame"), ctx.Req)
if isFeed { if isFeed {
feed.ShowRepoFeed(ctx, ctx.Repo.Repository, showFeedType) feed.ShowRepoFeed(ctx, ctx.Repo.Repository, showFeedType)

View file

@ -293,7 +293,7 @@ func RegisterRoutes(m *web.Route) {
} }
sitemapEnabled := func(ctx *context.Context) { sitemapEnabled := func(ctx *context.Context) {
if !setting.EnableSitemap { if !setting.Other.EnableSitemap {
ctx.Error(http.StatusNotFound) ctx.Error(http.StatusNotFound)
return return
} }
@ -307,7 +307,7 @@ func RegisterRoutes(m *web.Route) {
} }
feedEnabled := func(ctx *context.Context) { feedEnabled := func(ctx *context.Context) {
if !setting.EnableFeed { if !setting.Other.EnableFeed {
ctx.Error(http.StatusNotFound) ctx.Error(http.StatusNotFound)
return return
} }
@ -706,7 +706,7 @@ func RegisterRoutes(m *web.Route) {
default: default:
context_service.UserAssignmentWeb()(ctx) context_service.UserAssignmentWeb()(ctx)
if !ctx.Written() { if !ctx.Written() {
ctx.Data["EnableFeed"] = setting.EnableFeed ctx.Data["EnableFeed"] = setting.Other.EnableFeed
user.Profile(ctx) user.Profile(ctx)
} }
} }
@ -1205,7 +1205,7 @@ func RegisterRoutes(m *web.Route) {
m.Get(".rss", feedEnabled, repo.TagsListFeedRSS) m.Get(".rss", feedEnabled, repo.TagsListFeedRSS)
m.Get(".atom", feedEnabled, repo.TagsListFeedAtom) m.Get(".atom", feedEnabled, repo.TagsListFeedAtom)
}, func(ctx *context.Context) { }, func(ctx *context.Context) {
ctx.Data["EnableFeed"] = setting.EnableFeed ctx.Data["EnableFeed"] = setting.Other.EnableFeed
}, repo.MustBeNotEmpty, reqRepoCodeReader, context.RepoRefByType(context.RepoRefTag, true)) }, repo.MustBeNotEmpty, reqRepoCodeReader, context.RepoRefByType(context.RepoRefTag, true))
m.Group("/releases", func() { m.Group("/releases", func() {
m.Get("/", repo.Releases) m.Get("/", repo.Releases)
@ -1214,7 +1214,7 @@ func RegisterRoutes(m *web.Route) {
m.Get(".rss", feedEnabled, repo.ReleasesFeedRSS) m.Get(".rss", feedEnabled, repo.ReleasesFeedRSS)
m.Get(".atom", feedEnabled, repo.ReleasesFeedAtom) m.Get(".atom", feedEnabled, repo.ReleasesFeedAtom)
}, func(ctx *context.Context) { }, func(ctx *context.Context) {
ctx.Data["EnableFeed"] = setting.EnableFeed ctx.Data["EnableFeed"] = setting.Other.EnableFeed
}, repo.MustBeNotEmpty, reqRepoReleaseReader, context.RepoRefByType(context.RepoRefTag, true)) }, repo.MustBeNotEmpty, reqRepoReleaseReader, context.RepoRefByType(context.RepoRefTag, true))
m.Get("/releases/attachments/{uuid}", repo.GetAttachment, repo.MustBeNotEmpty, reqRepoReleaseReader) m.Get("/releases/attachments/{uuid}", repo.GetAttachment, repo.MustBeNotEmpty, reqRepoReleaseReader)
m.Group("/releases", func() { m.Group("/releases", func() {

View file

@ -15,9 +15,6 @@
{{end}} {{end}}
</div> </div>
<div class="ui right links" role="group" aria-label="{{.locale.Tr "aria.footer.links"}}"> <div class="ui right links" role="group" aria-label="{{.locale.Tr "aria.footer.links"}}">
{{if .ShowFooterBranding}}
<a target="_blank" rel="noopener noreferrer" href="https://github.com/go-gitea/gitea">{{svg "octicon-mark-github"}}<span class="sr-only">GitHub</span></a>
{{end}}
<div class="ui dropdown upward language"> <div class="ui dropdown upward language">
<span>{{svg "octicon-globe"}} {{.locale.LangName}}</span> <span>{{svg "octicon-globe"}} {{.locale.LangName}}</span>
<div class="menu language-menu"> <div class="menu language-menu">