From ea20adaa84cbff762fcaa7f2d5fa6b7bf56706ec Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 13 Sep 2018 10:33:48 +0800 Subject: feat(repo): support search repository by topic name (#4505) * feat(repo): support search repository by topic name --- routers/api/v1/repo/repo.go | 1 + routers/home.go | 2 ++ routers/user/profile.go | 4 ++++ 3 files changed, 7 insertions(+) (limited to 'routers') diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 90acde2eea..e48b100af6 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -91,6 +91,7 @@ func Search(ctx *context.APIContext) { OwnerID: ctx.QueryInt64("uid"), Page: ctx.QueryInt("page"), PageSize: convert.ToCorrectPageSize(ctx.QueryInt("limit")), + TopicOnly: ctx.QueryBool("topic"), Collaborate: util.OptionalBoolNone, } diff --git a/routers/home.go b/routers/home.go index 0aa907658c..7a23e8765e 100644 --- a/routers/home.go +++ b/routers/home.go @@ -122,6 +122,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { } keyword := strings.Trim(ctx.Query("q"), " ") + topicOnly := ctx.QueryBool("topic") repos, count, err = models.SearchRepositoryByName(&models.SearchRepoOptions{ Page: page, @@ -131,6 +132,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) { Keyword: keyword, OwnerID: opts.OwnerID, AllPublic: true, + TopicOnly: topicOnly, }) if err != nil { ctx.ServerError("SearchRepositoryByName", err) diff --git a/routers/user/profile.go b/routers/user/profile.go index fb731e715c..827226d3e1 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -105,6 +105,8 @@ func Profile(ctx *context.Context) { page = 1 } + topicOnly := ctx.QueryBool("topic") + var ( repos []*models.Repository count int64 @@ -174,6 +176,7 @@ func Profile(ctx *context.Context) { PageSize: setting.UI.User.RepoPagingNum, Starred: true, Collaborate: util.OptionalBoolFalse, + TopicOnly: topicOnly, }) if err != nil { ctx.ServerError("SearchRepositoryByName", err) @@ -217,6 +220,7 @@ func Profile(ctx *context.Context) { IsProfile: true, PageSize: setting.UI.User.RepoPagingNum, Collaborate: util.OptionalBoolFalse, + TopicOnly: topicOnly, }) if err != nil { ctx.ServerError("SearchRepositoryByName", err) -- cgit v1.2.3