summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/admin/repos.go1
-rw-r--r--routers/home.go57
2 files changed, 23 insertions, 35 deletions
diff --git a/routers/admin/repos.go b/routers/admin/repos.go
index 12df6fba1e..8712797cf0 100644
--- a/routers/admin/repos.go
+++ b/routers/admin/repos.go
@@ -24,7 +24,6 @@ func Repos(ctx *context.Context) {
ctx.Data["PageIsAdminRepositories"] = true
routers.RenderRepoSearch(ctx, &routers.RepoSearchOptions{
- Ranger: models.Repositories,
Private: true,
PageSize: setting.UI.Admin.RepoPagingNum,
TplName: tplRepos,
diff --git a/routers/home.go b/routers/home.go
index 94c570b6ce..afcb3d35e5 100644
--- a/routers/home.go
+++ b/routers/home.go
@@ -60,8 +60,7 @@ func Swagger(ctx *context.Context) {
// RepoSearchOptions when calling search repositories
type RepoSearchOptions struct {
- Ranger func(*models.SearchRepoOptions) (models.RepositoryList, int64, error)
- Searcher *models.User
+ OwnerID int64
Private bool
PageSize int
TplName base.TplName
@@ -113,35 +112,21 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
}
keyword := strings.Trim(ctx.Query("q"), " ")
- if len(keyword) == 0 {
- repos, count, err = opts.Ranger(&models.SearchRepoOptions{
- Page: page,
- PageSize: opts.PageSize,
- Searcher: ctx.User,
- OrderBy: orderBy,
- Private: opts.Private,
- Collaborate: true,
- })
- if err != nil {
- ctx.Handle(500, "opts.Ranger", err)
- return
- }
- } else {
- if isKeywordValid(keyword) {
- repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
- Keyword: keyword,
- OrderBy: orderBy,
- Private: opts.Private,
- Page: page,
- PageSize: opts.PageSize,
- Searcher: ctx.User,
- Collaborate: true,
- })
- if err != nil {
- ctx.Handle(500, "SearchRepositoryByName", err)
- return
- }
- }
+
+ repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{
+ Page: page,
+ PageSize: opts.PageSize,
+ OrderBy: orderBy,
+ Private: opts.Private,
+ Keyword: keyword,
+ OwnerID: opts.OwnerID,
+ Searcher: ctx.User,
+ Collaborate: true,
+ AllPublic: true,
+ })
+ if err != nil {
+ ctx.Handle(500, "SearchRepositoryByName", err)
+ return
}
ctx.Data["Keyword"] = keyword
ctx.Data["Total"] = count
@@ -157,11 +142,15 @@ func ExploreRepos(ctx *context.Context) {
ctx.Data["PageIsExplore"] = true
ctx.Data["PageIsExploreRepositories"] = true
+ var ownerID int64
+ if ctx.User != nil && !ctx.User.IsAdmin {
+ ownerID = ctx.User.ID
+ }
+
RenderRepoSearch(ctx, &RepoSearchOptions{
- Ranger: models.GetRecentUpdatedRepositories,
PageSize: setting.UI.ExplorePagingNum,
- Searcher: ctx.User,
- Private: ctx.User != nil && ctx.User.IsAdmin,
+ OwnerID: ownerID,
+ Private: ctx.User != nil,
TplName: tplExploreRepos,
})
}