diff options
| author | Anton Medvedev <anton@medv.io> | 2025-12-07 20:12:04 +0100 |
|---|---|---|
| committer | Anton Medvedev <anton@medv.io> | 2025-12-07 20:12:04 +0100 |
| commit | 4693364d59fce5d61cff503eae988edb57f4c1e9 (patch) | |
| tree | d411bc37d595a024ee2cf54f1649dc9be7a847d9 | |
| parent | 59608fd41c1ec2bdab8dfebbb1786bd84d8b5fa1 (diff) | |
Replace `CurrentRef` with `CurrentRefDir` in layout parameters
| -rw-r--r-- | blob.go | 26 | ||||
| -rw-r--r-- | branches.go | 12 | ||||
| -rw-r--r-- | commit.go | 12 | ||||
| -rw-r--r-- | commits_list.go | 12 | ||||
| -rw-r--r-- | index.go | 14 | ||||
| -rw-r--r-- | list.go | 14 | ||||
| -rw-r--r-- | pkg/templates/layout.gohtml | 4 | ||||
| -rw-r--r-- | pkg/templates/templates.go | 14 | ||||
| -rw-r--r-- | tags.go | 12 |
9 files changed, 60 insertions, 60 deletions
@@ -134,13 +134,13 @@ func generateBlobs(files []git.Blob, params Params) error { err = templates.MarkdownTemplate.ExecuteTemplate(f, "layout.gohtml", templates.MarkdownParams{ LayoutParams: templates.LayoutParams{ - Title: fmt.Sprintf("%s/%s at %s", params.Name, blob.Path, params.Ref), - Dark: params.Dark, - CSSMarkdown: cssMarkdown(params.Dark), - Name: params.Name, - RootHref: rootHref, - CurrentRef: params.Ref, - Selected: "code", + Title: fmt.Sprintf("%s/%s at %s", params.Name, blob.Path, params.Ref), + Dark: params.Dark, + CSSMarkdown: cssMarkdown(params.Dark), + Name: params.Name, + RootHref: rootHref, + CurrentRefDir: params.Ref.DirName(), + Selected: "code", }, HeaderParams: templates.HeaderParams{ Ref: params.Ref, @@ -193,12 +193,12 @@ func generateBlobs(files []git.Blob, params Params) error { err = templates.BlobTemplate.ExecuteTemplate(f, "layout.gohtml", templates.BlobParams{ LayoutParams: templates.LayoutParams{ - Title: fmt.Sprintf("%s/%s at %s", params.Name, blob.Path, params.Ref), - Dark: params.Dark, - Name: params.Name, - RootHref: rootHref, - CurrentRef: params.Ref, - Selected: "code", + Title: fmt.Sprintf("%s/%s at %s", params.Name, blob.Path, params.Ref), + Dark: params.Dark, + Name: params.Name, + RootHref: rootHref, + CurrentRefDir: params.Ref.DirName(), + Selected: "code", }, HeaderParams: templates.HeaderParams{ Ref: params.Ref, diff --git a/branches.go b/branches.go index 13f44f0..7faf037 100644 --- a/branches.go +++ b/branches.go @@ -48,12 +48,12 @@ func generateBranches(branches []git.Ref, defaultBranch string, params Params) e err = templates.BranchesTemplate.ExecuteTemplate(f, "layout.gohtml", templates.BranchesParams{ LayoutParams: templates.LayoutParams{ - Title: fmt.Sprintf("Branches %s %s", dot, params.Name), - Name: params.Name, - Dark: params.Dark, - RootHref: rootHref, - CurrentRef: params.DefaultRef, - Selected: "branches", + Title: fmt.Sprintf("Branches %s %s", dot, params.Name), + Name: params.Name, + Dark: params.Dark, + RootHref: rootHref, + CurrentRefDir: params.DefaultRef.DirName(), + Selected: "branches", }, Branches: entries, }) @@ -236,12 +236,12 @@ func generateCommitPage(commit git.Commit, params Params) error { err = templates.CommitTemplate.ExecuteTemplate(f, "layout.gohtml", templates.CommitParams{ LayoutParams: templates.LayoutParams{ - Title: fmt.Sprintf("%s %s %s@%s", commit.Subject, dot, params.Name, commit.ShortHash), - Name: params.Name, - Dark: params.Dark, - RootHref: rootHref, - CurrentRef: currentRef, - Selected: "commits", + Title: fmt.Sprintf("%s %s %s@%s", commit.Subject, dot, params.Name, commit.ShortHash), + Name: params.Name, + Dark: params.Dark, + RootHref: rootHref, + CurrentRefDir: currentRef.DirName(), + Selected: "commits", }, Commit: commit, DiffCSS: template.CSS(cssBuf.String()), diff --git a/commits_list.go b/commits_list.go index 837a480..b09424e 100644 --- a/commits_list.go +++ b/commits_list.go @@ -62,12 +62,12 @@ func generateLogForBranch(allCommits []git.Commit, params Params) error { err = templates.CommitsListTemplate.ExecuteTemplate(f, "layout.gohtml", templates.CommitsListParams{ LayoutParams: templates.LayoutParams{ - Title: fmt.Sprintf("Commits %s %s", dot, params.Name), - Name: params.Name, - Dark: params.Dark, - RootHref: rootHref, - CurrentRef: params.Ref, - Selected: "commits", + Title: fmt.Sprintf("Commits %s %s", dot, params.Name), + Name: params.Name, + Dark: params.Dark, + RootHref: rootHref, + CurrentRefDir: params.Ref.DirName(), + Selected: "commits", }, HeaderParams: templates.HeaderParams{ Header: "Commits", @@ -100,13 +100,13 @@ func generateIndex(files []git.Blob, params Params) error { err = templates.ListTemplate.ExecuteTemplate(f, "layout.gohtml", templates.ListParams{ LayoutParams: templates.LayoutParams{ - Title: title, - Name: params.Name, - Dark: params.Dark, - CSSMarkdown: cssMarkdown(params.Dark), - RootHref: rootHref, - CurrentRef: params.Ref, - Selected: "code", + Title: title, + Name: params.Name, + Dark: params.Dark, + CSSMarkdown: cssMarkdown(params.Dark), + RootHref: rootHref, + CurrentRefDir: params.Ref.DirName(), + Selected: "code", }, HeaderParams: templates.HeaderParams{ Ref: params.Ref, @@ -183,13 +183,13 @@ func generateLists(files []git.Blob, params Params) error { err = templates.ListTemplate.ExecuteTemplate(f, "layout.gohtml", templates.ListParams{ LayoutParams: templates.LayoutParams{ - Title: title, - Name: params.Name, - Dark: params.Dark, - CSSMarkdown: CSSMarkdown, - RootHref: rootHref, - CurrentRef: params.Ref, - Selected: "code", + Title: title, + Name: params.Name, + Dark: params.Dark, + CSSMarkdown: CSSMarkdown, + RootHref: rootHref, + CurrentRefDir: params.Ref.DirName(), + Selected: "code", }, HeaderParams: templates.HeaderParams{ Ref: params.Ref, diff --git a/pkg/templates/layout.gohtml b/pkg/templates/layout.gohtml index 5073b81..9712577 100644 --- a/pkg/templates/layout.gohtml +++ b/pkg/templates/layout.gohtml @@ -268,7 +268,7 @@ <div class="menu"> <a href="{{ .RootHref }}index.html" class="project-name">{{ .Name }}</a> <div class="menu-item {{ if eq .Selected "code" }}selected{{ end }}"> - <a href="{{ .RootHref }}blob/{{ .CurrentRef }}/index.html"> + <a href="{{ .RootHref }}blob/{{ .CurrentRefDir }}/index.html"> <svg aria-hidden="true" width="16" height="16"> <use xlink:href="#code"></use> </svg> @@ -292,7 +292,7 @@ </a> </div> <div class="menu-item {{ if eq .Selected "commits" }}selected{{ end }}"> - <a href="{{ .RootHref }}commits/{{ .CurrentRef }}/index.html"> + <a href="{{ .RootHref }}commits/{{ .CurrentRefDir }}/index.html"> <svg aria-hidden="true" focusable="false" width="16" height="16"> <use xlink:href="#commit"></use> </svg> diff --git a/pkg/templates/templates.go b/pkg/templates/templates.go index 058454f..91d4884 100644 --- a/pkg/templates/templates.go +++ b/pkg/templates/templates.go @@ -66,13 +66,13 @@ var previewContent string var PreviewTemplate = Must(New("preview").Parse(previewContent)) type LayoutParams struct { - Title string - Name string - Dark bool - CSSMarkdown CSS - RootHref string - CurrentRef git.Ref - Selected string + Title string + Name string + Dark bool + CSSMarkdown CSS + RootHref string + CurrentRefDir string + Selected string } type HeaderParams struct { @@ -25,12 +25,12 @@ func generateTags(entries []git.Tag, params Params) error { return templates.TagsTemplate.ExecuteTemplate(f, "layout.gohtml", templates.TagsParams{ LayoutParams: templates.LayoutParams{ - Title: fmt.Sprintf("Tags %s %s", dot, params.Name), - Name: params.Name, - Dark: params.Dark, - RootHref: rootHref, - CurrentRef: params.DefaultRef, - Selected: "tags", + Title: fmt.Sprintf("Tags %s %s", dot, params.Name), + Name: params.Name, + Dark: params.Dark, + RootHref: rootHref, + CurrentRefDir: params.DefaultRef.DirName(), + Selected: "tags", }, Tags: entries, }) |
