Skip to content

Commit 0b04828

Browse files
committed
add DISABLE_ORGANIZATIONS_PAGE and DISABLE_CODE_PAGE settings
1 parent 2b8ff41 commit 0b04828

File tree

7 files changed

+40
-3
lines changed

7 files changed

+40
-3
lines changed

custom/conf/app.example.ini

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,24 @@ LEVEL = Info
907907
;; Valid site url schemes for user profiles
908908
;VALID_SITE_URL_SCHEMES=http,https
909909

910+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
911+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
912+
;[service.explore]
913+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
914+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
915+
;;
916+
;; Only allow signed in users to view the explore pages.
917+
;REQUIRE_SIGNIN_VIEW = false
918+
;;
919+
;; Disable the users explore page.
920+
;DISABLE_USERS_PAGE = false
921+
;;
922+
;; Disable the organizations explore page.
923+
;DISABLE_ORGANIZATIONS_PAGE = false
924+
;;
925+
;; Disable the code explore page.
926+
;DISABLE_CODE_PAGE = false
927+
;;
910928

911929
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
912930
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

modules/setting/service.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ var Service = struct {
9090

9191
// Explore page settings
9292
Explore struct {
93-
RequireSigninView bool `ini:"REQUIRE_SIGNIN_VIEW"`
94-
DisableUsersPage bool `ini:"DISABLE_USERS_PAGE"`
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"`
9597
} `ini:"service.explore"`
9698
}{
9799
AllowedUserVisibilityModesSlice: []bool{true, true, true},

routers/web/explore/code.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ func Code(ctx *context.Context) {
2525
ctx.Redirect(setting.AppSubURL + "/explore")
2626
return
2727
}
28+
if setting.Service.Explore.DisableCodePage {
29+
ctx.Redirect(setting.AppSubURL + "/explore/repos")
30+
return
31+
}
2832

2933
ctx.Data["UsersIsDisabled"] = setting.Service.Explore.DisableUsersPage
34+
ctx.Data["OrganizationsIsDisabled"] = setting.Service.Explore.DisableOrganizationsPage
3035
ctx.Data["IsRepoIndexerEnabled"] = setting.Indexer.RepoIndexerEnabled
3136
ctx.Data["Title"] = ctx.Tr("explore")
3237
ctx.Data["PageIsExplore"] = true

routers/web/explore/org.go

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

1515
// Organizations render explore organizations page
1616
func Organizations(ctx *context.Context) {
17+
if setting.Service.Explore.DisableOrganizationsPage {
18+
ctx.Redirect(setting.AppSubURL + "/explore/repos")
19+
return
20+
}
21+
1722
ctx.Data["UsersIsDisabled"] = setting.Service.Explore.DisableUsersPage
23+
ctx.Data["CodeIsDisabled"] = setting.Service.Explore.DisableCodePage
1824
ctx.Data["Title"] = ctx.Tr("explore")
1925
ctx.Data["PageIsExplore"] = true
2026
ctx.Data["PageIsExploreOrganizations"] = true

routers/web/explore/repo.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
166166
// Repos render explore repositories page
167167
func Repos(ctx *context.Context) {
168168
ctx.Data["UsersIsDisabled"] = setting.Service.Explore.DisableUsersPage
169+
ctx.Data["OrganizationsIsDisabled"] = setting.Service.Explore.DisableOrganizationsPage
170+
ctx.Data["CodeIsDisabled"] = setting.Service.Explore.DisableCodePage
169171
ctx.Data["Title"] = ctx.Tr("explore")
170172
ctx.Data["PageIsExplore"] = true
171173
ctx.Data["PageIsExploreRepositories"] = true

routers/web/explore/user.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ func Users(ctx *context.Context) {
134134
ctx.Redirect(setting.AppSubURL + "/explore/repos")
135135
return
136136
}
137+
ctx.Data["OrganizationsIsDisabled"] = setting.Service.Explore.DisableOrganizationsPage
138+
ctx.Data["CodeIsDisabled"] = setting.Service.Explore.DisableCodePage
137139
ctx.Data["Title"] = ctx.Tr("explore")
138140
ctx.Data["PageIsExplore"] = true
139141
ctx.Data["PageIsExploreUsers"] = true

templates/explore/navbar.tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
{{svg "octicon-person"}} {{ctx.Locale.Tr "explore.users"}}
99
</a>
1010
{{end}}
11+
{{if not .OrganizationsIsDisabled}}
1112
<a class="{{if .PageIsExploreOrganizations}}active {{end}}item" href="{{AppSubUrl}}/explore/organizations">
1213
{{svg "octicon-organization"}} {{ctx.Locale.Tr "explore.organizations"}}
1314
</a>
14-
{{if and (not ctx.Consts.RepoUnitTypeCode.UnitGlobalDisabled) .IsRepoIndexerEnabled}}
15+
{{end}}
16+
{{if and (not ctx.Consts.RepoUnitTypeCode.UnitGlobalDisabled) (and .IsRepoIndexerEnabled (not .CodeIsDisabled))}}
1517
<a class="{{if .PageIsExploreCode}}active {{end}}item" href="{{AppSubUrl}}/explore/code">
1618
{{svg "octicon-code"}} {{ctx.Locale.Tr "explore.code"}}
1719
</a>

0 commit comments

Comments
 (0)