diff options
Diffstat (limited to 'routers/home.go')
-rw-r--r-- | routers/home.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/routers/home.go b/routers/home.go index 77a7e153e2..1b8c4cd17b 100644 --- a/routers/home.go +++ b/routers/home.go @@ -290,6 +290,7 @@ func ExploreCode(ctx *context.Context) { ctx.Data["PageIsExplore"] = true ctx.Data["PageIsExploreCode"] = true + language := strings.TrimSpace(ctx.Query("l")) keyword := strings.TrimSpace(ctx.Query("q")) page := ctx.QueryInt("page") if page <= 0 { @@ -317,8 +318,9 @@ func ExploreCode(ctx *context.Context) { } var ( - total int - searchResults []*code_indexer.Result + total int + searchResults []*code_indexer.Result + searchResultLanguages []*code_indexer.SearchResultLanguages ) // if non-admin login user, we need check UnitTypeCode at first @@ -340,14 +342,14 @@ func ExploreCode(ctx *context.Context) { ctx.Data["RepoMaps"] = rightRepoMap - total, searchResults, err = code_indexer.PerformSearch(repoIDs, keyword, page, setting.UI.RepoSearchPagingNum) + total, searchResults, searchResultLanguages, err = code_indexer.PerformSearch(repoIDs, language, keyword, page, setting.UI.RepoSearchPagingNum) if err != nil { ctx.ServerError("SearchResults", err) return } // if non-login user or isAdmin, no need to check UnitTypeCode } else if (ctx.User == nil && len(repoIDs) > 0) || isAdmin { - total, searchResults, err = code_indexer.PerformSearch(repoIDs, keyword, page, setting.UI.RepoSearchPagingNum) + total, searchResults, searchResultLanguages, err = code_indexer.PerformSearch(repoIDs, language, keyword, page, setting.UI.RepoSearchPagingNum) if err != nil { ctx.ServerError("SearchResults", err) return @@ -377,12 +379,15 @@ func ExploreCode(ctx *context.Context) { } ctx.Data["Keyword"] = keyword + ctx.Data["Language"] = language ctx.Data["SearchResults"] = searchResults + ctx.Data["SearchResultLanguages"] = searchResultLanguages ctx.Data["RequireHighlightJS"] = true ctx.Data["PageIsViewCode"] = true pager := context.NewPagination(total, setting.UI.RepoSearchPagingNum, page, 5) pager.SetDefaultParams(ctx) + pager.AddParam(ctx, "l", "Language") ctx.Data["Page"] = pager ctx.HTML(200, tplExploreCode) |