diff --git a/modules/indexer/code/internal/indexer.go b/modules/indexer/code/internal/indexer.go index 440bd678f6..16e5772f10 100644 --- a/modules/indexer/code/internal/indexer.go +++ b/modules/indexer/code/internal/indexer.go @@ -26,7 +26,7 @@ type SearchOptions struct { Language string IsKeywordFuzzy bool - IsHtmlSafe bool + IsHTMLSafe bool db.Paginator } diff --git a/modules/indexer/code/search.go b/modules/indexer/code/search.go index 266eb81de3..fbce8b189d 100644 --- a/modules/indexer/code/search.go +++ b/modules/indexer/code/search.go @@ -102,7 +102,7 @@ func RawSearchResultCode(filename, language string, lineNums []int, code string) return lines } -func searchResult(result *internal.SearchResult, startIndex, endIndex int, escapeHtml bool) (*Result, error) { +func searchResult(result *internal.SearchResult, startIndex, endIndex int, escapeHTML bool) (*Result, error) { startLineNum := 1 + strings.Count(result.Content[:startIndex], "\n") var formattedLinesBuffer bytes.Buffer @@ -134,7 +134,7 @@ func searchResult(result *internal.SearchResult, startIndex, endIndex int, escap } var lines []*ResultLine - if escapeHtml { + if escapeHTML { lines = HighlightSearchResultCode(result.Filename, result.Language, lineNums, formattedLinesBuffer.String()) } else { lines = RawSearchResultCode(result.Filename, result.Language, lineNums, formattedLinesBuffer.String()) @@ -166,13 +166,13 @@ func PerformSearch(ctx context.Context, opts *SearchOptions) (int, []*Result, [] displayResults := make([]*Result, len(results)) nLinesBuffer := 0 - if opts.IsHtmlSafe { + if opts.IsHTMLSafe { nLinesBuffer = 1 } for i, result := range results { startIndex, endIndex := indices(result.Content, result.StartIndex, result.EndIndex, nLinesBuffer) - displayResults[i], err = searchResult(result, startIndex, endIndex, opts.IsHtmlSafe) + displayResults[i], err = searchResult(result, startIndex, endIndex, opts.IsHTMLSafe) if err != nil { return 0, nil, nil, err } diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index c1ca119c7e..df7d60dc75 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -85,6 +85,7 @@ import ( "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/routers/api/v1/activitypub" "code.gitea.io/gitea/routers/api/v1/admin" + "code.gitea.io/gitea/routers/api/v1/explore" "code.gitea.io/gitea/routers/api/v1/misc" "code.gitea.io/gitea/routers/api/v1/notify" "code.gitea.io/gitea/routers/api/v1/org" @@ -92,7 +93,6 @@ import ( "code.gitea.io/gitea/routers/api/v1/repo" "code.gitea.io/gitea/routers/api/v1/settings" "code.gitea.io/gitea/routers/api/v1/user" - "code.gitea.io/gitea/routers/api/v1/explore" "code.gitea.io/gitea/routers/common" "code.gitea.io/gitea/services/actions" "code.gitea.io/gitea/services/auth" diff --git a/routers/api/v1/explore/code.go b/routers/api/v1/explore/code.go index 11525bddb4..48a83f4b9c 100644 --- a/routers/api/v1/explore/code.go +++ b/routers/api/v1/explore/code.go @@ -94,7 +94,7 @@ func Code(ctx *context.APIContext) { RepoIDs: repoIDs, Keyword: keyword, IsKeywordFuzzy: isFuzzy, - IsHtmlSafe: false, + IsHTMLSafe: false, Paginator: &db.ListOptions{ Page: page, PageSize: setting.API.DefaultPagingNum, diff --git a/routers/api/v1/swagger/explore.go b/routers/api/v1/swagger/explore.go index f95c04d551..6c8ccd2cec 100644 --- a/routers/api/v1/swagger/explore.go +++ b/routers/api/v1/swagger/explore.go @@ -10,6 +10,6 @@ import ( // ExploreCode // swagger:response ExploreCode type swaggerResponseExploreCode struct { - // out:body - Body api.ExploreCodeResult `json:"body"` + // in:body + Body api.ExploreCodeResult `json:"body"` } diff --git a/routers/web/explore/code.go b/routers/web/explore/code.go index a4c14d3c0d..c1de9e8bfa 100644 --- a/routers/web/explore/code.go +++ b/routers/web/explore/code.go @@ -81,7 +81,7 @@ func Code(ctx *context.Context) { RepoIDs: repoIDs, Keyword: keyword, IsKeywordFuzzy: isFuzzy, - IsHtmlSafe: true, + IsHTMLSafe: true, Language: language, Paginator: &db.ListOptions{ Page: page, diff --git a/routers/web/repo/search.go b/routers/web/repo/search.go index 667bce249b..7b5dbf9b3b 100644 --- a/routers/web/repo/search.go +++ b/routers/web/repo/search.go @@ -59,7 +59,7 @@ func Search(ctx *context.Context) { RepoIDs: []int64{ctx.Repo.Repository.ID}, Keyword: keyword, IsKeywordFuzzy: isFuzzy, - IsHtmlSafe: true, + IsHTMLSafe: true, Language: language, Paginator: &db.ListOptions{ Page: page, diff --git a/routers/web/user/code.go b/routers/web/user/code.go index c3ac724acc..be357d3604 100644 --- a/routers/web/user/code.go +++ b/routers/web/user/code.go @@ -80,7 +80,7 @@ func CodeSearch(ctx *context.Context) { Keyword: keyword, IsKeywordFuzzy: isFuzzy, Language: language, - IsHtmlSafe: true, + IsHTMLSafe: true, Paginator: &db.ListOptions{ Page: page, PageSize: setting.UI.RepoSearchPagingNum, diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 228b44e8f2..011836925b 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -25484,11 +25484,6 @@ "description": "ExploreCode", "schema": { "$ref": "#/definitions/ExploreCodeResult" - }, - "headers": { - "body": { - "description": "out:body" - } } }, "FileDeleteResponse": { @@ -26337,4 +26332,4 @@ "TOTPHeader": [] } ] -} \ No newline at end of file +}