mirror of
https://github.com/go-gitea/gitea
synced 2024-12-22 09:37:53 +01:00
Split org Propfile README to a new tab overview
(#31373)
like user profile, add a new overviw tab to show profile READEME when it is exist. replace #31349 (another solution option) example view: ![屏幕截图 2024-06-14 094116](https://github.com/go-gitea/gitea/assets/25342410/3303a1f2-ae02-48e0-9519-7fa11e65657f) ![屏幕截图 2024-06-14 094101](https://github.com/go-gitea/gitea/assets/25342410/7a4a5a48-dc2b-4ad4-b2a2-9ea4ab5d5808) --------- Signed-off-by: a1012112796 <1012112796@qq.com>
This commit is contained in:
parent
521d91944e
commit
39d2fdefaf
@ -13,7 +13,6 @@ import (
|
|||||||
"code.gitea.io/gitea/models/organization"
|
"code.gitea.io/gitea/models/organization"
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
"code.gitea.io/gitea/modules/git"
|
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/markup"
|
"code.gitea.io/gitea/modules/markup"
|
||||||
"code.gitea.io/gitea/modules/markup/markdown"
|
"code.gitea.io/gitea/modules/markup/markdown"
|
||||||
@ -42,6 +41,14 @@ func Home(ctx *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
home(ctx, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Repositories(ctx *context.Context) {
|
||||||
|
home(ctx, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func home(ctx *context.Context, viewRepositories bool) {
|
||||||
org := ctx.Org.Organization
|
org := ctx.Org.Organization
|
||||||
|
|
||||||
ctx.Data["PageIsUserProfile"] = true
|
ctx.Data["PageIsUserProfile"] = true
|
||||||
@ -101,10 +108,34 @@ func Home(ctx *context.Context) {
|
|||||||
private := ctx.FormOptionalBool("private")
|
private := ctx.FormOptionalBool("private")
|
||||||
ctx.Data["IsPrivate"] = 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 (
|
var (
|
||||||
repos []*repo_model.Repository
|
repos []*repo_model.Repository
|
||||||
count int64
|
count int64
|
||||||
err error
|
|
||||||
)
|
)
|
||||||
repos, count, err = repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
|
repos, count, err = repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
|
||||||
ListOptions: db.ListOptions{
|
ListOptions: db.ListOptions{
|
||||||
@ -129,29 +160,8 @@ func Home(ctx *context.Context) {
|
|||||||
return
|
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["Repos"] = repos
|
||||||
ctx.Data["Total"] = count
|
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 := context.NewPagination(int(count), setting.UI.User.RepoPagingNum, page, 5)
|
||||||
pager.SetDefaultParams(ctx)
|
pager.SetDefaultParams(ctx)
|
||||||
@ -173,18 +183,16 @@ func Home(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
ctx.Data["Page"] = pager
|
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)
|
ctx.HTML(http.StatusOK, tplOrgHome)
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repository, profileDbRepo *repo_model.Repository, profileReadme *git.Blob) {
|
func prepareOrgProfileReadme(ctx *context.Context, viewRepositories bool) bool {
|
||||||
if profileGitRepo == nil || profileReadme == nil {
|
profileDbRepo, profileGitRepo, profileReadme, profileClose := shared_user.FindUserProfileReadme(ctx, ctx.Doer)
|
||||||
return
|
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 {
|
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["ProfileReadme"] = profileContent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.Data["PageIsViewOverview"] = true
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
@ -54,9 +54,9 @@ func Members(ctx *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = shared_user.LoadHeaderCount(ctx)
|
err = shared_user.RenderOrgHeader(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("LoadHeaderCount", err)
|
ctx.ServerError("RenderOrgHeader", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,9 +59,9 @@ func Teams(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
ctx.Data["Teams"] = ctx.Org.Teams
|
ctx.Data["Teams"] = ctx.Org.Teams
|
||||||
|
|
||||||
err := shared_user.LoadHeaderCount(ctx)
|
err := shared_user.RenderOrgHeader(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("LoadHeaderCount", err)
|
ctx.ServerError("RenderOrgHeader", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,3 +162,15 @@ func LoadHeaderCount(ctx *context.Context) error {
|
|||||||
|
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
@ -995,6 +995,8 @@ func registerRoutes(m *web.Router) {
|
|||||||
}, context.PackageAssignment(), reqPackageAccess(perm.AccessModeRead))
|
}, context.PackageAssignment(), reqPackageAccess(perm.AccessModeRead))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m.Get("/repositories", org.Repositories)
|
||||||
|
|
||||||
m.Group("/projects", func() {
|
m.Group("/projects", func() {
|
||||||
m.Group("", func() {
|
m.Group("", func() {
|
||||||
m.Get("", org.Projects)
|
m.Get("", org.Projects)
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
<div class="ui container">
|
<div class="ui container">
|
||||||
<overflow-menu class="ui secondary pointing tabular borderless menu tw-mb-4">
|
<overflow-menu class="ui secondary pointing tabular borderless menu tw-mb-4">
|
||||||
<div class="overflow-menu-items">
|
<div class="overflow-menu-items">
|
||||||
<a class="{{if .PageIsViewRepositories}}active {{end}}item" href="{{$.Org.HomeLink}}">
|
{{if .HasProfileReadme}}
|
||||||
|
<a class="{{if .PageIsViewOverview}}active {{end}}item" href="{{$.Org.HomeLink}}">
|
||||||
|
{{svg "octicon-info"}} {{ctx.Locale.Tr "user.overview"}}
|
||||||
|
</a>
|
||||||
|
{{end}}
|
||||||
|
<a class="{{if .PageIsViewRepositories}}active {{end}}item" href="{{$.Org.HomeLink}}{{if .HasProfileReadme}}/-/repositories{{end}}">
|
||||||
{{svg "octicon-repo"}} {{ctx.Locale.Tr "user.repositories"}}
|
{{svg "octicon-repo"}} {{ctx.Locale.Tr "user.repositories"}}
|
||||||
{{if .RepoCount}}
|
{{if .RepoCount}}
|
||||||
<div class="ui small label">{{.RepoCount}}</div>
|
<div class="ui small label">{{.RepoCount}}</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user