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) diff --git a/static/style.css b/static/style.css index 5f7087b..ce66ba6 100644 --- a/static/style.css +++ b/static/style.css @@ -1,11 +1,11 @@ :root { - --light: #f4f4f4; - --cyan: #509c93; - --light-gray: #eee; - --medium-gray: #ddd; - --gray: #6a6a6a; - --dark: #444; - --darker: #222; + --light: #224520; + --cyan: #285125; + --light-gray: #336830; + --medium-gray: #dbd7d4; + --gray: #dbd7d4; + --dark: #f3d0aa; + --darker: #f3d0aa; --sans-font: "InterVar", -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", sans-serif; --display-font: "InterDisplay", -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", sans-serif; @@ -13,6 +13,7 @@ } html { + color: var(--dark); background: var(--light); -webkit-text-size-adjust: none; font-family: var(--sans-font); diff --git a/templates/commit.html b/templates/commit.html index c1def17..3e6ec5e 100644 --- a/templates/commit.html +++ b/templates/commit.html @@ -2,74 +2,76 @@ {{ template "head" . }} - {{ template "repoheader" . }} - - {{ template "nav" . }} -
-
-
-          {{- .commit.Message -}}
-        
-
- {{ .commit.Author.Name }} {{ .commit.Author.Email}} +{{ template "repoheader" . }} + + + {{ template "nav" . }} +
+
+
+        {{- .commit.Message -}}
+      
+
+ {{ .commit.Author.Name }} {{ + .commit.Author.Email}}
{{ .commit.Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}
-
+
-
+
commit -

- {{ .commit.This }} - +

+ {{ .commit.This }} +

-
+
- {{ if .commit.Parent }} -
+ {{ if .commit.Parent }} +
parent -

- {{ .commit.Parent }} -

-
+

+ {{ .commit.Parent }} +

+
- {{ end }} -
-
+ {{ end }} +
+
{{ .stat.FilesChanged }} files changed, {{ .stat.Insertions }} insertions(+), {{ .stat.Deletions }} deletions(-) -
-
-
- jump to - {{ range .diff }} - - {{ end }} -
-
-
- {{ $repo := .name }} - {{ $this := .commit.This }} - {{ $parent := .commit.Parent }} - {{ range .diff }} -
-
- {{ if .IsNew }} - A - {{ end }} - {{ if .IsDelete }} - D - {{ end }} - {{ if not (or .IsNew .IsDelete) }} - M - {{ end }} +
+
+ jump to + {{ range .diff }} + + {{ end }} +
+
+
+
+ {{ $repo := .repo }} + {{ $this := .commit.This }} + {{ $parent := .commit.Parent }} + {{ range .diff }} +
+
+ {{ if .IsNew }} + A + {{ end }} + {{ if .IsDelete }} + D + {{ end }} + {{ if not (or .IsNew .IsDelete) }} + M + {{ end }} {{ if .Name.Old }} {{ .Name.Old }} {{ if .Name.New }} - → - {{ .Name.New }} + → + {{ .Name.New }} {{ end }} {{ else }} {{ .Name.New }} @@ -77,28 +79,29 @@ {{ if .IsBinary }}

Not showing binary file.

{{ else }} -
+          
             {{- range .TextFragments -}}
             

{{- .Header -}}

{{- range .Lines -}} - {{- if eq .Op.String "+" -}} - {{ .String }} - {{- end -}} - {{- if eq .Op.String "-" -}} - {{ .String }} - {{- end -}} - {{- if eq .Op.String " " -}} - {{ .String }} - {{- end -}} + {{- if eq .Op.String "+" -}} + {{ .String }} + {{- end -}} + {{- if eq .Op.String "-" -}} + {{ .String }} + {{- end -}} + {{- if eq .Op.String " " -}} + {{ .String }} {{- end -}} {{- end -}} - {{- end -}} -
-
-
- {{ end }} -
-
- + {{- end -}} + {{- end -}} + + + + {{ end }} + + + + -{{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/log.html b/templates/log.html index 7d74cb3..e596149 100644 --- a/templates/log.html +++ b/templates/log.html @@ -2,24 +2,26 @@ {{ template "head" . }} - {{ template "repoheader" . }} - - {{ template "nav" . }} -
- {{ $repo := .name }} -
- {{ range .commits }} -
-
{{ slice .Hash.String 0 8 }}
-
{{ .Message }}
-
-
- {{ .Author.Name }} {{ .Author.Email }} -
{{ .Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}
-
- {{ end }} +{{ template "repoheader" . }} + + + {{ template "nav" . }} +
+ {{ $repo := .repo }} +
+ {{ range .commits }} +
+ +
{{ .Message }}
-
- +
+ {{ .Author.Name }} {{ .Author.Email }} +
{{ .Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}
+
+ {{ end }} +
+
+ + -{{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/nav.html b/templates/nav.html index 51c9a34..6f6b4dd 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -1,14 +1,14 @@ {{ define "nav" }} - +{{ end }} \ No newline at end of file diff --git a/templates/refs.html b/templates/refs.html index 76add7d..347ff3b 100644 --- a/templates/refs.html +++ b/templates/refs.html @@ -2,37 +2,39 @@ {{ template "head" . }} - {{ template "repoheader" . }} - - {{ template "nav" . }} -
- {{ $name := .name }} -

branches

-
+{{ template "repoheader" . }} + + + {{ template "nav" . }} +
+ {{ $name := .repo }} +

branches

+
{{ range .branches }} -
+
{{ .Name.Short }} browse log -
- {{ end }}
- {{ if .tags }} -

tags

-
+ {{ end }} +
+ {{ if .tags }} +

tags

+
{{ range .tags }}
- {{ .Name }} - browse - log - {{ if .Message }} -
{{ .Message }}
+ {{ .Name }} + browse + log + {{ if .Message }} +
{{ .Message }}
{{ end }} {{ end }} -
- {{ end }} -
- +
+ {{ end }} +
+ + -{{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/repo-header.html b/templates/repo-header.html index f358278..fae5525 100644 --- a/templates/repo-header.html +++ b/templates/repo-header.html @@ -1,12 +1,12 @@ {{ define "repoheader" }}

- all repos - — {{ .name }} + all repos + — {{ .repo }} {{ if .ref }} @ {{ .ref }} {{ end }}

{{ .desc }}

-{{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/repo.html b/templates/repo.html index 1cd9b5c..957faba 100644 --- a/templates/repo.html +++ b/templates/repo.html @@ -4,35 +4,36 @@ {{ template "repoheader" . }} - - {{ template "nav" . }} -
- {{ $repo := .name }} -
- {{ range .commits }} -
-
{{ slice .Hash.String 0 8 }}
-
{{ .Message }}
-
-
- {{ .Author.Name }} {{ .Author.Email }} -
{{ .Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}
-
- {{ end }} + + {{ template "nav" . }} +
+ {{ $repo := .repo }} +
+ {{ range .commits }} +
+ +
{{ .Message }}
-{{- if .readme }} -
- {{- .readme -}} -
-{{- end -}} +
+ {{ .Author.Name }} {{ .Author.Email }} +
{{ .Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}
+
+ {{ end }} +
+ {{- if .readme }} +
+ {{- .readme -}} +
+ {{- end -}} -
+
clone -
-git clone https://{{ .servername }}/{{ .name }}
-        
-
-
- +
+        git clone https://{{ .servername }}/{{ .repo }}
+      
+
+
+ + -{{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/tree.html b/templates/tree.html index c4b7e4f..a4f0d1b 100644 --- a/templates/tree.html +++ b/templates/tree.html @@ -3,53 +3,55 @@ {{ template "head" . }} - {{ template "repoheader" . }} - - {{ template "nav" . }} -
- {{ $repo := .name }} - {{ $ref := .ref }} - {{ $parent := .parent }} +{{ template "repoheader" . }} -
+ + {{ template "nav" . }} +
+ {{ $repo := .repo }} + {{ $ref := .ref }} + {{ $parent := .parent }} + +
+ {{ if $parent }} +
+
+
..
+ {{ end }} + {{ range .files }} + {{ if not .IsFile }} +
{{ .Mode }}
+
{{ .Size }}
+
{{ if $parent }} -
-
- - {{ end }} - {{ range .files }} - {{ if not .IsFile }} -
{{ .Mode }}
-
{{ .Size }}
-
- {{ if $parent }} - {{ .Name }}/ - {{ else }} - {{ .Name }}/ - {{ end }} -
- {{ end }} - {{ end }} - {{ range .files }} - {{ if .IsFile }} -
{{ .Mode }}
-
{{ .Size }}
-
- {{ if $parent }} - {{ .Name }} - {{ else }} - {{ .Name }} - {{ end }} -
- {{ end }} + {{ .Name }}/ + {{ else }} + {{ .Name }}/ {{ end }}
-
-
-          {{- if .readme }}{{ .readme }}{{- end -}}
-        
-
-
- + {{ end }} + {{ end }} + {{ range .files }} + {{ if .IsFile }} +
{{ .Mode }}
+
{{ .Size }}
+
+ {{ if $parent }} + {{ .Name }} + {{ else }} + {{ .Name }} + {{ end }} +
+ {{ end }} + {{ end }} +
+
+
+        {{- if .readme }}{{ .readme }}{{- end -}}
+      
+
+
+ + -{{ end }} +{{ end }} \ No newline at end of file