@@ -13,7 +13,6 @@ import (
1313 "code.gitea.io/gitea/models/organization"
1414 repo_model "code.gitea.io/gitea/models/repo"
1515 "code.gitea.io/gitea/modules/base"
16- "code.gitea.io/gitea/modules/git"
1716 "code.gitea.io/gitea/modules/log"
1817 "code.gitea.io/gitea/modules/markup"
1918 "code.gitea.io/gitea/modules/markup/markdown"
@@ -42,6 +41,14 @@ func Home(ctx *context.Context) {
4241 return
4342 }
4443
44+ home (ctx , false )
45+ }
46+
47+ func Repositories (ctx * context.Context ) {
48+ home (ctx , true )
49+ }
50+
51+ func home (ctx * context.Context , viewRepositories bool ) {
4552 org := ctx .Org .Organization
4653
4754 ctx .Data ["PageIsUserProfile" ] = true
@@ -101,10 +108,34 @@ func Home(ctx *context.Context) {
101108 private := ctx .FormOptionalBool ("private" )
102109 ctx .Data ["IsPrivate" ] = private
103110
111+ err := shared_user .LoadHeaderCount (ctx )
112+ if err != nil {
113+ ctx .ServerError ("LoadHeaderCount" , err )
114+ return
115+ }
116+
117+ opts := & organization.FindOrgMembersOpts {
118+ OrgID : org .ID ,
119+ PublicOnly : ctx .Org .PublicMemberOnly ,
120+ ListOptions : db.ListOptions {Page : 1 , PageSize : 25 },
121+ }
122+ members , _ , err := organization .FindOrgMembers (ctx , opts )
123+ if err != nil {
124+ ctx .ServerError ("FindOrgMembers" , err )
125+ return
126+ }
127+ ctx .Data ["Members" ] = members
128+ ctx .Data ["Teams" ] = ctx .Org .Teams
129+ ctx .Data ["DisableNewPullMirrors" ] = setting .Mirror .DisableNewPull
130+ ctx .Data ["ShowMemberAndTeamTab" ] = ctx .Org .IsMember || len (members ) > 0
131+
132+ if ! prepareOrgProfileReadme (ctx , viewRepositories ) {
133+ ctx .Data ["PageIsViewRepositories" ] = true
134+ }
135+
104136 var (
105137 repos []* repo_model.Repository
106138 count int64
107- err error
108139 )
109140 repos , count , err = repo_model .SearchRepository (ctx , & repo_model.SearchRepoOptions {
110141 ListOptions : db.ListOptions {
@@ -129,29 +160,8 @@ func Home(ctx *context.Context) {
129160 return
130161 }
131162
132- opts := & organization.FindOrgMembersOpts {
133- OrgID : org .ID ,
134- PublicOnly : ctx .Org .PublicMemberOnly ,
135- ListOptions : db.ListOptions {Page : 1 , PageSize : 25 },
136- }
137- members , _ , err := organization .FindOrgMembers (ctx , opts )
138- if err != nil {
139- ctx .ServerError ("FindOrgMembers" , err )
140- return
141- }
142-
143163 ctx .Data ["Repos" ] = repos
144164 ctx .Data ["Total" ] = count
145- ctx .Data ["Members" ] = members
146- ctx .Data ["Teams" ] = ctx .Org .Teams
147- ctx .Data ["DisableNewPullMirrors" ] = setting .Mirror .DisableNewPull
148- ctx .Data ["PageIsViewRepositories" ] = true
149-
150- err = shared_user .LoadHeaderCount (ctx )
151- if err != nil {
152- ctx .ServerError ("LoadHeaderCount" , err )
153- return
154- }
155165
156166 pager := context .NewPagination (int (count ), setting .UI .User .RepoPagingNum , page , 5 )
157167 pager .SetDefaultParams (ctx )
@@ -173,18 +183,16 @@ func Home(ctx *context.Context) {
173183 }
174184 ctx .Data ["Page" ] = pager
175185
176- ctx .Data ["ShowMemberAndTeamTab" ] = ctx .Org .IsMember || len (members ) > 0
177-
178- profileDbRepo , profileGitRepo , profileReadmeBlob , profileClose := shared_user .FindUserProfileReadme (ctx , ctx .Doer )
179- defer profileClose ()
180- prepareOrgProfileReadme (ctx , profileGitRepo , profileDbRepo , profileReadmeBlob )
181-
182186 ctx .HTML (http .StatusOK , tplOrgHome )
183187}
184188
185- func prepareOrgProfileReadme (ctx * context.Context , profileGitRepo * git.Repository , profileDbRepo * repo_model.Repository , profileReadme * git.Blob ) {
186- if profileGitRepo == nil || profileReadme == nil {
187- return
189+ func prepareOrgProfileReadme (ctx * context.Context , viewRepositories bool ) bool {
190+ profileDbRepo , profileGitRepo , profileReadme , profileClose := shared_user .FindUserProfileReadme (ctx , ctx .Doer )
191+ defer profileClose ()
192+ ctx .Data ["HasProfileReadme" ] = profileReadme != nil
193+
194+ if profileGitRepo == nil || profileReadme == nil || viewRepositories {
195+ return false
188196 }
189197
190198 if bytes , err := profileReadme .GetBlobContent (setting .UI .MaxDisplayFileSize ); err != nil {
@@ -206,4 +214,7 @@ func prepareOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repositor
206214 ctx .Data ["ProfileReadme" ] = profileContent
207215 }
208216 }
217+
218+ ctx .Data ["PageIsViewOverview" ] = true
219+ return true
209220}
0 commit comments