Skip to content

Commit d44e156

Browse files
authored
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.
1 parent f1173d6 commit d44e156

File tree

11 files changed

+25
-28
lines changed

11 files changed

+25
-28
lines changed

custom/conf/app.example.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2340,7 +2340,6 @@ ROUTER = console
23402340
;[other]
23412341
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23422342
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2343-
;SHOW_FOOTER_BRANDING = false
23442343
;; Show version information about Gitea and Go in the footer
23452344
;SHOW_FOOTER_VERSION = true
23462345
;; Show template execution time in the footer

docs/content/doc/administration/config-cheat-sheet.en-us.md

-1
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,6 @@ although Github don't support this form.
13911391
13921392
## Other (`other`)
13931393

1394-
- `SHOW_FOOTER_BRANDING`: **false**: Show Gitea branding in the footer.
13951394
- `SHOW_FOOTER_VERSION`: **true**: Show Gitea and Go version information in the footer.
13961395
- `SHOW_FOOTER_TEMPLATE_LOAD_TIME`: **true**: Show time of template execution in the footer.
13971396
- `ENABLE_SITEMAP`: **true**: Generate sitemap.

docs/content/doc/administration/config-cheat-sheet.zh-cn.md

-1
Original file line numberDiff line numberDiff line change
@@ -483,5 +483,4 @@ PROXY_HOSTS = *.github.com
483483

484484
## Other (`other`)
485485

486-
- `SHOW_FOOTER_BRANDING`: 为真则在页面底部显示Gitea的字样。
487486
- `SHOW_FOOTER_VERSION`: 为真则在页面底部显示Gitea的版本。

modules/context/context.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,7 @@ func Contexter(ctx context.Context) func(next http.Handler) http.Handler {
741741

742742
ctx.Data["ShowRegistrationButton"] = setting.Service.ShowRegistrationButton
743743
ctx.Data["ShowMilestonesDashboardPage"] = setting.Service.ShowMilestonesDashboardPage
744-
ctx.Data["ShowFooterBranding"] = setting.ShowFooterBranding
745-
ctx.Data["ShowFooterVersion"] = setting.ShowFooterVersion
744+
ctx.Data["ShowFooterVersion"] = setting.Other.ShowFooterVersion
746745

747746
ctx.Data["EnableSwagger"] = setting.API.EnableSwagger
748747
ctx.Data["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn

modules/context/repo.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
452452
userName := ctx.Params(":username")
453453
repoName := ctx.Params(":reponame")
454454
repoName = strings.TrimSuffix(repoName, ".git")
455-
if setting.EnableFeed {
455+
if setting.Other.EnableFeed {
456456
repoName = strings.TrimSuffix(repoName, ".rss")
457457
repoName = strings.TrimSuffix(repoName, ".atom")
458458
}
@@ -540,7 +540,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
540540
ctx.Data["RepoLink"] = ctx.Repo.RepoLink
541541
ctx.Data["RepoRelPath"] = ctx.Repo.Owner.Name + "/" + ctx.Repo.Repository.Name
542542

543-
if setting.EnableFeed {
543+
if setting.Other.EnableFeed {
544544
ctx.Data["EnableFeed"] = true
545545
ctx.Data["FeedURL"] = ctx.Repo.RepoLink
546546
}

modules/setting/other.go

+14-9
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@
33

44
package setting
55

6-
var (
7-
// Other settings
8-
ShowFooterBranding bool
6+
import "code.gitea.io/gitea/modules/log"
7+
8+
type OtherConfig struct {
99
ShowFooterVersion bool
1010
ShowFooterTemplateLoadTime bool
1111
EnableFeed bool
1212
EnableSitemap bool
13-
)
13+
}
14+
15+
var Other = OtherConfig{
16+
ShowFooterVersion: true,
17+
ShowFooterTemplateLoadTime: true,
18+
EnableSitemap: true,
19+
EnableFeed: true,
20+
}
1421

1522
func loadOtherFrom(rootCfg ConfigProvider) {
1623
sec := rootCfg.Section("other")
17-
ShowFooterBranding = sec.Key("SHOW_FOOTER_BRANDING").MustBool(false)
18-
ShowFooterVersion = sec.Key("SHOW_FOOTER_VERSION").MustBool(true)
19-
ShowFooterTemplateLoadTime = sec.Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true)
20-
EnableSitemap = sec.Key("ENABLE_SITEMAP").MustBool(true)
21-
EnableFeed = sec.Key("ENABLE_FEED").MustBool(true)
24+
if err := sec.MapTo(&Other); err != nil {
25+
log.Fatal("Failed to map [other] settings: %v", err)
26+
}
2227
}

modules/templates/base.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ func BaseVars() Vars {
3333

3434
"ShowRegistrationButton": setting.Service.ShowRegistrationButton,
3535
"ShowMilestonesDashboardPage": setting.Service.ShowMilestonesDashboardPage,
36-
"ShowFooterBranding": setting.ShowFooterBranding,
37-
"ShowFooterVersion": setting.ShowFooterVersion,
36+
"ShowFooterVersion": setting.Other.ShowFooterVersion,
3837
"DisableDownloadSourceArchives": setting.Repository.DisableDownloadSourceArchives,
3938

4039
"EnableSwagger": setting.API.EnableSwagger,

modules/templates/helper.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func NewFuncMap() []template.FuncMap {
181181
return setting.UI.DefaultShowFullName
182182
},
183183
"ShowFooterTemplateLoadTime": func() bool {
184-
return setting.ShowFooterTemplateLoadTime
184+
return setting.Other.ShowFooterTemplateLoadTime
185185
},
186186
"AllowedReactions": func() []string {
187187
return setting.UI.Reactions

routers/web/repo/view.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {
695695

696696
// Home render repository home page
697697
func Home(ctx *context.Context) {
698-
if setting.EnableFeed {
698+
if setting.Other.EnableFeed {
699699
isFeed, _, showFeedType := feed.GetFeedType(ctx.Params(":reponame"), ctx.Req)
700700
if isFeed {
701701
feed.ShowRepoFeed(ctx, ctx.Repo.Repository, showFeedType)

routers/web/web.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ func RegisterRoutes(m *web.Route) {
293293
}
294294

295295
sitemapEnabled := func(ctx *context.Context) {
296-
if !setting.EnableSitemap {
296+
if !setting.Other.EnableSitemap {
297297
ctx.Error(http.StatusNotFound)
298298
return
299299
}
@@ -307,7 +307,7 @@ func RegisterRoutes(m *web.Route) {
307307
}
308308

309309
feedEnabled := func(ctx *context.Context) {
310-
if !setting.EnableFeed {
310+
if !setting.Other.EnableFeed {
311311
ctx.Error(http.StatusNotFound)
312312
return
313313
}
@@ -706,7 +706,7 @@ func RegisterRoutes(m *web.Route) {
706706
default:
707707
context_service.UserAssignmentWeb()(ctx)
708708
if !ctx.Written() {
709-
ctx.Data["EnableFeed"] = setting.EnableFeed
709+
ctx.Data["EnableFeed"] = setting.Other.EnableFeed
710710
user.Profile(ctx)
711711
}
712712
}
@@ -1205,7 +1205,7 @@ func RegisterRoutes(m *web.Route) {
12051205
m.Get(".rss", feedEnabled, repo.TagsListFeedRSS)
12061206
m.Get(".atom", feedEnabled, repo.TagsListFeedAtom)
12071207
}, func(ctx *context.Context) {
1208-
ctx.Data["EnableFeed"] = setting.EnableFeed
1208+
ctx.Data["EnableFeed"] = setting.Other.EnableFeed
12091209
}, repo.MustBeNotEmpty, reqRepoCodeReader, context.RepoRefByType(context.RepoRefTag, true))
12101210
m.Group("/releases", func() {
12111211
m.Get("/", repo.Releases)
@@ -1214,7 +1214,7 @@ func RegisterRoutes(m *web.Route) {
12141214
m.Get(".rss", feedEnabled, repo.ReleasesFeedRSS)
12151215
m.Get(".atom", feedEnabled, repo.ReleasesFeedAtom)
12161216
}, func(ctx *context.Context) {
1217-
ctx.Data["EnableFeed"] = setting.EnableFeed
1217+
ctx.Data["EnableFeed"] = setting.Other.EnableFeed
12181218
}, repo.MustBeNotEmpty, reqRepoReleaseReader, context.RepoRefByType(context.RepoRefTag, true))
12191219
m.Get("/releases/attachments/{uuid}", repo.GetAttachment, repo.MustBeNotEmpty, reqRepoReleaseReader)
12201220
m.Group("/releases", func() {

templates/base/footer_content.tmpl

-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
{{end}}
1616
</div>
1717
<div class="ui right links" role="group" aria-label="{{.locale.Tr "aria.footer.links"}}">
18-
{{if .ShowFooterBranding}}
19-
<a target="_blank" rel="noopener noreferrer" href="https://github.com/go-gitea/gitea">{{svg "octicon-mark-github"}}<span class="sr-only">GitHub</span></a>
20-
{{end}}
2118
<div class="ui dropdown upward language">
2219
<span>{{svg "octicon-globe"}} {{.locale.LangName}}</span>
2320
<div class="menu language-menu">

0 commit comments

Comments
 (0)