Compare commits

..

2 Commits

Author SHA1 Message Date
jolheiser c33dfdc42a
fix: base breadcrumb requires ending slash
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2024-07-09 15:54:04 -05:00
jolheiser d20394e093
feat: improve SSH repo list
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2024-07-09 15:39:38 -05:00
3 changed files with 24 additions and 9 deletions

View File

@ -3,6 +3,7 @@ package html
import ( import (
"fmt" "fmt"
"strings" "strings"
"path"
) )
type RepoBreadcrumbComponentContext struct { type RepoBreadcrumbComponentContext struct {
@ -22,13 +23,13 @@ func (r RepoBreadcrumbComponentContext) crumbs() []breadcrumb {
breadcrumbs := []breadcrumb{ breadcrumbs := []breadcrumb{
{ {
label: r.Repo, label: r.Repo,
href: fmt.Sprintf("/%s/tree/%s", r.Repo, r.Ref), href: fmt.Sprintf("/%s/tree/%s/", r.Repo, r.Ref),
}, },
} }
for idx, part := range parts { for idx, part := range parts {
breadcrumbs = append(breadcrumbs, breadcrumb{ breadcrumbs = append(breadcrumbs, breadcrumb{
label: part, label: part,
href: breadcrumbs[idx].href + "/" + part, href: path.Join(breadcrumbs[idx].href, part),
}) })
} }
breadcrumbs[len(breadcrumbs)-1].end = true breadcrumbs[len(breadcrumbs)-1].end = true

View File

@ -12,6 +12,7 @@ import "bytes"
import ( import (
"fmt" "fmt"
"path"
"strings" "strings"
) )
@ -32,13 +33,13 @@ func (r RepoBreadcrumbComponentContext) crumbs() []breadcrumb {
breadcrumbs := []breadcrumb{ breadcrumbs := []breadcrumb{
{ {
label: r.Repo, label: r.Repo,
href: fmt.Sprintf("/%s/tree/%s", r.Repo, r.Ref), href: fmt.Sprintf("/%s/tree/%s/", r.Repo, r.Ref),
}, },
} }
for idx, part := range parts { for idx, part := range parts {
breadcrumbs = append(breadcrumbs, breadcrumb{ breadcrumbs = append(breadcrumbs, breadcrumb{
label: part, label: part,
href: breadcrumbs[idx].href + "/" + part, href: path.Join(breadcrumbs[idx].href, part),
}) })
} }
breadcrumbs[len(breadcrumbs)-1].end = true breadcrumbs[len(breadcrumbs)-1].end = true
@ -72,7 +73,7 @@ func repoBreadcrumbComponent(rbcc RepoBreadcrumbComponentContext) templ.Componen
var templ_7745c5c3_Var2 string var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(crumb.label) templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(crumb.label)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_breadcrumb.templ`, Line: 43, Col: 24} return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_breadcrumb.templ`, Line: 44, Col: 24}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@ -99,7 +100,7 @@ func repoBreadcrumbComponent(rbcc RepoBreadcrumbComponentContext) templ.Componen
var templ_7745c5c3_Var4 string var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(crumb.label) templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(crumb.label)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_breadcrumb.templ`, Line: 45, Col: 134} return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_breadcrumb.templ`, Line: 46, Col: 134}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@ -112,7 +113,7 @@ func repoBreadcrumbComponent(rbcc RepoBreadcrumbComponentContext) templ.Componen
var templ_7745c5c3_Var5 string var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(" / ") templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(" / ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_breadcrumb.templ`, Line: 46, Col: 12} return templ.Error{Err: templ_7745c5c3_Err, FileName: `repo_breadcrumb.templ`, Line: 47, Col: 12}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {

View File

@ -8,6 +8,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"text/tabwriter"
"go.jolheiser.com/ugit/internal/git" "go.jolheiser.com/ugit/internal/git"
@ -104,10 +105,22 @@ func Middleware(repoDir string, cloneURL string, port int, gh Hooks) wish.Middle
if err != nil && err != fs.ErrNotExist { if err != nil && err != fs.ErrNotExist {
log.Error("invalid repository", "error", err) log.Error("invalid repository", "error", err)
} }
tw := tabwriter.NewWriter(s, 0, 0, 1, ' ', 0)
for _, de := range des { for _, de := range des {
fmt.Fprintln(s, de.Name()) if filepath.Ext(de.Name()) != ".git" {
fmt.Fprintf(s, "\tgit clone %s/%s\n", cloneURL, de.Name()) continue
}
repo, err := git.NewRepo(repoDir, de.Name())
visibility := "❓"
if err == nil {
visibility = "🔓"
if repo.Meta.Private {
visibility = "🔒"
}
}
fmt.Fprintf(tw, "%[1]s\t%[3]s\t%[2]s/%[1]s.git\n", strings.TrimSuffix(de.Name(), ".git"), cloneURL, visibility)
} }
tw.Flush()
} }
sh(s) sh(s)
} }