summaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2024-02-20 00:24:38 +0000
committerLibravatar cel 🌸 <cel@blos.sm>2024-02-20 00:24:38 +0000
commitf4ff8fe6eb20ab5b557d7beac095959890e126e8 (patch)
tree41e3c708a0c5c3cb4a318ebcd7739e3f2dc74552 /routes
parentac0983a89692534daa3d36dba528461b5bb32dbc (diff)
downloadlegit-f4ff8fe6eb20ab5b557d7beac095959890e126e8.tar.gz
legit-f4ff8fe6eb20ab5b557d7beac095959890e126e8.tar.bz2
legit-f4ff8fe6eb20ab5b557d7beac095959890e126e8.zip
fix routes
Diffstat (limited to '')
-rw-r--r--routes/handler.go12
-rw-r--r--routes/routes.go30
2 files changed, 36 insertions, 6 deletions
diff --git a/routes/handler.go b/routes/handler.go
index f133e80..1a9bfbd 100644
--- a/routes/handler.go
+++ b/routes/handler.go
@@ -40,18 +40,18 @@ func Handlers(c *config.Config) *flow.Mux {
mux.HandleFunc("/", d.Index, "GET")
mux.HandleFunc("/static/:file", d.ServeStatic, "GET")
mux.HandleFunc("/:category/:name", d.Multiplex, "GET", "POST")
- mux.HandleFunc("/:category/:name/tree/:ref/...", d.RepoTree, "GET")
- mux.HandleFunc("/:category/:name/blob/:ref/...", d.FileContent, "GET")
- mux.HandleFunc("/:category/:name/log/:ref", d.Log, "GET")
- mux.HandleFunc("/:category/:name/commit/:ref", d.Diff, "GET")
- mux.HandleFunc("/:category/:name/refs", d.Refs, "GET")
- mux.HandleFunc("/:category/:name/...", d.Multiplex, "GET", "POST")
mux.HandleFunc("/:name", d.Multiplex, "GET", "POST")
+ mux.HandleFunc("/:category/:name/tree/:ref/...", d.RepoTree, "GET")
mux.HandleFunc("/:name/tree/:ref/...", d.RepoTree, "GET")
+ mux.HandleFunc("/:category/:name/blob/:ref/...", d.FileContent, "GET")
mux.HandleFunc("/:name/blob/:ref/...", d.FileContent, "GET")
+ mux.HandleFunc("/:category/:name/log/:ref", d.Log, "GET")
mux.HandleFunc("/:name/log/:ref", d.Log, "GET")
+ mux.HandleFunc("/:category/:name/commit/:ref", d.Diff, "GET")
mux.HandleFunc("/:name/commit/:ref", d.Diff, "GET")
+ mux.HandleFunc("/:category/:name/refs", d.Refs, "GET")
mux.HandleFunc("/:name/refs", d.Refs, "GET")
+ mux.HandleFunc("/:category/:name/...", d.Multiplex, "GET", "POST")
mux.HandleFunc("/:name/...", d.Multiplex, "GET", "POST")
return mux
diff --git a/routes/routes.go b/routes/routes.go
index 6c6df6c..f27a554 100644
--- a/routes/routes.go
+++ b/routes/routes.go
@@ -226,6 +226,11 @@ func (d *deps) RepoIndex(w http.ResponseWriter, r *http.Request) {
data := make(map[string]any)
data["name"] = name
+ if category != "" {
+ data["repo"] = filepath.Join(category, name)
+ } else {
+ data["repo"] = name
+ }
data["ref"] = mainBranch
data["readme"] = readmeContent
data["commits"] = commits
@@ -276,6 +281,11 @@ func (d *deps) RepoTree(w http.ResponseWriter, r *http.Request) {
data := make(map[string]any)
data["name"] = name
+ if category != "" {
+ data["repo"] = filepath.Join(category, name)
+ } else {
+ data["repo"] = name
+ }
data["ref"] = ref
data["parent"] = treePath
data["desc"] = getDescription(path)
@@ -313,6 +323,11 @@ func (d *deps) FileContent(w http.ResponseWriter, r *http.Request) {
contents, err := gr.FileContent(treePath)
data := make(map[string]any)
data["name"] = name
+ if category != "" {
+ data["repo"] = filepath.Join(category, name)
+ } else {
+ data["repo"] = name
+ }
data["ref"] = ref
data["desc"] = getDescription(path)
data["path"] = treePath
@@ -358,6 +373,11 @@ func (d *deps) Log(w http.ResponseWriter, r *http.Request) {
data["commits"] = commits
data["meta"] = d.c.Meta
data["name"] = name
+ if category != "" {
+ data["repo"] = filepath.Join(category, name)
+ } else {
+ data["repo"] = name
+ }
data["ref"] = ref
data["desc"] = getDescription(path)
data["log"] = true
@@ -408,6 +428,11 @@ func (d *deps) Diff(w http.ResponseWriter, r *http.Request) {
data["diff"] = diff.Diff
data["meta"] = d.c.Meta
data["name"] = name
+ if category != "" {
+ data["repo"] = filepath.Join(category, name)
+ } else {
+ data["repo"] = name
+ }
data["ref"] = ref
data["desc"] = getDescription(path)
@@ -459,6 +484,11 @@ func (d *deps) Refs(w http.ResponseWriter, r *http.Request) {
data["meta"] = d.c.Meta
data["name"] = name
+ if category != "" {
+ data["repo"] = filepath.Join(category, name)
+ } else {
+ data["repo"] = name
+ }
data["branches"] = branches
data["tags"] = tags
data["desc"] = getDescription(path)