parent
7e382a5555
commit
f3fbb7c67d
9 changed files with 211 additions and 106 deletions
|
@ -16,6 +16,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/markup/markdown"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
shared_user "code.gitea.io/gitea/routers/web/shared/user"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -158,6 +159,12 @@ func Home(ctx *context.Context) {
|
|||
ctx.Data["PageIsViewRepositories"] = true
|
||||
ctx.Data["IsFollowing"] = isFollowing
|
||||
|
||||
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)
|
||||
pager.AddParam(ctx, "language", "Language")
|
||||
|
|
|
@ -101,6 +101,12 @@ func Projects(ctx *context.Context) {
|
|||
project.RenderedContent = project.Description
|
||||
}
|
||||
|
||||
err = shared_user.LoadHeaderCount(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadHeaderCount", err)
|
||||
return
|
||||
}
|
||||
|
||||
numPages := 0
|
||||
if total > 0 {
|
||||
numPages = (int(total) - 1/setting.UI.IssuePagingNum)
|
||||
|
@ -135,6 +141,13 @@ func RenderNewProject(ctx *context.Context) {
|
|||
ctx.Data["HomeLink"] = ctx.ContextUser.HomeLink()
|
||||
ctx.Data["CancelLink"] = ctx.ContextUser.HomeLink() + "/-/projects"
|
||||
shared_user.RenderUserHeader(ctx)
|
||||
|
||||
err := shared_user.LoadHeaderCount(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadHeaderCount", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.HTML(http.StatusOK, tplProjectsNew)
|
||||
}
|
||||
|
||||
|
@ -270,6 +283,12 @@ func EditProjectPost(ctx *context.Context) {
|
|||
|
||||
shared_user.RenderUserHeader(ctx)
|
||||
|
||||
err := shared_user.LoadHeaderCount(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadHeaderCount", err)
|
||||
return
|
||||
}
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(http.StatusOK, tplProjectsNew)
|
||||
return
|
||||
|
@ -379,6 +398,12 @@ func ViewProject(ctx *context.Context) {
|
|||
ctx.Data["Boards"] = boards
|
||||
shared_user.RenderUserHeader(ctx)
|
||||
|
||||
err = shared_user.LoadHeaderCount(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadHeaderCount", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.HTML(http.StatusOK, tplProjectsView)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/markup/markdown"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
)
|
||||
|
||||
// prepareContextForCommonProfile store some common data into context data for user's profile related pages (including the nav menu)
|
||||
|
@ -110,3 +111,21 @@ func RenderUserHeader(ctx *context.Context) {
|
|||
defer profileClose()
|
||||
ctx.Data["HasProfileReadme"] = profileReadmeBlob != nil
|
||||
}
|
||||
|
||||
func LoadHeaderCount(ctx *context.Context) error {
|
||||
prepareContextForCommonProfile(ctx)
|
||||
|
||||
repoCount, err := repo_model.CountRepository(ctx, &repo_model.SearchRepoOptions{
|
||||
Actor: ctx.Doer,
|
||||
OwnerID: ctx.ContextUser.ID,
|
||||
Private: ctx.IsSigned,
|
||||
Collaborate: util.OptionalBoolFalse,
|
||||
IncludeDescription: setting.UI.SearchRepoDescription,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctx.Data["RepoCount"] = repoCount
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -101,6 +101,12 @@ func ListPackages(ctx *context.Context) {
|
|||
ctx.Data["Total"] = total
|
||||
ctx.Data["RepositoryAccessMap"] = repositoryAccessMap
|
||||
|
||||
err = shared_user.LoadHeaderCount(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadHeaderCount", err)
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: context/org -> HandleOrgAssignment() can not be used
|
||||
if ctx.ContextUser.IsOrganization() {
|
||||
org := org_model.OrgFromUser(ctx.ContextUser)
|
||||
|
@ -255,6 +261,12 @@ func ViewPackageVersion(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["HasRepositoryAccess"] = hasRepositoryAccess
|
||||
|
||||
err = shared_user.LoadHeaderCount(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadHeaderCount", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.HTML(http.StatusOK, tplPackagesView)
|
||||
}
|
||||
|
||||
|
@ -346,6 +358,12 @@ func ListPackageVersions(ctx *context.Context) {
|
|||
|
||||
ctx.Data["Total"] = total
|
||||
|
||||
err = shared_user.LoadHeaderCount(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadHeaderCount", err)
|
||||
return
|
||||
}
|
||||
|
||||
pager := context.NewPagination(int(total), setting.UI.PackagesPagingNum, page, 5)
|
||||
for k, v := range pagerParams {
|
||||
pager.AddParamString(k, v)
|
||||
|
|
|
@ -269,6 +269,12 @@ func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileGi
|
|||
ctx.Data["Repos"] = repos
|
||||
ctx.Data["Total"] = total
|
||||
|
||||
err = shared_user.LoadHeaderCount(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("LoadHeaderCount", err)
|
||||
return
|
||||
}
|
||||
|
||||
pager := context.NewPagination(total, pagingNum, page, 5)
|
||||
pager.SetDefaultParams(ctx)
|
||||
pager.AddParam(ctx, "tab", "TabName")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue