mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
Add user/organization code search (#19977)
Fixes #19925 Screenshots: 
This commit is contained in:
parent
3ccebf7f40
commit
b59b0cad0a
19 changed files with 355 additions and 159 deletions
|
@ -21,14 +21,27 @@ func Search(ctx *context.Context) {
|
|||
ctx.Redirect(ctx.Repo.RepoLink)
|
||||
return
|
||||
}
|
||||
|
||||
language := ctx.FormTrim("l")
|
||||
keyword := ctx.FormTrim("q")
|
||||
|
||||
queryType := ctx.FormTrim("t")
|
||||
isMatch := queryType == "match"
|
||||
|
||||
ctx.Data["Keyword"] = keyword
|
||||
ctx.Data["Language"] = language
|
||||
ctx.Data["queryType"] = queryType
|
||||
ctx.Data["PageIsViewCode"] = true
|
||||
|
||||
if keyword == "" {
|
||||
ctx.HTML(http.StatusOK, tplSearch)
|
||||
return
|
||||
}
|
||||
|
||||
page := ctx.FormInt("page")
|
||||
if page <= 0 {
|
||||
page = 1
|
||||
}
|
||||
queryType := ctx.FormTrim("t")
|
||||
isMatch := queryType == "match"
|
||||
|
||||
total, searchResults, searchResultLanguages, err := code_indexer.PerformSearch(ctx, []int64{ctx.Repo.Repository.ID},
|
||||
language, keyword, page, setting.UI.RepoSearchPagingNum, isMatch)
|
||||
|
@ -41,13 +54,10 @@ func Search(ctx *context.Context) {
|
|||
} else {
|
||||
ctx.Data["CodeIndexerUnavailable"] = !code_indexer.IsAvailable()
|
||||
}
|
||||
ctx.Data["Keyword"] = keyword
|
||||
ctx.Data["Language"] = language
|
||||
ctx.Data["queryType"] = queryType
|
||||
|
||||
ctx.Data["SourcePath"] = ctx.Repo.Repository.HTMLURL()
|
||||
ctx.Data["SearchResults"] = searchResults
|
||||
ctx.Data["SearchResultLanguages"] = searchResultLanguages
|
||||
ctx.Data["PageIsViewCode"] = true
|
||||
|
||||
pager := context.NewPagination(total, setting.UI.RepoSearchPagingNum, page, 5)
|
||||
pager.SetDefaultParams(ctx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue