Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor setting.Other and remove unused SHOW_FOOTER_BRANDING #24270

Merged
merged 3 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2340,7 +2340,6 @@ ROUTER = console
;[other]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;SHOW_FOOTER_BRANDING = false
;; Show version information about Gitea and Go in the footer
;SHOW_FOOTER_VERSION = true
;; Show template execution time in the footer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,6 @@ although Github don't support this form.

## 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_TEMPLATE_LOAD_TIME`: **true**: Show time of template execution in the footer.
- `ENABLE_SITEMAP`: **true**: Generate sitemap.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,5 +483,4 @@ PROXY_HOSTS = *.git.luolix.top

## Other (`other`)

- `SHOW_FOOTER_BRANDING`: 为真则在页面底部显示Gitea的字样。
- `SHOW_FOOTER_VERSION`: 为真则在页面底部显示Gitea的版本。
3 changes: 1 addition & 2 deletions modules/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,7 @@ func Contexter(ctx context.Context) func(next http.Handler) http.Handler {

ctx.Data["ShowRegistrationButton"] = setting.Service.ShowRegistrationButton
ctx.Data["ShowMilestonesDashboardPage"] = setting.Service.ShowMilestonesDashboardPage
ctx.Data["ShowFooterBranding"] = setting.ShowFooterBranding
ctx.Data["ShowFooterVersion"] = setting.ShowFooterVersion
ctx.Data["ShowFooterVersion"] = setting.Other.ShowFooterVersion

ctx.Data["EnableSwagger"] = setting.API.EnableSwagger
ctx.Data["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn
Expand Down
4 changes: 2 additions & 2 deletions modules/context/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
userName := ctx.Params(":username")
repoName := ctx.Params(":reponame")
repoName = strings.TrimSuffix(repoName, ".git")
if setting.EnableFeed {
if setting.Other.EnableFeed {
repoName = strings.TrimSuffix(repoName, ".rss")
repoName = strings.TrimSuffix(repoName, ".atom")
}
Expand Down Expand Up @@ -540,7 +540,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) {
ctx.Data["RepoLink"] = ctx.Repo.RepoLink
ctx.Data["RepoRelPath"] = ctx.Repo.Owner.Name + "/" + ctx.Repo.Repository.Name

if setting.EnableFeed {
if setting.Other.EnableFeed {
ctx.Data["EnableFeed"] = true
ctx.Data["FeedURL"] = ctx.Repo.RepoLink
}
Expand Down
23 changes: 14 additions & 9 deletions modules/setting/other.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@

package setting

var (
// Other settings
ShowFooterBranding bool
import "code.gitea.io/gitea/modules/log"

type OtherConfig struct {
ShowFooterVersion bool
ShowFooterTemplateLoadTime bool
EnableFeed bool
EnableSitemap bool
)
}

var Other = OtherConfig{
ShowFooterVersion: true,
ShowFooterTemplateLoadTime: true,
EnableSitemap: true,
EnableFeed: true,
}

func loadOtherFrom(rootCfg ConfigProvider) {
sec := rootCfg.Section("other")
ShowFooterBranding = sec.Key("SHOW_FOOTER_BRANDING").MustBool(false)
ShowFooterVersion = sec.Key("SHOW_FOOTER_VERSION").MustBool(true)
ShowFooterTemplateLoadTime = sec.Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true)
EnableSitemap = sec.Key("ENABLE_SITEMAP").MustBool(true)
EnableFeed = sec.Key("ENABLE_FEED").MustBool(true)
if err := sec.MapTo(&Other); err != nil {
log.Fatal("Failed to map [other] settings: %v", err)
delvh marked this conversation as resolved.
Show resolved Hide resolved
}
}
3 changes: 1 addition & 2 deletions modules/templates/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ func BaseVars() Vars {

"ShowRegistrationButton": setting.Service.ShowRegistrationButton,
"ShowMilestonesDashboardPage": setting.Service.ShowMilestonesDashboardPage,
"ShowFooterBranding": setting.ShowFooterBranding,
"ShowFooterVersion": setting.ShowFooterVersion,
"ShowFooterVersion": setting.Other.ShowFooterVersion,
"DisableDownloadSourceArchives": setting.Repository.DisableDownloadSourceArchives,

"EnableSwagger": setting.API.EnableSwagger,
Expand Down
2 changes: 1 addition & 1 deletion modules/templates/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func NewFuncMap() []template.FuncMap {
return setting.UI.DefaultShowFullName
},
"ShowFooterTemplateLoadTime": func() bool {
return setting.ShowFooterTemplateLoadTime
return setting.Other.ShowFooterTemplateLoadTime
},
"AllowedReactions": func() []string {
return setting.UI.Reactions
Expand Down
2 changes: 1 addition & 1 deletion routers/web/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {

// Home render repository home page
func Home(ctx *context.Context) {
if setting.EnableFeed {
if setting.Other.EnableFeed {
isFeed, _, showFeedType := feed.GetFeedType(ctx.Params(":reponame"), ctx.Req)
if isFeed {
feed.ShowRepoFeed(ctx, ctx.Repo.Repository, showFeedType)
Expand Down
10 changes: 5 additions & 5 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func RegisterRoutes(m *web.Route) {
}

sitemapEnabled := func(ctx *context.Context) {
if !setting.EnableSitemap {
if !setting.Other.EnableSitemap {
ctx.Error(http.StatusNotFound)
return
}
Expand All @@ -307,7 +307,7 @@ func RegisterRoutes(m *web.Route) {
}

feedEnabled := func(ctx *context.Context) {
if !setting.EnableFeed {
if !setting.Other.EnableFeed {
ctx.Error(http.StatusNotFound)
return
}
Expand Down Expand Up @@ -706,7 +706,7 @@ func RegisterRoutes(m *web.Route) {
default:
context_service.UserAssignmentWeb()(ctx)
if !ctx.Written() {
ctx.Data["EnableFeed"] = setting.EnableFeed
ctx.Data["EnableFeed"] = setting.Other.EnableFeed
user.Profile(ctx)
}
}
Expand Down Expand Up @@ -1205,7 +1205,7 @@ func RegisterRoutes(m *web.Route) {
m.Get(".rss", feedEnabled, repo.TagsListFeedRSS)
m.Get(".atom", feedEnabled, repo.TagsListFeedAtom)
}, func(ctx *context.Context) {
ctx.Data["EnableFeed"] = setting.EnableFeed
ctx.Data["EnableFeed"] = setting.Other.EnableFeed
}, repo.MustBeNotEmpty, reqRepoCodeReader, context.RepoRefByType(context.RepoRefTag, true))
m.Group("/releases", func() {
m.Get("/", repo.Releases)
Expand All @@ -1214,7 +1214,7 @@ func RegisterRoutes(m *web.Route) {
m.Get(".rss", feedEnabled, repo.ReleasesFeedRSS)
m.Get(".atom", feedEnabled, repo.ReleasesFeedAtom)
}, func(ctx *context.Context) {
ctx.Data["EnableFeed"] = setting.EnableFeed
ctx.Data["EnableFeed"] = setting.Other.EnableFeed
}, repo.MustBeNotEmpty, reqRepoReleaseReader, context.RepoRefByType(context.RepoRefTag, true))
m.Get("/releases/attachments/{uuid}", repo.GetAttachment, repo.MustBeNotEmpty, reqRepoReleaseReader)
m.Group("/releases", func() {
Expand Down
3 changes: 0 additions & 3 deletions templates/base/footer_content.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
{{end}}
</div>
<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">
<span>{{svg "octicon-globe"}} {{.locale.LangName}}</span>
<div class="menu language-menu">
Expand Down