ugit @main -
refs -
log -
-
https://git.jolheiser.com/ugit.git
Signature
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEgqEQpE3xoo1QwJO/uFOtpdp7v3oFAmXiW2MACgkQuFOtpdp7
v3p8Cg//bH15+7K6BiwL/8rdQrKSB9YilcakDn6Xq6VNuwsW+RUnIYqf/5yurbRN
uupBeFxNhR9AEj0qDVVce9COFl3n2jwUvkZlOUKp5QyKn+grNUDdG4roaLFkvEYJ
t9Z3N1E3MHvh2cvsOUq4zBGdqadgiS4rvk7jQWLa4/K5LxoMW6mqOTCZb/r+7rOE
xJLKfQsAHPUXDA79tPGsm+eEmnyGhf9oCh4GP+jzEfeujRjyjQfC/s0x9RDc1ReH
0TzztY+5Q4EzuKigIwgChYunwMqa9UsfoTk9XZagNZsIrVp7gdl1lBjemWUgSlUC
jtnL9aW5pC2Q8UkMf9b8pRWrNQBjrI5L7ipsP/y4waIjMeuxQVc2OMdGXi5YPz2v
ub4hf7TXpY8uS4+O7WNGq4eZBr0dpp8k/e8WcZsCcmIm5F9IJcWuo9+MoVrc0aRZ
tI9v9Du2rI2sgK3rXz9/X6s0j5DNc/iYgvaOFvtaz18HCwdWVi2RSHEuPSffyVIo
ZbWYb5yMgMp0HyGHw9kCx5OlN2Lr6uYsREZ3cM9zNfCVW4dE6/F89RgGww7oulAU
YdBUg5st1jGuqmhJt5/4D0TFz3SuLhMEENJELO1WREDE83tXNDTb2kMn9kBL6YhA
mdHrD1KSIKQMT/DUPL2iyXDs3LoOzzcjhFAPj+vKXKLJjVUGUSk=
=EJhW
-----END PGP SIGNATURE-----
diff --git a/internal/html/repo_search.templ b/internal/html/repo_search.templ
index aba8e9e0a11e6df886966655a5eeb1a3c9b879fa..0afeeec00e0be4333fa135a8f017487fbb23ced4 100644
--- a/internal/html/repo_search.templ
+++ b/internal/html/repo_search.templ
@@ -9,19 +9,39 @@ RepoHeaderComponentContext
Results []git.GrepResult
}
-package html
+func (s SearchContext) DedupeResults() [][]git.GrepResult {
+ var (
+ results [][]git.GrepResult
+ currentFile string
+ currentResults []git.GrepResult
+ )
+ for _, result := range s.Results {
+import "fmt"
+import "fmt"
package html
+ continue
package html
+ RepoHeaderComponentContext
+ if currentFile != "" {
+ results = append(results, currentResults)
package html
+ RepoHeaderComponentContext
+ currentFile = result.File
+ currentResults = []git.GrepResult{result}
+ }
+
+ return results
+}
package html
-import "fmt"
package html
-import "go.jolheiser.com/ugit/internal/git"
+package html
package html
-type SearchContext struct {
+
package html
- BaseContext
+import "fmt"
+ for _, results := range sc.DedupeResults() {
+ @repoSearchResult(sc.RepoHeaderComponentContext.Name, sc.RepoHeaderComponentContext.Ref, results)
}
}
<script>
@@ -30,3 +49,17 @@ if (search !== "") document.querySelector("#search").value = search;
</script>
}
+templ repoSearchResult(repo, ref string, results []git.GrepResult) {
+ <div class="text-text mt-5"><a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/tree/%s/%s#L%d", repo, ref, results[0].File, results[0].Line)) }>{ results[0].File }</a></div>
+ <div class="code">@templ.Raw(results[0].Content)</div>
+ if len(results) > 1 {
+ <details class="text-text cursor-pointer">
+ <summary>{ fmt.Sprintf("%d ", len(results[1:])) }more</summary>
+ for _, result := range results[1:] {
+ <div class="text-text mt-5"><a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/tree/%s/%s#L%d", repo, ref, result.File, result.Line)) }>{ results[0].File }</a></div>
+ <div class="code">@templ.Raw(result.Content)</div>
+ }
+ </details>
+ }
+}
+
diff --git a/internal/html/repo_search_templ.go b/internal/html/repo_search_templ.go
index 7e26c2b0de8d81f7cdc6860eee2014b41045901b..1645b3946a3f4d7209e679be8ed9f5266350655c 100644
--- a/internal/html/repo_search_templ.go
+++ b/internal/html/repo_search_templ.go
@@ -19,6 +19,27 @@ 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)
@@ -55,101 +76,203 @@ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<input class=\"rounded p-1 mt-2 bg-mantle focus:border-lavender focus:outline-none focus:ring-0\" id=\"search\" type=\"text\" name=\"q\" placeholder=\"search\"></label></form>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- for _, result := range sc.Results {
+ for _, results := range sc.DedupeResults() {
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"text-text mt-5\"><a class=\"underline decoration-text/50 decoration-dashed hover:decoration-solid\" href=\"")
+ templ_7745c5c3_Err = repoSearchResult(sc.RepoHeaderComponentContext.Name, sc.RepoHeaderComponentContext.Ref, results).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
+// templ: version: v0.2.501
package html
+ if !templ_7745c5c3_IsBuffer {
+//lint:file-ignore SA4006 This context is only used if a nested component is present.
import "context"
+// templ: version: v0.2.501
package html
+//lint:file-ignore SA4006 This context is only used if a nested component is present.
import "io"
- if templ_7745c5c3_Err != nil {
+ })
+ templ_7745c5c3_Err = base(sc.BaseContext).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
-package html
+ if templ_7745c5c3_Err != nil {
//lint:file-ignore SA4006 This context is only used if a nested component is present.
+import "io"
-package html
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<script>")
import "github.com/a-h/templ"
+// Code generated by templ - DO NOT EDIT.
-package html
+ return templ_7745c5c3_Err
+ }
import "bytes"
-package html
+import "github.com/a-h/templ"
package html
-package html
+import "github.com/a-h/templ"
//lint:file-ignore SA4006 This context is only used if a nested component is present.
-package html
+ `
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var4)
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.
+import "io"
- templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(result.File)
+ }
- if templ_7745c5c3_Err != nil {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</script>")
+ if templ_7745c5c3_Err != nil {
//lint:file-ignore SA4006 This context is only used if a nested component is present.
+import "io"
+// templ: version: v0.2.501
-package html
+ if !templ_7745c5c3_IsBuffer {
import "github.com/a-h/templ"
+import "bytes"
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+
// templ: version: v0.2.501
- if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
- return templ_7745c5c3_Err
+ })
-package html
+// Code generated by templ - DO NOT EDIT.
import "github.com/a-h/templ"
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</a></div><div class=\"code\">")
+
-package html
+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_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
+ if !templ_7745c5c3_IsBuffer {
+ templ_7745c5c3_Buffer = templ.GetBuffer()
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ }
+
package html
+ templ_7745c5c3_Var5 := templ.GetChildren(ctx)
+import "bytes"
package html
+import "bytes"
//lint:file-ignore SA4006 This context is only used if a nested component is present.
-package html
+ }
+ ctx = templ.ClearChildren(ctx)
+import "bytes"
import "github.com/a-h/templ"
+ if templ_7745c5c3_Err != nil {
//lint:file-ignore SA4006 This context is only used if a nested component is present.
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+import "io"
- if templ_7745c5c3_Err != nil {
+ }
- return templ_7745c5c3_Err
+ var templ_7745c5c3_Var6 templ.SafeURL = templ.SafeURL(fmt.Sprintf("/%s/tree/%s/%s#L%d", repo, ref, results[0].File, results[0].Line))
-package html
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var6)))
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.
-import "github.com/a-h/templ"
+import "io"
- if templ_7745c5c3_Err != nil {
+ }
-package html
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
+ if templ_7745c5c3_Err != nil {
//lint:file-ignore SA4006 This context is only used if a nested component is present.
+import "io"
-package html
+ }
+ var templ_7745c5c3_Var7 string
+ templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(results[0].File)
import "github.com/a-h/templ"
+// Code generated by templ - DO NOT EDIT.
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_search.templ`, Line: 47, Col: 230}
+
// templ: version: v0.2.501
-package html
+import "fmt"
// templ: version: v0.2.501
+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.
-import "context"
+import "io"
+
// templ: version: v0.2.501
+import "fmt"
package html
+ if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
- })
+ }
-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_Err != nil {
return templ_7745c5c3_Err
}
+import "fmt"
import "github.com/a-h/templ"
-
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
+ if len(results) > 1 {
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<details class=\"text-text cursor-pointer\"><summary>")
+// templ: version: v0.2.501
import "github.com/a-h/templ"
// templ: version: v0.2.501
+import "context"
+ }
+ var templ_7745c5c3_Var8 string
+ templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d ", len(results[1:])))
+// templ: version: v0.2.501
import "github.com/a-h/templ"
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_search.templ`, Line: 51, Col: 50}
+// templ: version: v0.2.501
package html
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
+// templ: version: v0.2.501
import "github.com/a-h/templ"
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Var9 := `more`
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var9)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+import "go.jolheiser.com/ugit/internal/git"
//lint:file-ignore SA4006 This context is only used if a nested component is present.
+// templ: version: v0.2.501
import "github.com/a-h/templ"
+ return templ_7745c5c3_Err
+ }
+import "go.jolheiser.com/ugit/internal/git"
import "github.com/a-h/templ"
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"text-text mt-5\"><a class=\"underline decoration-text/50 decoration-dashed hover:decoration-solid\" href=\"")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+package html
import "github.com/a-h/templ"
+import "go.jolheiser.com/ugit/internal/git"
import "context"
-import "github.com/a-h/templ"
+// Code generated by templ - DO NOT EDIT.
// Code generated by templ - DO NOT EDIT.
+import "io"
+ if templ_7745c5c3_Err != nil {
+package html
//lint:file-ignore SA4006 This context is only used if a nested component is present.
-import "io"
- }
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+package html
import "github.com/a-h/templ"
-import "io"
+ var templ_7745c5c3_Var11 string
+ templ_7745c5c3_Var11, 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: 53, Col: 225}
+package html
import "github.com/a-h/templ"
// Code generated by templ - DO NOT EDIT.
+ defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+package html
//lint:file-ignore SA4006 This context is only used if a nested component is present.
-import "io"
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</a></div><div class=\"code\">")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templ.Raw(result.Content).Render(ctx, templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</details>")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
}
if !templ_7745c5c3_IsBuffer {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)