|
|
@ -1,4 +1,5 @@ |
|
|
|
// Copyright 2014 The Gogs Authors. All rights reserved.
|
|
|
|
// Copyright 2014 The Gogs Authors. All rights reserved.
|
|
|
|
|
|
|
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
|
@ -387,6 +388,37 @@ func showOrgProfile(ctx *context.Context) { |
|
|
|
org := ctx.Org.Organization |
|
|
|
org := ctx.Org.Organization |
|
|
|
ctx.Data["Title"] = org.DisplayName() |
|
|
|
ctx.Data["Title"] = org.DisplayName() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var orderBy models.SearchOrderBy |
|
|
|
|
|
|
|
ctx.Data["SortType"] = ctx.Query("sort") |
|
|
|
|
|
|
|
switch ctx.Query("sort") { |
|
|
|
|
|
|
|
case "newest": |
|
|
|
|
|
|
|
orderBy = models.SearchOrderByNewest |
|
|
|
|
|
|
|
case "oldest": |
|
|
|
|
|
|
|
orderBy = models.SearchOrderByOldest |
|
|
|
|
|
|
|
case "recentupdate": |
|
|
|
|
|
|
|
orderBy = models.SearchOrderByRecentUpdated |
|
|
|
|
|
|
|
case "leastupdate": |
|
|
|
|
|
|
|
orderBy = models.SearchOrderByLeastUpdated |
|
|
|
|
|
|
|
case "reversealphabetically": |
|
|
|
|
|
|
|
orderBy = models.SearchOrderByAlphabeticallyReverse |
|
|
|
|
|
|
|
case "alphabetically": |
|
|
|
|
|
|
|
orderBy = models.SearchOrderByAlphabetically |
|
|
|
|
|
|
|
case "moststars": |
|
|
|
|
|
|
|
orderBy = models.SearchOrderByStarsReverse |
|
|
|
|
|
|
|
case "feweststars": |
|
|
|
|
|
|
|
orderBy = models.SearchOrderByStars |
|
|
|
|
|
|
|
case "mostforks": |
|
|
|
|
|
|
|
orderBy = models.SearchOrderByForksReverse |
|
|
|
|
|
|
|
case "fewestforks": |
|
|
|
|
|
|
|
orderBy = models.SearchOrderByForks |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
ctx.Data["SortType"] = "recentupdate" |
|
|
|
|
|
|
|
orderBy = models.SearchOrderByRecentUpdated |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
keyword := strings.Trim(ctx.Query("q"), " ") |
|
|
|
|
|
|
|
ctx.Data["Keyword"] = keyword |
|
|
|
|
|
|
|
|
|
|
|
page := ctx.QueryInt("page") |
|
|
|
page := ctx.QueryInt("page") |
|
|
|
if page <= 0 { |
|
|
|
if page <= 0 { |
|
|
|
page = 1 |
|
|
|
page = 1 |
|
|
@ -403,6 +435,9 @@ func showOrgProfile(ctx *context.Context) { |
|
|
|
ctx.ServerError("AccessibleReposEnv", err) |
|
|
|
ctx.ServerError("AccessibleReposEnv", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if len(keyword) != 0 { |
|
|
|
|
|
|
|
env.AddKeyword(keyword) |
|
|
|
|
|
|
|
} |
|
|
|
repos, err = env.Repos(page, setting.UI.User.RepoPagingNum) |
|
|
|
repos, err = env.Repos(page, setting.UI.User.RepoPagingNum) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("env.Repos", err) |
|
|
|
ctx.ServerError("env.Repos", err) |
|
|
@ -413,25 +448,41 @@ func showOrgProfile(ctx *context.Context) { |
|
|
|
ctx.ServerError("env.CountRepos", err) |
|
|
|
ctx.ServerError("env.CountRepos", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["Repos"] = repos |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
showPrivate := ctx.IsSigned && ctx.User.IsAdmin |
|
|
|
showPrivate := ctx.IsSigned && ctx.User.IsAdmin |
|
|
|
repos, err = models.GetUserRepositories(org.ID, showPrivate, page, setting.UI.User.RepoPagingNum, "") |
|
|
|
if len(keyword) == 0 { |
|
|
|
|
|
|
|
repos, err = models.GetUserRepositories(org.ID, showPrivate, page, setting.UI.User.RepoPagingNum, orderBy.String()) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.ServerError("GetRepositories", err) |
|
|
|
ctx.ServerError("GetRepositories", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["Repos"] = repos |
|
|
|
|
|
|
|
count = models.CountUserRepositories(org.ID, showPrivate) |
|
|
|
count = models.CountUserRepositories(org.ID, showPrivate) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{ |
|
|
|
|
|
|
|
Keyword: keyword, |
|
|
|
|
|
|
|
OwnerID: org.ID, |
|
|
|
|
|
|
|
OrderBy: orderBy, |
|
|
|
|
|
|
|
Private: showPrivate, |
|
|
|
|
|
|
|
Page: page, |
|
|
|
|
|
|
|
IsProfile: true, |
|
|
|
|
|
|
|
PageSize: setting.UI.User.RepoPagingNum, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.ServerError("SearchRepositoryByName", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["Page"] = paginater.New(int(count), setting.UI.User.RepoPagingNum, page, 5) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err := org.GetMembers(); err != nil { |
|
|
|
if err := org.GetMembers(); err != nil { |
|
|
|
ctx.ServerError("GetMembers", err) |
|
|
|
ctx.ServerError("GetMembers", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["Members"] = org.Members |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["Repos"] = repos |
|
|
|
|
|
|
|
ctx.Data["Total"] = count |
|
|
|
|
|
|
|
ctx.Data["Page"] = paginater.New(int(count), setting.UI.User.RepoPagingNum, page, 5) |
|
|
|
|
|
|
|
ctx.Data["Members"] = org.Members |
|
|
|
ctx.Data["Teams"] = org.Teams |
|
|
|
ctx.Data["Teams"] = org.Teams |
|
|
|
|
|
|
|
|
|
|
|
ctx.HTML(200, tplOrgHome) |
|
|
|
ctx.HTML(200, tplOrgHome) |
|
|
|