summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Medvedev <anton@medv.io>2025-12-07 20:12:04 +0100
committerAnton Medvedev <anton@medv.io>2025-12-07 20:12:04 +0100
commit4693364d59fce5d61cff503eae988edb57f4c1e9 (patch)
treed411bc37d595a024ee2cf54f1649dc9be7a847d9
parent59608fd41c1ec2bdab8dfebbb1786bd84d8b5fa1 (diff)
Replace `CurrentRef` with `CurrentRefDir` in layout parameters
-rw-r--r--blob.go26
-rw-r--r--branches.go12
-rw-r--r--commit.go12
-rw-r--r--commits_list.go12
-rw-r--r--index.go14
-rw-r--r--list.go14
-rw-r--r--pkg/templates/layout.gohtml4
-rw-r--r--pkg/templates/templates.go14
-rw-r--r--tags.go12
9 files changed, 60 insertions, 60 deletions
diff --git a/blob.go b/blob.go
index d8a6575..3739c58 100644
--- a/blob.go
+++ b/blob.go
@@ -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,
})
diff --git a/commit.go b/commit.go
index ef18913..028e8a9 100644
--- a/commit.go
+++ b/commit.go
@@ -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",
diff --git a/index.go b/index.go
index 593eed6..9ac6164 100644
--- a/index.go
+++ b/index.go
@@ -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,
diff --git a/list.go b/list.go
index 28dbf93..f1651d0 100644
--- a/list.go
+++ b/list.go
@@ -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 {
diff --git a/tags.go b/tags.go
index 5d5d0dc..eb3bdf0 100644
--- a/tags.go
+++ b/tags.go
@@ -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,
})