all repos

mugit @ 9d3f4dd

🐮 git server that your cow will love
2 files changed, 43 insertions(+), 11 deletions(-)
ui: add breadcrumbs to file content view
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2026-03-05 20:58:57 +0200
Change ID: olmzpxznknwssqnwutykuxnzlwtnyopr
Parent: 99af93d
M internal/handlers/repo.go

@@ -158,15 +158,16 @@ }))

} type RepoFile struct { - Ref string - Desc string - LineCount []int - Path string - IsImage bool - IsBinary bool - Content string - Mime string - Size int64 + Ref string + Desc string + LineCount []int + Breadcrumbs []Breadcrumb + Path string + IsImage bool + IsBinary bool + Content string + Mime string + Size int64 } func (h *handlers) fileContentsHandler(w http.ResponseWriter, r *http.Request) {

@@ -228,7 +229,8 @@ for i := range lines {

lines[i] = i + 1 } p.Content = contentStr - p.LineCount = lines + p.LineCount = lines // TODO: replace with strings.Count(, "\n") + p.Breadcrumbs = Breadcrumbs(treePath) } h.templ(w, "repo_file", h.pageData(repo, p))

@@ -518,3 +520,25 @@ IsEmpty: empty,

}, } } + +type Breadcrumb struct { + Name string + Path string + IsLast bool +} + +func Breadcrumbs(path string) []Breadcrumb { + if path == "" { + return nil + } + parts := strings.Split(path, "/") + crumbs := make([]Breadcrumb, len(parts)) + for i, part := range parts { + crumbs[i] = Breadcrumb{ + Name: part, + Path: strings.Join(parts[:i+1], "/"), + IsLast: i == len(parts)-1, + } + } + return crumbs +}
M web/templates/repo_file.html

@@ -7,7 +7,15 @@ </head>

<body> {{ template "repo_header" . }} <main> - <p>{{ .P.Path }} (<a class="muted" href="?raw=true">view raw</a>)</p> + <p> + <a class="link" href="/{{ .RepoName }}/tree/{{ .P.Ref }}">{{ .RepoName }}</a> + {{- range .P.Breadcrumbs -}} + <span class="mode">/</span> + {{- if .IsLast -}}{{- .Name -}} + {{- else -}}<a class="link" href="{{ $.RepoName }}/tree/{{ $.P.Ref }}/{{ $.P.Path }}">{{ .Name }}</a>{{- end -}} + {{- end -}} + (<a class="muted" href="?raw=true">view raw</a>) + </p> <div class="file-wrapper"> {{ if .P.IsImage }} <div class="image-viewer">