diff --git a/config.yaml b/config.yaml index 3f2d737..2278b5e 100644 --- a/config.yaml +++ b/config.yaml @@ -9,8 +9,8 @@ repo: - master - main dirs: - templates: ./templates - static: ./static + templates: ./legit/templates + static: ./legit/static meta: title: icy does git description: come get your free software diff --git a/go.mod b/go.mod index ece773e..e2b25d5 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( github.com/go-git/go-git/v5 v5.12.0 github.com/microcosm-cc/bluemonday v1.0.27 github.com/russross/blackfriday/v2 v2.1.0 - golang.org/x/sys v0.26.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -36,6 +35,7 @@ require ( github.com/xanzy/ssh-agent v0.3.3 // indirect golang.org/x/crypto v0.28.0 // indirect golang.org/x/net v0.30.0 // indirect + golang.org/x/sys v0.26.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/legit/routes/handler.go b/legit/routes/handler.go index 8e61c91..cf61fd7 100644 --- a/legit/routes/handler.go +++ b/legit/routes/handler.go @@ -33,10 +33,10 @@ func Handlers(c *config.Config) http.Handler { r := chi.NewRouter() d := deps{c} - r.Get("/", d.Index) r.Get("/static/{file}", d.ServeStatic) r.Route("/@{user}", func(r chi.Router) { + r.Get("/", d.Index) r.Route("/{name}", func(r chi.Router) { r.Get("/", d.Multiplex) r.Post("/", d.Multiplex) diff --git a/legit/routes/routes.go b/legit/routes/routes.go index 27d4039..bfffbf8 100644 --- a/legit/routes/routes.go +++ b/legit/routes/routes.go @@ -25,7 +25,9 @@ type deps struct { } func (d *deps) Index(w http.ResponseWriter, r *http.Request) { - dirs, err := os.ReadDir(d.c.Repo.ScanPath) + user := "@" + chi.URLParam(r, "user") + path := filepath.Join(d.c.Repo.ScanPath, user) + dirs, err := os.ReadDir(path) if err != nil { d.Write500(w) log.Printf("reading scan path: %s", err) @@ -45,7 +47,6 @@ func (d *deps) Index(w http.ResponseWriter, r *http.Request) { continue } - path := filepath.Join(d.c.Repo.ScanPath, name) gr, err := git.Open(path, "") if err != nil { log.Println(err)