diff --git a/internal/html/repo_search.templ b/internal/html/repo_search.templ index 0afeeec00e0be4333fa135a8f017487fbb23ced4..aba8e9e0a11e6df886966655a5eeb1a3c9b879fa 100644 --- a/internal/html/repo_search.templ +++ b/internal/html/repo_search.templ @@ -9,39 +9,18 @@ RepoHeaderComponentContext Results []git.GrepResult } -func (s SearchContext) DedupeResults() [][]git.GrepResult { - var ( -package html - currentFile string - currentResults []git.GrepResult - ) - for _, result := range s.Results { -package html RepoHeaderComponentContext - currentResults = append(currentResults, result) - continue - if currentFile != "" { - results = append(results, currentResults) + Results []git.GrepResult +} - import "fmt" - import "go.jolheiser.com/ugit/internal/git" - } - - return results -} - -templ RepoSearch(sc SearchContext) { - Results []git.GrepResult - +import "go.jolheiser.com/ugit/internal/git" } -import "fmt" +type SearchContext struct { - for _, results := range sc.DedupeResults() { - @repoSearchResult(sc.RepoHeaderComponentContext.Name, sc.RepoHeaderComponentContext.Ref, results) } } } -templ repoSearchResult(repo, ref string, results []git.GrepResult) { -
{ results[0].File }
-
@templ.Raw(results[0].Content)
- if len(results) > 1 { -
- { fmt.Sprintf("%d ", len(results[1:])) }more - for _, result := range results[1:] { -
{ results[0].File }
-
@templ.Raw(result.Content)
- } -
- } -} - diff --git a/internal/html/repo_search_templ.go b/internal/html/repo_search_templ.go index 1645b3946a3f4d7209e679be8ed9f5266350655c..7e26c2b0de8d81f7cdc6860eee2014b41045901b 100644 --- a/internal/html/repo_search_templ.go +++ b/internal/html/repo_search_templ.go @@ -19,27 +19,6 @@ RepoHeaderComponentContext Results []git.GrepResult } -func (s SearchContext) DedupeResults() [][]git.GrepResult { - var ( - results [][]git.GrepResult - currentFile string - currentResults []git.GrepResult - ) - for _, result := range s.Results { - if result.File == currentFile { - currentResults = append(currentResults, result) - continue - } - if currentFile != "" { - results = append(results, currentResults) - } - currentFile = result.File - currentResults = []git.GrepResult{result} - } - - return results -} - func RepoSearch(sc SearchContext) templ.Component { return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) @@ -76,204 +55,111 @@ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - for _, results := range sc.DedupeResults() { +import "go.jolheiser.com/ugit/internal/git" //lint:file-ignore SA4006 This context is only used if a nested component is present. -import "bytes" - if templ_7745c5c3_Err != nil { -import "github.com/a-h/templ" // Code generated by templ - DO NOT EDIT. - } -//lint:file-ignore SA4006 This context is only used if a nested component is present. - if !templ_7745c5c3_IsBuffer { -import "github.com/a-h/templ" // templ: version: v0.2.501 -//lint:file-ignore SA4006 This context is only used if a nested component is present. +import "github.com/a-h/templ" import "github.com/a-h/templ" -package html +// Code generated by templ - DO NOT EDIT. import "github.com/a-h/templ" -//lint:file-ignore SA4006 This context is only used if a nested component is present. - templ_7745c5c3_Err = base(sc.BaseContext).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err -import "context" - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { +// Code generated by templ - DO NOT EDIT. import "github.com/a-h/templ" -package html -import "context" - if !templ_7745c5c3_IsBuffer { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) - } - return templ_7745c5c3_Err - }) // Code generated by templ - DO NOT EDIT. import "github.com/a-h/templ" - -func repoSearchResult(repo, ref string, results []git.GrepResult) templ.Component { - return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { -// templ: version: v0.2.501 import "github.com/a-h/templ" - if !templ_7745c5c3_IsBuffer { - templ_7745c5c3_Buffer = templ.GetBuffer() - defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) - } -package html - templ_7745c5c3_Var5 := templ.GetChildren(ctx) - if templ_7745c5c3_Var5 == nil { - templ_7745c5c3_Var5 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var7 string - templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(results[0].File) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_search.templ`, Line: 47, Col: 230} - } -import "io" +import "go.jolheiser.com/ugit/internal/git" import "bytes" import "github.com/a-h/templ" -import "context" - return templ_7745c5c3_Err +// Code generated by templ - DO NOT EDIT. -import "context" -import "bytes" import "github.com/a-h/templ" -import "context" - return templ_7745c5c3_Err -import "context" -import "bytes" // Code generated by templ - DO NOT EDIT. - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err -import "context" - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") +// Code generated by templ - DO NOT EDIT. import "github.com/a-h/templ" -import "context" - return templ_7745c5c3_Err - } - if len(results) > 1 { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err -//lint:file-ignore SA4006 This context is only used if a nested component is present. - var templ_7745c5c3_Var8 string -import "bytes" import "github.com/a-h/templ" - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_search.templ`, Line: 51, Col: 50} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Var9 := `more` // Code generated by templ - DO NOT EDIT. -//lint:file-ignore SA4006 This context is only used if a nested component is present. +import "github.com/a-h/templ" - return templ_7745c5c3_Err - } // Code generated by templ - DO NOT EDIT. // Code generated by templ - DO NOT EDIT. - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } // Code generated by templ - DO NOT EDIT. - - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("