mirror of
https://github.com/go-gitea/gitea.git
synced 2025-02-02 15:09:33 -05:00
fix formatting
This commit is contained in:
parent
ed8d76be3b
commit
a3a47886c8
@ -26,7 +26,7 @@ type SearchOptions struct {
|
|||||||
Language string
|
Language string
|
||||||
|
|
||||||
IsKeywordFuzzy bool
|
IsKeywordFuzzy bool
|
||||||
IsHtmlSafe bool
|
IsHTMLSafe bool
|
||||||
|
|
||||||
db.Paginator
|
db.Paginator
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ func RawSearchResultCode(filename, language string, lineNums []int, code string)
|
|||||||
return lines
|
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")
|
startLineNum := 1 + strings.Count(result.Content[:startIndex], "\n")
|
||||||
|
|
||||||
var formattedLinesBuffer bytes.Buffer
|
var formattedLinesBuffer bytes.Buffer
|
||||||
@ -134,7 +134,7 @@ func searchResult(result *internal.SearchResult, startIndex, endIndex int, escap
|
|||||||
}
|
}
|
||||||
|
|
||||||
var lines []*ResultLine
|
var lines []*ResultLine
|
||||||
if escapeHtml {
|
if escapeHTML {
|
||||||
lines = HighlightSearchResultCode(result.Filename, result.Language, lineNums, formattedLinesBuffer.String())
|
lines = HighlightSearchResultCode(result.Filename, result.Language, lineNums, formattedLinesBuffer.String())
|
||||||
} else {
|
} else {
|
||||||
lines = RawSearchResultCode(result.Filename, result.Language, lineNums, formattedLinesBuffer.String())
|
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))
|
displayResults := make([]*Result, len(results))
|
||||||
|
|
||||||
nLinesBuffer := 0
|
nLinesBuffer := 0
|
||||||
if opts.IsHtmlSafe {
|
if opts.IsHTMLSafe {
|
||||||
nLinesBuffer = 1
|
nLinesBuffer = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, result := range results {
|
for i, result := range results {
|
||||||
startIndex, endIndex := indices(result.Content, result.StartIndex, result.EndIndex, nLinesBuffer)
|
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 {
|
if err != nil {
|
||||||
return 0, nil, nil, err
|
return 0, nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
"code.gitea.io/gitea/routers/api/v1/activitypub"
|
"code.gitea.io/gitea/routers/api/v1/activitypub"
|
||||||
"code.gitea.io/gitea/routers/api/v1/admin"
|
"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/misc"
|
||||||
"code.gitea.io/gitea/routers/api/v1/notify"
|
"code.gitea.io/gitea/routers/api/v1/notify"
|
||||||
"code.gitea.io/gitea/routers/api/v1/org"
|
"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/repo"
|
||||||
"code.gitea.io/gitea/routers/api/v1/settings"
|
"code.gitea.io/gitea/routers/api/v1/settings"
|
||||||
"code.gitea.io/gitea/routers/api/v1/user"
|
"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/routers/common"
|
||||||
"code.gitea.io/gitea/services/actions"
|
"code.gitea.io/gitea/services/actions"
|
||||||
"code.gitea.io/gitea/services/auth"
|
"code.gitea.io/gitea/services/auth"
|
||||||
|
@ -94,7 +94,7 @@ func Code(ctx *context.APIContext) {
|
|||||||
RepoIDs: repoIDs,
|
RepoIDs: repoIDs,
|
||||||
Keyword: keyword,
|
Keyword: keyword,
|
||||||
IsKeywordFuzzy: isFuzzy,
|
IsKeywordFuzzy: isFuzzy,
|
||||||
IsHtmlSafe: false,
|
IsHTMLSafe: false,
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
Page: page,
|
Page: page,
|
||||||
PageSize: setting.API.DefaultPagingNum,
|
PageSize: setting.API.DefaultPagingNum,
|
||||||
|
@ -10,6 +10,6 @@ import (
|
|||||||
// ExploreCode
|
// ExploreCode
|
||||||
// swagger:response ExploreCode
|
// swagger:response ExploreCode
|
||||||
type swaggerResponseExploreCode struct {
|
type swaggerResponseExploreCode struct {
|
||||||
// out:body
|
// in:body
|
||||||
Body api.ExploreCodeResult `json:"body"`
|
Body api.ExploreCodeResult `json:"body"`
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ func Code(ctx *context.Context) {
|
|||||||
RepoIDs: repoIDs,
|
RepoIDs: repoIDs,
|
||||||
Keyword: keyword,
|
Keyword: keyword,
|
||||||
IsKeywordFuzzy: isFuzzy,
|
IsKeywordFuzzy: isFuzzy,
|
||||||
IsHtmlSafe: true,
|
IsHTMLSafe: true,
|
||||||
Language: language,
|
Language: language,
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
Page: page,
|
Page: page,
|
||||||
|
@ -59,7 +59,7 @@ func Search(ctx *context.Context) {
|
|||||||
RepoIDs: []int64{ctx.Repo.Repository.ID},
|
RepoIDs: []int64{ctx.Repo.Repository.ID},
|
||||||
Keyword: keyword,
|
Keyword: keyword,
|
||||||
IsKeywordFuzzy: isFuzzy,
|
IsKeywordFuzzy: isFuzzy,
|
||||||
IsHtmlSafe: true,
|
IsHTMLSafe: true,
|
||||||
Language: language,
|
Language: language,
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
Page: page,
|
Page: page,
|
||||||
|
@ -80,7 +80,7 @@ func CodeSearch(ctx *context.Context) {
|
|||||||
Keyword: keyword,
|
Keyword: keyword,
|
||||||
IsKeywordFuzzy: isFuzzy,
|
IsKeywordFuzzy: isFuzzy,
|
||||||
Language: language,
|
Language: language,
|
||||||
IsHtmlSafe: true,
|
IsHTMLSafe: true,
|
||||||
Paginator: &db.ListOptions{
|
Paginator: &db.ListOptions{
|
||||||
Page: page,
|
Page: page,
|
||||||
PageSize: setting.UI.RepoSearchPagingNum,
|
PageSize: setting.UI.RepoSearchPagingNum,
|
||||||
|
7
templates/swagger/v1_json.tmpl
generated
7
templates/swagger/v1_json.tmpl
generated
@ -25484,11 +25484,6 @@
|
|||||||
"description": "ExploreCode",
|
"description": "ExploreCode",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/ExploreCodeResult"
|
"$ref": "#/definitions/ExploreCodeResult"
|
||||||
},
|
|
||||||
"headers": {
|
|
||||||
"body": {
|
|
||||||
"description": "out:body"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"FileDeleteResponse": {
|
"FileDeleteResponse": {
|
||||||
@ -26337,4 +26332,4 @@
|
|||||||
"TOTPHeader": []
|
"TOTPHeader": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user