aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/web/org/home.go75
-rw-r--r--routers/web/org/members.go4
-rw-r--r--routers/web/org/teams.go4
-rw-r--r--routers/web/shared/user/header.go12
-rw-r--r--routers/web/web.go2
5 files changed, 61 insertions, 36 deletions
diff --git a/routers/web/org/home.go b/routers/web/org/home.go
index 77d49f5b78..366a7b20de 100644
--- a/routers/web/org/home.go
+++ b/routers/web/org/home.go
@@ -13,7 +13,6 @@ import (
"code.gitea.io/gitea/models/organization"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/base"
- "code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
@@ -42,6 +41,14 @@ func Home(ctx *context.Context) {
return
}
+ home(ctx, false)
+}
+
+func Repositories(ctx *context.Context) {
+ home(ctx, true)
+}
+
+func home(ctx *context.Context, viewRepositories bool) {
org := ctx.Org.Organization
ctx.Data["PageIsUserProfile"] = true
@@ -101,10 +108,34 @@ func Home(ctx *context.Context) {
private := ctx.FormOptionalBool("private")
ctx.Data["IsPrivate"] = private
+ err := shared_user.LoadHeaderCount(ctx)
+ if err != nil {
+ ctx.ServerError("LoadHeaderCount", err)
+ return
+ }
+
+ opts := &organization.FindOrgMembersOpts{
+ OrgID: org.ID,
+ PublicOnly: ctx.Org.PublicMemberOnly,
+ ListOptions: db.ListOptions{Page: 1, PageSize: 25},
+ }
+ members, _, err := organization.FindOrgMembers(ctx, opts)
+ if err != nil {
+ ctx.ServerError("FindOrgMembers", err)
+ return
+ }
+ ctx.Data["Members"] = members
+ ctx.Data["Teams"] = ctx.Org.Teams
+ ctx.Data["DisableNewPullMirrors"] = setting.Mirror.DisableNewPull
+ ctx.Data["ShowMemberAndTeamTab"] = ctx.Org.IsMember || len(members) > 0
+
+ if !prepareOrgProfileReadme(ctx, viewRepositories) {
+ ctx.Data["PageIsViewRepositories"] = true
+ }
+
var (
repos []*repo_model.Repository
count int64
- err error
)
repos, count, err = repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
ListOptions: db.ListOptions{
@@ -129,29 +160,8 @@ func Home(ctx *context.Context) {
return
}
- opts := &organization.FindOrgMembersOpts{
- OrgID: org.ID,
- PublicOnly: ctx.Org.PublicMemberOnly,
- ListOptions: db.ListOptions{Page: 1, PageSize: 25},
- }
- members, _, err := organization.FindOrgMembers(ctx, opts)
- if err != nil {
- ctx.ServerError("FindOrgMembers", err)
- return
- }
-
ctx.Data["Repos"] = repos
ctx.Data["Total"] = count
- ctx.Data["Members"] = members
- ctx.Data["Teams"] = ctx.Org.Teams
- ctx.Data["DisableNewPullMirrors"] = setting.Mirror.DisableNewPull
- ctx.Data["PageIsViewRepositories"] = true
-
- err = shared_user.LoadHeaderCount(ctx)
- if err != nil {
- ctx.ServerError("LoadHeaderCount", err)
- return
- }
pager := context.NewPagination(int(count), setting.UI.User.RepoPagingNum, page, 5)
pager.SetDefaultParams(ctx)
@@ -173,18 +183,16 @@ func Home(ctx *context.Context) {
}
ctx.Data["Page"] = pager
- ctx.Data["ShowMemberAndTeamTab"] = ctx.Org.IsMember || len(members) > 0
-
- profileDbRepo, profileGitRepo, profileReadmeBlob, profileClose := shared_user.FindUserProfileReadme(ctx, ctx.Doer)
- defer profileClose()
- prepareOrgProfileReadme(ctx, profileGitRepo, profileDbRepo, profileReadmeBlob)
-
ctx.HTML(http.StatusOK, tplOrgHome)
}
-func prepareOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repository, profileDbRepo *repo_model.Repository, profileReadme *git.Blob) {
- if profileGitRepo == nil || profileReadme == nil {
- return
+func prepareOrgProfileReadme(ctx *context.Context, viewRepositories bool) bool {
+ profileDbRepo, profileGitRepo, profileReadme, profileClose := shared_user.FindUserProfileReadme(ctx, ctx.Doer)
+ defer profileClose()
+ ctx.Data["HasProfileReadme"] = profileReadme != nil
+
+ if profileGitRepo == nil || profileReadme == nil || viewRepositories {
+ return false
}
if bytes, err := profileReadme.GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil {
@@ -206,4 +214,7 @@ func prepareOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repositor
ctx.Data["ProfileReadme"] = profileContent
}
}
+
+ ctx.Data["PageIsViewOverview"] = true
+ return true
}
diff --git a/routers/web/org/members.go b/routers/web/org/members.go
index 58d0b9b8c4..8ff75b0651 100644
--- a/routers/web/org/members.go
+++ b/routers/web/org/members.go
@@ -54,9 +54,9 @@ func Members(ctx *context.Context) {
return
}
- err = shared_user.LoadHeaderCount(ctx)
+ err = shared_user.RenderOrgHeader(ctx)
if err != nil {
- ctx.ServerError("LoadHeaderCount", err)
+ ctx.ServerError("RenderOrgHeader", err)
return
}
diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go
index aaac1177ae..31b9601ce7 100644
--- a/routers/web/org/teams.go
+++ b/routers/web/org/teams.go
@@ -59,9 +59,9 @@ func Teams(ctx *context.Context) {
}
ctx.Data["Teams"] = ctx.Org.Teams
- err := shared_user.LoadHeaderCount(ctx)
+ err := shared_user.RenderOrgHeader(ctx)
if err != nil {
- ctx.ServerError("LoadHeaderCount", err)
+ ctx.ServerError("RenderOrgHeader", err)
return
}
diff --git a/routers/web/shared/user/header.go b/routers/web/shared/user/header.go
index 7531e1ba26..ef111cff80 100644
--- a/routers/web/shared/user/header.go
+++ b/routers/web/shared/user/header.go
@@ -162,3 +162,15 @@ func LoadHeaderCount(ctx *context.Context) error {
return nil
}
+
+func RenderOrgHeader(ctx *context.Context) error {
+ if err := LoadHeaderCount(ctx); err != nil {
+ return err
+ }
+
+ _, _, profileReadmeBlob, profileClose := FindUserProfileReadme(ctx, ctx.Doer)
+ defer profileClose()
+ ctx.Data["HasProfileReadme"] = profileReadmeBlob != nil
+
+ return nil
+}
diff --git a/routers/web/web.go b/routers/web/web.go
index 4e917b5ede..98b4252cb9 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -995,6 +995,8 @@ func registerRoutes(m *web.Router) {
}, context.PackageAssignment(), reqPackageAccess(perm.AccessModeRead))
}
+ m.Get("/repositories", org.Repositories)
+
m.Group("/projects", func() {
m.Group("", func() {
m.Get("", org.Projects)