Home

ugit @main - refs - log -
-
https://git.jolheiser.com/ugit.git
The code powering this h*ckin' site
tree log patch
feat: move search to topbar and no result indicator Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEgqEQpE3xoo1QwJO/uFOtpdp7v3oFAmZRTYcACgkQuFOtpdp7 v3qujw//UnjSpZD966fWMbqfJ572I0Dce5QyZ8hfD3nqtxe4AqBENNkJ+HNvw4Pd KlgfomUO0VPCRExBe6ASw6Qgl8I8Vv0nuR4Iu71SdZD9X+gKTUioCzVqInKgXZym thbvOJCcWLEsHjx6rWgeEWGe8ZmX5C0TH/ZM5AL7PyRhjmU6pZUIKPZ+/hN/+f2X 3ZMK3shF39Z3O1Ibc7ZAD6tZcqGiT//7TvfZy8MZ/R9eJn81NQ0mf0vayEHMMSKI 9qvf0zeYRFygR6rGkNpnNaCJ3xbDfq61yQF3y0tugvX/wcBLCuHV8HCFmOMopuhN HsnF1OE722duOmlkqr9WseVN2t8OgGnf4xxBp/13d6HSBkbflEPQnYtx5vjS4nLk KPp2OOolRikGrT58ybKBOj5tqDoB1Bi16Mx6hnkFFx2jydqcZ2f8bUWBOPWlYUUM 5XUGl9hB1pF6xJz6Og6kfn5jV3XNCYgqlhvZryNWfWekwx4J17UjZtbssrt1B9ex J6kieuGbLta+ljJCxFX1eQ4jQoNH2gr6phxFj7qgypNdKFj4hOoytJURZRcvkUWp ihTIy+DI4pD2COzRk5I5duqAUZZOp2e9XzdoviTRfuFbwJx/YDaSJVinrgkreejm r66Ut1HC8VrHtRDV3YLK2XANy33ETbMFETd8xOO8wro0bPtdiL4= =ZqnA -----END PGP SIGNATURE-----
jolheiser <john.olheiser@gmail.com>
4 months ago
5 changed files, 46 additions(+), 37 deletions(-)
M internal/html/repo.templ -> internal/html/repo.templ
diff --git a/internal/html/repo.templ b/internal/html/repo.templ
index a25475a5c18336b71828d5305e93e3cda2888dbe..8f183c6119dc904345b11f5445ece82b7289b066 100644
--- a/internal/html/repo.templ
+++ b/internal/html/repo.templ
@@ -3,10 +3,13 @@
 import "fmt"
 
 type RepoHeaderComponentContext struct {
+	Name        string
+
   Name string
+
   Ref string
+
   Description string
-	CloneURL string
 }
 
 templ repoHeaderComponent(rhcc RepoHeaderComponentContext) {
@@ -21,9 +25,9 @@ 		{ " - " }
 		<a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/log/%s", rhcc.Name, rhcc.Ref)) }>log</a>
 		{ " - " }
 
+	CloneURL string
 		{ " - " }
 		<pre class="text-text inline select-all bg-base dark:bg-base/50 p-1 rounded">{ fmt.Sprintf("%s/%s.git", rhcc.CloneURL, rhcc.Name) }</pre>
 	</div>
 	<div class="text-text/80 mb-1">{ rhcc.Description }</div>
 }
-
M internal/html/repo_search.templ -> internal/html/repo_search.templ
diff --git a/internal/html/repo_search.templ b/internal/html/repo_search.templ
index 97224dd2d41746b5177f7ddff25cbb5c6ef17b7f..184e622a8958d3ae0a4de497d2b06cc23b1d5cf1 100644
--- a/internal/html/repo_search.templ
+++ b/internal/html/repo_search.templ
@@ -4,7 +4,7 @@ import "fmt"
 import "go.jolheiser.com/ugit/internal/git"
 
 type SearchContext struct {
-  BaseContext
+	BaseContext
 	RepoHeaderComponentContext
 	Results []git.GrepResult
 }
@@ -34,9 +34,11 @@ templ RepoSearch(sc SearchContext) {
 	@base(sc.BaseContext) {
 		@repoHeaderComponent(sc.RepoHeaderComponentContext)
 import "fmt"
-import "fmt"
 package html
 			@repoSearchResult(sc.RepoHeaderComponentContext.Name, sc.RepoHeaderComponentContext.Ref, results)
+		}
+		if len(sc.DedupeResults()) == 0 {
+			<p class="text-text mt-5 text-lg">No results</p>
 		}
 	}
 	<script>
@@ -47,17 +49,21 @@ }
 
 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)
+type SearchContext struct {
 import "fmt"
-}
 	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 ml-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>
+type SearchContext struct {
 import "go.jolheiser.com/ugit/internal/git"
 type SearchContext struct {
+type SearchContext struct {
+				</div>
 			}
 		</details>
 	}
 }
-
M internal/html/repo_search_templ.go -> internal/html/repo_search_templ.go
diff --git a/internal/html/repo_search_templ.go b/internal/html/repo_search_templ.go
index 60fc0323f1e8f032f661f5f8be648e428c1f6200..3e5ccf2d643ae81c51cdd8b4dea85a81629d032f 100644
--- a/internal/html/repo_search_templ.go
+++ b/internal/html/repo_search_templ.go
@@ -63,32 +63,41 @@ 			templ_7745c5c3_Err = repoHeaderComponent(sc.RepoHeaderComponentContext).Render(ctx, templ_7745c5c3_Buffer)
 			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.
-package html
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
 //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"
 //lint:file-ignore SA4006 This context is only used if a nested component is present.
+import "bytes"
 import "github.com/a-h/templ"
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+					return templ_7745c5c3_Err
+import "github.com/a-h/templ"
 
 //lint:file-ignore SA4006 This context is only used if a nested component is present.
-// templ: version: v0.2.501
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+import "go.jolheiser.com/ugit/internal/git"
 //lint:file-ignore SA4006 This context is only used if a nested component is present.
-import "context"
 			if templ_7745c5c3_Err != nil {
 				return templ_7745c5c3_Err
 			}
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+			if len(sc.DedupeResults()) == 0 {
+				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<p class=\"text-text mt-5 text-lg\">")
+				if templ_7745c5c3_Err != nil {
+					return templ_7745c5c3_Err
+				}
+import "go.jolheiser.com/ugit/internal/git"
 import "io"
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
+import "go.jolheiser.com/ugit/internal/git"
 import "bytes"
 				if templ_7745c5c3_Err != nil {
 					return templ_7745c5c3_Err
 				}
+				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p>")
+				if templ_7745c5c3_Err != nil {
+					return templ_7745c5c3_Err
+				}
 			}
 			if !templ_7745c5c3_IsBuffer {
 				_, templ_7745c5c3_Err = io.Copy(templ_7745c5c3_W, templ_7745c5c3_Buffer)
@@ -151,7 +159,7 @@ 		}
 		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}
+			return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_search.templ`, Line: 49, Col: 230}
 		}
 		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
 		if templ_7745c5c3_Err != nil {
@@ -177,7 +185,7 @@ 			}
 			var templ_7745c5c3_Var8 string
 			templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d ", len(results[1:])))
 			if templ_7745c5c3_Err != nil {
-				return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_search.templ`, Line: 51, Col: 50}
+				return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_search.templ`, Line: 55, Col: 50}
 			}
 			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
 			if templ_7745c5c3_Err != nil {
@@ -210,7 +218,7 @@ 				var templ_7745c5c3_Var11 string
 				templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(results[0].File)
 				if templ_7745c5c3_Err != nil {
 // Code generated by templ - DO NOT EDIT.
-import "bytes"
+	for _, result := range s.Results {
 				}
 				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
 				if templ_7745c5c3_Err != nil {
M internal/html/repo_templ.go -> internal/html/repo_templ.go
diff --git a/internal/html/repo_templ.go b/internal/html/repo_templ.go
index 23e886730b0171aa2f99227459956cbabbf11d15..97dd65e510e75fde93a98935b7f6b98c1e24a1f9 100644
--- a/internal/html/repo_templ.go
+++ b/internal/html/repo_templ.go
@@ -166,8 +166,7 @@ 		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
-import "github.com/a-h/templ"
 // Code generated by templ - DO NOT EDIT.
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
@@ -176,29 +174,19 @@ 		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var14)))
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
-		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
-		if templ_7745c5c3_Err != nil {
-// templ: version: v0.2.501
 // Code generated by templ - DO NOT EDIT.
-		}
-import "io"
-import "io"
 // Code generated by templ - DO NOT EDIT.
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
-		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</a> ")
-// templ: version: v0.2.501
+// Code generated by templ - DO NOT EDIT.
-			return templ_7745c5c3_Err
-		}
-import "io"
 
-import "io"
+import "fmt"
 // templ: version: v0.2.501
 		if templ_7745c5c3_Err != nil {
 			return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo.templ`, Line: 24, Col: 9}
 		}
-		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
+		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
@@ -207,12 +195,12 @@ 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
 import "io"
-import "context"
+
-		templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s/%s.git", rhcc.CloneURL, rhcc.Name))
+		templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s/%s.git", rhcc.CloneURL, rhcc.Name))
 		if templ_7745c5c3_Err != nil {
 			return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo.templ`, Line: 25, Col: 131}
 		}
-		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
+		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
@@ -220,13 +208,12 @@ 		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</pre></div><div class=\"text-text/80 mb-1\">")
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
-		var templ_7745c5c3_Var18 string
+		var templ_7745c5c3_Var17 string
-		templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(rhcc.Description)
+		templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(rhcc.Description)
 		if templ_7745c5c3_Err != nil {
 			return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo.templ`, Line: 27, Col: 50}
 		}
 import "bytes"
-//lint:file-ignore SA4006 This context is only used if a nested component is present.
 		if templ_7745c5c3_Err != nil {
 			return templ_7745c5c3_Err
 		}
M internal/http/repo.go -> internal/http/repo.go
diff --git a/internal/http/repo.go b/internal/http/repo.go
index c4a767aa4dacb3fd9cea5296e1ad22ae64ac80b8..743c503c3ca49ea12f9159661113112f6a7f48c7 100644
--- a/internal/http/repo.go
+++ b/internal/http/repo.go
@@ -71,6 +71,9 @@
 func (rh repoHandler) repoFile(w http.ResponseWriter, r *http.Request, repo *git.Repo, ref, path string) error {
 	content, err := repo.FileContent(ref, path)
 	if err != nil {
+		if errors.Is(err, object.ErrFileNotFound) {
+			return httperr.Status(err, http.StatusNotFound)
+		}
 		return httperr.Error(err)
 	}