all repos

mugit @ e61accc

🐮 git server that your cow will love
10 files changed, 271 insertions(+), 224 deletions(-)
ui: refactor how data is passed to pages
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2026-02-20 21:24:04 +0200
Change ID: quxxpnkrkpsusuonusotlxrzormroouv
Parent: 8fee104
M internal/handlers/repo.go

@@ -23,18 +23,44 @@ "olexsmir.xyz/mugit/internal/git"

"olexsmir.xyz/mugit/internal/mdx" ) +type Meta struct { + Title string + Description string + Host string + IsEmpty bool + GoMod bool + SSHEnabled bool +} + +type RepoBase struct { + Ref string + Desc string +} + +type PageData[T any] struct { + Meta Meta + RepoName string // empty for non-repo pages, needed for _head.html to compile + P T +} + func (h *handlers) indexHandler(w http.ResponseWriter, r *http.Request) { repos, err := h.listPublicRepos() if err != nil { h.write500(w, err) return } + h.templ(w, "index", h.pageData(nil, repos)) +} - data := make(map[string]any) - data["meta"] = h.c.Meta - data["repos"] = repos - data["servername"] = h.c.Meta.Host - h.templ(w, "index", data) +type RepoIndex struct { + Desc string + IsEmpty bool + Readme template.HTML + Ref string + Commits []*git.Commit + IsMirror bool + MirrorURL string + MirrorLastSync time.Time } func (h *handlers) repoIndex(w http.ResponseWriter, r *http.Request) {

@@ -50,56 +76,50 @@ h.write500(w, err)

return } - data := make(map[string]any) - data["name"] = repo.Name() - data["desc"] = desc - data["servername"] = h.c.Meta.Host - data["meta"] = h.c.Meta - - if repo.IsEmpty() { - data["empty"] = true - h.templ(w, "repo_index", data) + p := RepoIndex{Desc: desc, IsEmpty: repo.IsEmpty()} + if p.IsEmpty { + h.templ(w, "repo_index", h.pageData(repo, p)) return } - masterBranch, err := repo.FindMasterBranch(h.c.Repo.Masters) + p.Ref, err = repo.FindMasterBranch(h.c.Repo.Masters) if err != nil { h.write500(w, err) return } - readme, err := h.renderReadme(repo) + p.Readme, err = h.renderReadme(repo) if err != nil { h.write500(w, err) return } - commits, err := repo.Commits() + p.Commits, err = repo.Commits() if err != nil { h.write500(w, err) return } - if len(commits) >= 4 { - commits = commits[:3] + if len(p.Commits) >= 3 { + p.Commits = p.Commits[:3] } - data["ref"] = masterBranch - data["readme"] = readme - data["commits"] = commits - data["gomod"] = repo.IsGoMod() + if isMirror, err := repo.IsMirror(); isMirror && err == nil { + p.IsMirror = true + p.MirrorURL, _ = repo.RemoteURL() + p.MirrorLastSync, _ = repo.LastSync() + } - if isMirror, err := repo.IsMirror(); err == nil && isMirror { - lastSync, _ := repo.LastSync() - remoteURL, _ := repo.RemoteURL() - data["mirrorinfo"] = map[string]any{ - "isMirror": true, - "url": remoteURL, - "lastSync": lastSync, - } - } + h.templ(w, "repo_index", h.pageData(repo, p)) +} - h.templ(w, "repo_index", data) +type RepoTree struct { + Desc string + Ref string + Tree []git.NiceTree + ParentPath string + DotDot string + Readme template.HTML } func (h *handlers) repoTreeHandler(w http.ResponseWriter, r *http.Request) {

@@ -119,22 +139,33 @@ h.write500(w, err)

return } - files, err := repo.FileTree(treePath) + tree, err := repo.FileTree(treePath) if err != nil { h.write500(w, err) return } - data := make(map[string]any) - data["name"] = name - data["ref"] = ref - data["parent"] = treePath - data["dotdot"] = filepath.Dir(treePath) - data["desc"] = desc - data["meta"] = h.c.Meta - data["files"] = files + h.templ(w, "repo_tree", h.pageData(repo, RepoTree{ + Desc: desc, + Ref: ref, + Tree: tree, + ParentPath: treePath, + DotDot: filepath.Dir(treePath), + // TODO: return the readme + Readme: "", + })) +} - h.templ(w, "repo_tree", data) +type RepoFile struct { + Ref string + Desc string + LineCount []int + Path string + IsImage bool + IsBinary bool + Content string + Mime string + Size int64 } func (h *handlers) fileContentsHandler(w http.ResponseWriter, r *http.Request) {

@@ -150,12 +181,6 @@

repo, err := h.openPublicRepo(name, ref) if err != nil { h.write404(w, err) - return - } - - desc, err := repo.Description() - if err != nil { - h.write500(w, err) return }

@@ -176,45 +201,42 @@ w.Write(fc.Content)

return } - if fc.IsImage() || fc.IsBinary { - data := make(map[string]any) - data["name"] = name - data["ref"] = ref - data["desc"] = desc - data["path"] = treePath - data["is_image"] = fc.IsImage() - data["is_binary"] = fc.IsBinary - data["mime_type"] = fc.Mime - data["size"] = fc.Size - data["meta"] = h.c.Meta - h.templ(w, "repo_file", data) - return + p := RepoFile{ + Ref: ref, + Path: treePath, + IsImage: fc.IsImage(), + IsBinary: fc.IsBinary, + Mime: fc.Mime, + Size: fc.Size, } - data := make(map[string]any) - data["name"] = name - data["ref"] = ref - data["desc"] = desc - data["path"] = treePath - - contentStr := fc.String() - lc, err := countLines(strings.NewReader(contentStr)) + p.Desc, err = repo.Description() if err != nil { - slog.Error("failed to count line numbers", "err", err) + h.write500(w, err) + return } - lines := make([]int, lc) - if lc > 0 { + if !fc.IsImage() && !fc.IsBinary { + contentStr := fc.String() + lc, err := countLines(strings.NewReader(contentStr)) + if err != nil { + slog.Error("failed to count line numbers", "err", err) + } + lines := make([]int, lc) for i := range lines { lines[i] = i + 1 } + p.Content = contentStr + p.LineCount = lines } - data["linecount"] = lines - data["content"] = contentStr - data["meta"] = h.c.Meta + h.templ(w, "repo_file", h.pageData(repo, p)) +} - h.templ(w, "repo_file", data) +type RepoLog struct { + Desc string + Commits []*git.Commit + Ref string } func (h *handlers) logHandler(w http.ResponseWriter, r *http.Request) {

@@ -239,14 +261,17 @@ h.write500(w, err)

return } - data := make(map[string]any) - data["name"] = name - data["ref"] = ref - data["desc"] = desc - data["meta"] = h.c.Meta - data["log"] = true - data["commits"] = commits - h.templ(w, "repo_log", data) + h.templ(w, "repo_log", h.pageData(repo, RepoLog{ + Desc: desc, + Commits: commits, + Ref: ref, + })) +} + +type RepoCommit struct { + Diff *git.NiceDiff + Ref string + Desc string } func (h *handlers) commitHandler(w http.ResponseWriter, r *http.Request) {

@@ -270,15 +295,18 @@ h.write500(w, err)

return } - data := make(map[string]any) - data["diff"] = diff.Diff - data["commit"] = diff.Commit - data["parents"] = diff.Parents - data["stat"] = diff.Stat - data["name"] = name - data["ref"] = ref - data["desc"] = desc - h.templ(w, "repo_commit", data) + h.templ(w, "repo_commit", h.pageData(repo, RepoCommit{ + Desc: desc, + Ref: ref, + Diff: diff, + })) +} + +type RepoRefs struct { + Desc string + Ref string + Branches []*git.Branch + Tags []*git.TagReference } func (h *handlers) refsHandler(w http.ResponseWriter, r *http.Request) {

@@ -294,7 +322,7 @@ h.write500(w, err)

return } - masterBranch, err := repo.FindMasterBranch(h.c.Repo.Masters) + master, err := repo.FindMasterBranch(h.c.Repo.Masters) if err != nil { h.write500(w, err) return

@@ -306,20 +334,15 @@ h.write500(w, err)

return } - tags, err := repo.Tags() - if err != nil { - // repo should have at least one branch, tags are *optional* - slog.Error("couldn't fetch repo tags", "err", err) - } + // repo should have at least one branch, tags are *optional* + tags, _ := repo.Tags() - data := make(map[string]any) - data["meta"] = h.c.Meta - data["name"] = repo.Name() - data["desc"] = desc - data["ref"] = masterBranch - data["branches"] = branches - data["tags"] = tags - h.templ(w, "repo_refs", data) + h.templ(w, "repo_refs", h.pageData(repo, RepoRefs{ + Desc: desc, + Ref: master, + Tags: tags, + Branches: branches, + })) } func countLines(r io.Reader) (int, error) {

@@ -452,3 +475,26 @@

h.readmeCache.Set(name, readmeContents) return readmeContents, nil } + +func (h handlers) pageData(repo *git.Repo, p any) PageData[any] { + var name string + var gomod, empty bool + if repo != nil { + gomod = repo.IsGoMod() + empty = repo.IsEmpty() + name = repo.Name() + } + + return PageData[any]{ + P: p, + RepoName: name, + Meta: Meta{ + Title: h.c.Meta.Title, + Description: h.c.Meta.Description, + Host: h.c.Meta.Host, + GoMod: gomod, + SSHEnabled: h.c.SSH.Enable, + IsEmpty: empty, + }, + } +}
M web/templates/_head.html

@@ -3,13 +3,13 @@ <meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="/static/style.css" type="text/css"> <link rel="icon" href="/static/favicon.svg"> - {{ if and .servername .gomod }} - <meta name="go-import" content="{{ .servername}}/{{ .name }} git https://{{ .servername }}/{{ .name }}"> - {{ end }} - {{ if and .servername .name }} - <link rel="alternate" type="application/rss" href="https://{{ .servername }}/{{ .name }}/feed"> + + {{ if .Meta.GoMod }} + <meta name="go-import" content="{{.Meta.Host}}/{{.RepoName}} git https://{{.Meta.Host}}/{{.RepoName}}"> {{ end }} - {{ if .servername }} - <link rel="alternate" type="application/rss" href="https://{{ .servername }}/index.xml"> + + <link ref="alternate" type="application/rss" href="https://{{.Meta.Host}}/index.xml"> + {{ if .RepoName }} + <link ref="alternate" type="application/rss" href="https://{{.Meta.Host}}/{{.RepoName}}/feed"> {{ end }} {{ end }}
M web/templates/_repo_header.html

@@ -4,22 +4,22 @@ <div class="repo-breadcrumb">

<a href="/">all repos</a> </div> <h1 class="repo-name"> - {{ .name }} - {{- if .ref }} - <span class="ref">@ {{ .ref }}</span> + {{ .RepoName }} + {{- if .P.Ref }} + <span class="ref">@ {{ .P.Ref }}</span> {{- end }} </h1> - {{- if .desc }} - <div class="desc muted">{{ .desc }}</div> + {{- if .P.Desc }} + <div class="desc muted">{{ .P.Desc }}</div> {{- end }} - {{- if not .empty }} + {{- if not .Meta.IsEmpty }} <nav class="repo-nav"> <ul> - <li><a href="/{{ .name }}">summary</a></li> - <li><a href="/{{ .name }}/refs">refs</a></li> - <li><a href="/{{ .name }}/tree/{{ .ref }}/">tree</a></li> - <li><a href="/{{ .name }}/log/{{ .ref }}">log</a></li> + <li><a href="/{{ .RepoName }}">summary</a></li> + <li><a href="/{{ .RepoName }}/refs">refs</a></li> + <li><a href="/{{ .RepoName }}/tree/{{ .P.Ref }}/">tree</a></li> + <li><a href="/{{ .RepoName }}/log/{{ .P.Ref }}">log</a></li> </ul> </nav> {{- end }}
M web/templates/index.html

@@ -3,12 +3,12 @@ <!DOCTYPE html>

<html> <head> {{ template "head" . }} - <title>{{ .meta.Title }}</title> + <title>{{ .Meta.Title }}</title> </head> <body> <header> - <h1>{{ .meta.Title }}</h1> - {{ if .meta.Description }}<h2>{{ .meta.Description }}</h2>{{ end }} + <h1>{{ .Meta.Title }}</h1> + {{ if .Meta.Description }}<h2>{{ .Meta.Description }}</h2>{{ end }} </header> <main> <table class="table index">

@@ -20,7 +20,7 @@ <th class="nowrap">Last update</th>

</tr> </thead> <tbody> - {{- range .repos }} + {{- range .P }} <tr> <td class="nowrap"><a href="/{{ .Name }}">{{ .Name }}</a></td> <td class="fill">
M web/templates/repo_commit.html

@@ -1,54 +1,58 @@

{{ define "repo_commit" }} +{{ $commit := .P.Diff.Commit }} +{{ $diff := .P.Diff.Diff }} +{{ $stat := .P.Diff.Stat }} +{{ $parents := .P.Diff.Parents }} <html> <head> {{ template "head" . }} - <title>{{ .name }}: {{ .commit.HashShort }}</title> + <title>{{ .RepoName }}: {{ $commit.HashShort }}</title> </head> <body> {{ template "repo_header" . }} <main> <section class="commit"> <div class="commit-refs"> - {{ .stat.FilesChanged }} files changed, - {{ .stat.Insertions }} insertions(+), - {{ .stat.Deletions }} deletions(-) + {{ $stat.FilesChanged }} files changed, + {{ $stat.Insertions }} insertions(+), + {{ $stat.Deletions }} deletions(-) </div> <div class="box"> <pre class="commit-message"> - {{- if .commit.Message }}{{- .commit.Message -}} + {{- if $commit.Message }}{{- $commit.Message -}} {{- else -}}<span class="muted">Empty message</span>{{- end -}} </pre> <div> <strong>Author:</strong> - {{ .commit.AuthorName }} - <a href="mailto:{{ .AuthorEmail }}" class="commit-email">{{ .commit.AuthorEmail }}</a> + {{ $commit.AuthorName }} + <a href="mailto:{{ $commit.AuthorEmail }}" class="commit-email">{{ $commit.AuthorEmail }}</a> </div> <div> <strong>Committed at:</strong> - {{ .commit.Committed }} + {{ $commit.Committed }} </div> - {{ if .commit.ChangeID -}} + {{ if $commit.ChangeID -}} <div> <strong>Change ID:</strong> - {{ .commit.ChangeID }} + {{ $commit.ChangeID }} </div> {{- end }} <div> <strong>Parent:</strong> - {{ range $i, $p := .parents -}} + {{ range $i, $p := $parents -}} {{ if $i }}, {{ end -}} - <a class="link" href="/{{ $.name }}/commit/{{ $p }}">{{ $p }}</a> + <a class="link" href="/{{$.RepoName}}/commit/{{ $p }}">{{ $p }}</a> {{- end }} </div> </div> - {{ if gt (len .diff) 1 -}} + {{ if gt (len $diff) 1 -}} <div class="jump"> <strong>jump to</strong> <table class="table jump-table"> <tbody> - {{ range .diff }} + {{ range $diff }} {{ $path := .Name.New }} {{ if not $path }}{{ $path = .Name.Old }}{{ end }} <tr>

@@ -70,10 +74,9 @@ </div>

{{ end }} </section> <section> - {{ $repo := .name }} - {{ $this := .commit.Hash }} - {{ $parent := index .parents 0 }} - {{ range .diff }} + {{ $this := $commit.Hash }} + {{ $parent := index $parents 0 }} + {{ range $diff }} {{ $path := .Name.New }} {{ if not $path }}{{ $path = .Name.Old }}{{ end }} <div id="{{ $path }}">

@@ -88,13 +91,13 @@ {{ if not (or .IsNew .IsDelete) }}

<span class="diff-type diff-mod">M</span> {{ end }} {{ if .Name.Old }} - <a href="/{{ $repo }}/blob/{{ $parent }}/{{ .Name.Old }}">{{ .Name.Old }}</a> + <a href="/{{$.RepoName}}/blob/{{ $parent }}/{{ .Name.Old }}">{{ .Name.Old }}</a> {{ if .Name.New }} &#8594; - <a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a> + <a href="/{{$.RepoName}}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a> {{ end }} {{ else }} - <a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a> + <a href="/{{$.RepoName}}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a> {{- end -}} {{ if .IsBinary }} <p>Not showing binary file.</p>
M web/templates/repo_file.html

@@ -2,36 +2,38 @@ {{ define "repo_file" }}

<html> <head> {{ template "head" . }} - <title>{{ .name }}: {{ .path }} ({{ .ref }})</title> + <title>{{ .RepoName }}: {{ .P.Path }} ({{ .P.Ref }})</title> </head> <body> {{ template "repo_header" . }} <main> - <p>{{ .path }} (<a class="muted" href="?raw=true">view raw</a>)</p> + <p>{{ .P.Path }} (<a class="muted" href="?raw=true">view raw</a>)</p> <div class="file-wrapper"> - {{ if .is_image }} + {{ if .P.IsImage }} <div class="image-viewer"> - <p>{{.mime_type}} • {{.size}} bytes</p> - <img src="?raw=true" alt="{{- .path -}}"> + <p>{{ .P.Mime }} • {{ .P.Size }} bytes</p> + <img src="?raw=true" alt="{{- .P.Path -}}"> </div> - {{ else if .is_binary }} + {{ else if .P.IsBinary }} <div class="binary-viewer"> - <p>Binary file ({{.mime_type}})</p> - <p>Size: {{.size}} bytes</p> + <p>Binary file ({{ .P.Mime }})</p> + <p>Size: {{ .P.Size }} bytes</p> <a class="link" href="?raw=true" download>[ Download ]</a> </div> {{ else }} <table> - <tbody><tr> - <td class="line-numbers"> - <pre>{{- range .linecount }} + <tbody> + <tr> + <td class="line-numbers"> +<pre>{{- range .P.LineCount }} <a id="L{{ . }}" href="#L{{ . }}">{{ . }}</a> {{- end -}}</pre> - </td> - <td class="file-content"> - <pre>{{- .content -}}</pre> - </td> - </tbody></tr> + </td> + <td class="file-content"> + <pre>{{- .P.Content -}}</pre> + </td> + </tr> + </tbody> </table> {{ end }} </div>
M web/templates/repo_index.html

@@ -3,18 +3,18 @@ <!DOCTYPE html>

<html> <head> {{ template "head" . }} - <title>{{ .name }} &mdash; {{ .meta.Title }}</title> + <title>{{ .RepoName}} &mdash; {{ .Meta.Title }}</title> </head> <body> {{ template "repo_header" . }} <main> - {{ $repo := .name }} - {{ if .empty }} + {{ if .P.IsEmpty }} <h3>Repository is empty</h3> {{ else }} <section class="repo-index"> <div class="repo-index-main"> - {{ range .commits }} + {{ $repo := .RepoName }} + {{ range .P.Commits }} <div class="box"> <div> <a href="/{{ $repo }}/commit/{{ .Hash }}" class="commit-hash link">{{ .HashShort }}</a>

@@ -34,27 +34,22 @@ </div>

<div class="repo-index-side"> <h2>Clone urls</h2> - <pre>{{- /* */ -}} -https://{{ .servername }}/{{ .name }} -git@{{ .servername }}:{{ .name }} -{{- /* */ -}}</pre> - - {{- if .mirrorinfo.isMirror }} + <pre>https://{{.Meta.Host}}/{{.RepoName}}</pre> + {{ if .Meta.SSHEnabled }}<pre>git@{{.Meta.Host}}:{{.RepoName}}</pre>{{end}} + {{- if .P.IsMirror -}} <br> - <h2>Mirror Status</h3> - <p> - Last updated {{ humanizeTime .mirrorinfo.lastSync }} from: - <a href="{{ .mirrorinfo.url }}" target="_blank">{{ .mirrorinfo.url }}</a> - </p> - {{- end }} + <h2>Mirror status</h2> + <p> + Last updated {{ humanizeTime .P.MirrorLastSync }} from: + <a href="{{.P.MirrorURL}}" target="_blank">{{.P.MirrorURL}}</a> + </p> + {{- end}} </div> </section> {{ end }} - {{- if .readme }} - <article class="readme"> - {{- .readme -}} - </article> + {{- if .P.Readme }} + <article class="readme">{{- .P.Readme -}}</article> {{- end -}} </main> </body>
M web/templates/repo_log.html

@@ -1,13 +1,13 @@

{{ define "repo_log" }} +{{ $repo := .RepoName }} <html> <head> {{ template "head" . }} - <title>{{ .name }}: log</title> + <title>{{ $repo }}: log</title> </head> <body> {{ template "repo_header" . }} <main> - {{ $repo := .name }} <table class="table log"> <thead> <tr class="nohover">

@@ -18,13 +18,13 @@ <th class="age nowrap">Age</th>

</tr> </thead> <tbody> - {{ range .commits }} + {{ range .P.Commits }} <tr> <td class="fill"> <a href="/{{ $repo }}/commit/{{ .Hash }}"> {{- if .Message }}{{- commitSummary .Message -}} {{- else -}}<span class="muted">Empty message</span>{{- end -}} - </a> + </a> </td> <td class="author nowrap"> <span class="author-short">
M web/templates/repo_refs.html

@@ -1,38 +1,41 @@

{{ define "repo_refs" }} +{{ $repo := .RepoName }} <html> <head> {{ template "head" . }} - <title>{{ .name }}: refs</title> + <title>{{ $repo }}: refs</title> </head> <body> {{ template "repo_header" . }} <main> - {{ $name := .name }} <h3>branches</h3> <div class="refs"> - {{ range .branches }} + {{ range .P.Branches }} <div> - <strong>{{ .Name }}</strong> - <a class="link" href="/{{ $name }}/tree/{{ .Name }}/">browse</a> - <a class="link" href="/{{ $name }}/log/{{ .Name }}">log</a> - <a class="link" href="/{{ $name }}/archive/{{ .Name }}">tar.gz</a> + <strong>{{ .Name }}</strong> + <a class="link" href="/{{ $repo }}/tree/{{ .Name }}/">browse</a> + <a class="link" href="/{{ $repo }}/log/{{ .Name }}">log</a> + <a class="link" href="/{{ $repo }}/archive/{{ .Name }}">tar.gz</a> </div> - {{ end }} + {{ end }} </div> - {{ if .tags }} + {{ if .P.Tags }} <h3>tags</h3> <div class="refs"> - {{ range .tags }} - <div> - <strong>{{ .Name }}</strong> - <a class="link" href="/{{ $name }}/tree/{{ .Name }}/">browse</a> - <a class="link" href="/{{ $name }}/log/{{ .Name }}">log</a> - <a class="link" href="/{{ $name }}/archive/{{ .Name }}">tar.gz</a> - {{ if .Message }} - <pre>{{ .Message }}</pre> - </div> - {{ end }} - {{ end }} + {{ range .P.Tags }} + <div> + <strong>{{ .Name }}</strong> + <a class="link" href="/{{ $repo }}/tree/{{ .Name }}/">browse</a> + <a class="link" href="/{{ $repo }}/log/{{ .Name }}">log</a> + <a class="link" href="/{{ $repo }}/archive/{{ .Name }}">tar.gz</a> + {{ if .Message }} + <details> + <summary>message</summary> + <pre>{{ .Message }}</pre> + </details> + {{ end }} + </div> + {{ end }} </div> {{ end }} </main>
M web/templates/repo_tree.html

@@ -1,15 +1,15 @@

{{ define "repo_tree" }} +{{ $name := .RepoName }} +{{ $ref := .P.Ref }} <html> <head> {{ template "head" . }} - <title>{{ .name }}: tree ({{ .ref }})</title> + <title>{{ $name }}: tree ({{ $ref }})</title> </head> <body> {{ template "repo_header" . }} <main> - {{ $repo := .name }} - {{ $ref := .ref }} - {{ $parent := .parent }} + {{ $parent := .P.ParentPath }} <table class="table tree"> <thead>

@@ -24,36 +24,36 @@ {{ if $parent }}

<tr> <td class="mode nowrap"></td> <td class="size nowrap"></td> - <td class="fill"><a href="/{{ $repo }}/tree/{{ $ref }}/{{ .dotdot }}">..</a></td> + <td class="fill"><a href="/{{ $name }}/tree/{{ $ref }}/{{ .P.DotDot }}">..</a></td> </tr> {{ end }} - {{ range .files }} + {{ range .P.Tree }} {{ if not .IsFile }} <tr> <td class="mode nowrap">{{ .Mode }}</td> <td class="size nowrap">{{ .Size }}</td> <td class="fill"> {{ if $parent }} - <a href="/{{ $repo }}/tree/{{ $ref }}/{{ $parent }}/{{ .Name }}">{{ .Name }}/</a> + <a href="/{{ $name}}/tree/{{ $ref }}/{{ $parent }}/{{ .Name }}">{{ .Name }}/</a> {{ else }} - <a href="/{{ $repo }}/tree/{{ $ref }}/{{ .Name }}">{{ .Name }}/</a> + <a href="/{{ $name }}/tree/{{ $ref }}/{{ .Name }}">{{ .Name }}/</a> {{ end }} </td> </tr> {{ end }} {{ end }} - {{ range .files }} + {{ range .P.Tree }} {{ if .IsFile }} <tr> <td class="mode nowrap">{{ .Mode }}</td> <td class="size nowrap">{{ .Size }}</td> <td class="fill"> {{ if $parent }} - <a href="/{{ $repo }}/blob/{{ $ref }}/{{ $parent }}/{{ .Name }}">{{ .Name }}</a> + <a href="/{{ $name }}/blob/{{ $ref }}/{{ $parent }}/{{ .Name }}">{{ .Name }}</a> {{ else }} - <a href="/{{ $repo }}/blob/{{ $ref }}/{{ .Name }}">{{ .Name }}</a> + <a href="/{{ $name }}/blob/{{ $ref }}/{{ .Name }}">{{ .Name }}</a> {{ end }} </td> </tr>

@@ -63,9 +63,7 @@ </tbody>

</table> <article> - <pre> - {{- if .readme }}{{ .readme }}{{- end -}} - </pre> + <pre>{{- if .P.Readme }}{{ .P.Readme }}{{- end -}}</pre> </article> </main> </body>