diff options
author | Alexey Terentyev <terentyev.alexey@gmail.com> | 2018-05-24 04:03:42 +0300 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2018-05-24 09:03:42 +0800 |
commit | b908ac9fab141b72f38db3d40a9f6054bb701982 (patch) | |
tree | 11a91f0a12fa32b0fa834d0388949fb59d13f4a2 /routers | |
parent | ea2a938e8a25588634364b3bc6ce8d6634ae4c60 (diff) | |
download | gitea-b908ac9fab141b72f38db3d40a9f6054bb701982.tar.gz gitea-b908ac9fab141b72f38db3d40a9f6054bb701982.zip |
Added repository search ordered by stars or forks. Forks column in admin repo list. (#3969)
* Added repository search order by stars or forks.
Added Forks column to admin repository list.
Signed-off-by: Alexey Terentyev <axifnx@gmail.com>
* Renamed search repo template
Signed-off-by: Alexey Terentyev <axifnx@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/home.go | 24 | ||||
-rw-r--r-- | routers/user/profile.go | 8 |
2 files changed, 24 insertions, 8 deletions
diff --git a/routers/home.go b/routers/home.go index 4810eb4e6f..5bb353c7e1 100644 --- a/routers/home.go +++ b/routers/home.go @@ -104,6 +104,14 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { orderBy = models.SearchOrderBySizeReverse case "size": orderBy = models.SearchOrderBySize + 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 @@ -164,26 +172,26 @@ func RenderUserSearch(ctx *context.Context, opts *models.SearchUserOptions, tplN users []*models.User count int64 err error - orderBy string + orderBy models.SearchOrderBy ) ctx.Data["SortType"] = ctx.Query("sort") switch ctx.Query("sort") { case "newest": - orderBy = "id DESC" + orderBy = models.SearchOrderByIDReverse case "oldest": - orderBy = "id ASC" + orderBy = models.SearchOrderByID case "recentupdate": - orderBy = "updated_unix DESC" + orderBy = models.SearchOrderByRecentUpdated case "leastupdate": - orderBy = "updated_unix ASC" + orderBy = models.SearchOrderByLeastUpdated case "reversealphabetically": - orderBy = "name DESC" + orderBy = models.SearchOrderByAlphabeticallyReverse case "alphabetically": - orderBy = "name ASC" + orderBy = models.SearchOrderByAlphabetically default: ctx.Data["SortType"] = "alphabetically" - orderBy = "name ASC" + orderBy = models.SearchOrderByAlphabetically } opts.Keyword = strings.Trim(ctx.Query("q"), " ") diff --git a/routers/user/profile.go b/routers/user/profile.go index 6f8b8fe897..fb731e715c 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -125,6 +125,14 @@ func Profile(ctx *context.Context) { 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 |