Skip to content

Commit ce6eeab

Browse files
committed
Revert "use db settings"
This reverts commit c3a3bab.
1 parent 6c4673d commit ce6eeab

File tree

12 files changed

+29
-84
lines changed

12 files changed

+29
-84
lines changed

modules/setting/config.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,9 @@ type RepositoryStruct struct {
5151
OpenWithEditorApps *config.Value[OpenWithEditorAppsType]
5252
}
5353

54-
type ExplorePage struct {
55-
RequireSigninView *config.Value[bool]
56-
DisableUsersPage *config.Value[bool]
57-
DisableOrganizationsPage *config.Value[bool]
58-
DisableCodePage *config.Value[bool]
59-
}
60-
61-
type ServiceStruct struct {
62-
ExplorePage *ExplorePage
63-
}
64-
6554
type ConfigStruct struct {
6655
Picture *PictureStruct
6756
Repository *RepositoryStruct
68-
Service *ServiceStruct
6957
}
7058

7159
var (
@@ -83,14 +71,6 @@ func initDefaultConfig() {
8371
Repository: &RepositoryStruct{
8472
OpenWithEditorApps: config.ValueJSON[OpenWithEditorAppsType]("repository.open-with.editor-apps"),
8573
},
86-
Service: &ServiceStruct{
87-
ExplorePage: &ExplorePage{
88-
RequireSigninView: config.ValueJSON[bool]("service.explore.require_signin_view").WithFileConfig(config.CfgSecKey{Sec: "service.explore", Key: "REQUIRE_SIGNIN_VIEW"}),
89-
DisableUsersPage: config.ValueJSON[bool]("service.explore.disable_users_page").WithFileConfig(config.CfgSecKey{Sec: "service.explore", Key: "DISABLE_USERS_PAGE"}),
90-
DisableOrganizationsPage: config.ValueJSON[bool]("service.explore.disable_organizations_page").WithFileConfig(config.CfgSecKey{Sec: "service.explore", Key: "DISABLE_ORGANIZATIONS_PAGE"}),
91-
DisableCodePage: config.ValueJSON[bool]("service.explore.disable_code_page").WithFileConfig(config.CfgSecKey{Sec: "service.explore", Key: "DISABLE_CODE_PAGE"}),
92-
},
93-
},
9474
}
9575
}
9676

modules/setting/service.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ var Service = struct {
8787
EnableOpenIDSignUp bool
8888
OpenIDWhitelist []*regexp.Regexp
8989
OpenIDBlacklist []*regexp.Regexp
90+
91+
// Explore page settings
92+
Explore struct {
93+
RequireSigninView bool `ini:"REQUIRE_SIGNIN_VIEW"`
94+
DisableUsersPage bool `ini:"DISABLE_USERS_PAGE"`
95+
DisableOrganizationsPage bool `ini:"DISABLE_ORGANIZATIONS_PAGE"`
96+
DisableCodePage bool `ini:"DISABLE_CODE_PAGE"`
97+
} `ini:"service.explore"`
9098
}{
9199
AllowedUserVisibilityModesSlice: []bool{true, true, true},
92100
}
@@ -228,6 +236,8 @@ func loadServiceFrom(rootCfg ConfigProvider) {
228236
}
229237
Service.ValidSiteURLSchemes = schemes
230238

239+
mustMapSetting(rootCfg, "service.explore", &Service.Explore)
240+
231241
loadOpenIDSetting(rootCfg)
232242
}
233243

options/locale/locale_en-US.ini

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3300,10 +3300,6 @@ config.picture_service = Picture Service
33003300
config.disable_gravatar = Disable Gravatar
33013301
config.enable_federated_avatar = Enable Federated Avatars
33023302
config.open_with_editor_app_help = The "Open with" editors for the clone menu. If left empty, the default will be used. Expand to see the default.
3303-
config.explore_require_signin_view = Only signed-in users can view the explore pages
3304-
config.explore_disable_users_page = Disable users explore page
3305-
config.explore_disable_organizations_page = Disable organizations explore page
3306-
config.explore_disable_code_page = Disable code explore page
33073303
33083304
config.git_config = Git Configuration
33093305
config.git_disable_diff_highlight = Disable Diff Syntax Highlight

routers/api/v1/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,11 @@ func reqToken() func(ctx *context.APIContext) {
356356

357357
func reqExploreSignInAndUsersExploreEnabled() func(ctx *context.APIContext) {
358358
return func(ctx *context.APIContext) {
359-
if setting.Config().Service.ExplorePage.DisableUsersPage.Value(ctx) {
359+
if setting.Service.Explore.DisableUsersPage {
360360
ctx.NotFound()
361361
return
362362
}
363-
if setting.Config().Service.ExplorePage.RequireSigninView.Value(ctx) && !ctx.IsSigned {
363+
if setting.Service.Explore.RequireSigninView && !ctx.IsSigned {
364364
ctx.Error(http.StatusUnauthorized, "reqExploreSignIn", "you must be signed in to search for users")
365365
}
366366
}

routers/web/admin/config.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,9 @@ func ChangeConfig(ctx *context.Context) {
231231
return string(b), nil
232232
}
233233
marshallers := map[string]func(string) (string, error){
234-
cfg.Picture.DisableGravatar.DynKey(): marshalBool,
235-
cfg.Picture.EnableFederatedAvatar.DynKey(): marshalBool,
236-
cfg.Repository.OpenWithEditorApps.DynKey(): marshalOpenWithApps,
237-
cfg.Service.ExplorePage.RequireSigninView.DynKey(): marshalBool,
238-
cfg.Service.ExplorePage.DisableUsersPage.DynKey(): marshalBool,
239-
cfg.Service.ExplorePage.DisableOrganizationsPage.DynKey(): marshalBool,
240-
cfg.Service.ExplorePage.DisableCodePage.DynKey(): marshalBool,
234+
cfg.Picture.DisableGravatar.DynKey(): marshalBool,
235+
cfg.Picture.EnableFederatedAvatar.DynKey(): marshalBool,
236+
cfg.Repository.OpenWithEditorApps.DynKey(): marshalOpenWithApps,
241237
}
242238
marshaller, hasMarshaller := marshallers[key]
243239
if !hasMarshaller {

routers/web/explore/code.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ func Code(ctx *context.Context) {
2525
ctx.Redirect(setting.AppSubURL + "/explore")
2626
return
2727
}
28-
if setting.Config().Service.ExplorePage.DisableCodePage.Value(ctx) {
28+
if setting.Service.Explore.DisableCodePage {
2929
ctx.Redirect(setting.AppSubURL + "/explore/repos")
3030
return
3131
}
3232

33-
ctx.Data["UsersIsDisabled"] = setting.Config().Service.ExplorePage.DisableUsersPage.Value(ctx)
34-
ctx.Data["OrganizationsIsDisabled"] = setting.Config().Service.ExplorePage.DisableOrganizationsPage.Value(ctx)
33+
ctx.Data["UsersIsDisabled"] = setting.Service.Explore.DisableUsersPage
34+
ctx.Data["OrganizationsIsDisabled"] = setting.Service.Explore.DisableOrganizationsPage
3535
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
3636
ctx.Data["Title"] = ctx.Tr("explore")
3737
ctx.Data["PageIsExplore"] = true

routers/web/explore/org.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import (
1414

1515
// Organizations render explore organizations page
1616
func Organizations(ctx *context.Context) {
17-
if setting.Config().Service.ExplorePage.DisableOrganizationsPage.Value(ctx) {
17+
if setting.Service.Explore.DisableOrganizationsPage {
1818
ctx.Redirect(setting.AppSubURL + "/explore/repos")
1919
return
2020
}
2121

22-
ctx.Data["UsersIsDisabled"] = setting.Config().Service.ExplorePage.DisableUsersPage.Value(ctx)
23-
ctx.Data["CodeIsDisabled"] = setting.Config().Service.ExplorePage.DisableCodePage.Value(ctx)
22+
ctx.Data["UsersIsDisabled"] = setting.Service.Explore.DisableUsersPage
23+
ctx.Data["CodeIsDisabled"] = setting.Service.Explore.DisableCodePage
2424
ctx.Data["Title"] = ctx.Tr("explore")
2525
ctx.Data["PageIsExplore"] = true
2626
ctx.Data["PageIsExploreOrganizations"] = true

routers/web/explore/repo.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
165165

166166
// Repos render explore repositories page
167167
func Repos(ctx *context.Context) {
168-
ctx.Data["UsersIsDisabled"] = setting.Config().Service.ExplorePage.DisableUsersPage.Value(ctx)
169-
ctx.Data["OrganizationsIsDisabled"] = setting.Config().Service.ExplorePage.DisableOrganizationsPage.Value(ctx)
170-
ctx.Data["CodeIsDisabled"] = setting.Config().Service.ExplorePage.DisableCodePage.Value(ctx)
168+
ctx.Data["UsersIsDisabled"] = setting.Service.Explore.DisableUsersPage
169+
ctx.Data["OrganizationsIsDisabled"] = setting.Service.Explore.DisableOrganizationsPage
170+
ctx.Data["CodeIsDisabled"] = setting.Service.Explore.DisableCodePage
171171
ctx.Data["Title"] = ctx.Tr("explore")
172172
ctx.Data["PageIsExplore"] = true
173173
ctx.Data["PageIsExploreRepositories"] = true

routers/web/explore/user.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ func RenderUserSearch(ctx *context.Context, opts *user_model.SearchUserOptions,
130130

131131
// Users render explore users page
132132
func Users(ctx *context.Context) {
133-
if setting.Config().Service.ExplorePage.DisableUsersPage.Value(ctx) {
133+
if setting.Service.Explore.DisableUsersPage {
134134
ctx.Redirect(setting.AppSubURL + "/explore/repos")
135135
return
136136
}
137-
ctx.Data["OrganizationsIsDisabled"] = setting.Config().Service.ExplorePage.DisableOrganizationsPage.Value(ctx)
138-
ctx.Data["CodeIsDisabled"] = setting.Config().Service.ExplorePage.DisableCodePage.Value(ctx)
137+
ctx.Data["OrganizationsIsDisabled"] = setting.Service.Explore.DisableOrganizationsPage
138+
ctx.Data["CodeIsDisabled"] = setting.Service.Explore.DisableCodePage
139139
ctx.Data["Title"] = ctx.Tr("explore")
140140
ctx.Data["PageIsExplore"] = true
141141
ctx.Data["PageIsExploreUsers"] = true

routers/web/home.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func Home(ctx *context.Context) {
6767
// HomeSitemap renders the main sitemap
6868
func HomeSitemap(ctx *context.Context) {
6969
m := sitemap.NewSitemapIndex()
70-
if !setting.Config().Service.ExplorePage.DisableUsersPage.Value(ctx) {
70+
if !setting.Service.Explore.DisableUsersPage {
7171
_, cnt, err := user_model.SearchUsers(ctx, &user_model.SearchUserOptions{
7272
Type: user_model.UserTypeIndividual,
7373
ListOptions: db.ListOptions{PageSize: 1},

0 commit comments

Comments
 (0)