From 68e2091437e178dc98987d463180c17bfe346b9a Mon Sep 17 00:00:00 2001 From: tjpcc Date: Mon, 9 Oct 2023 09:01:24 -0600 Subject: use the {{join}} function in gopher templates $.Selector can be "/", which is handled better by 'join' than just concatenating with the template itself --- templates/ref.gph | 2 +- templates/repo_home.gph | 8 ++++---- templates/repo_root.gph | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/ref.gph b/templates/ref.gph index c7de102..f6b00cc 100644 --- a/templates/ref.gph +++ b/templates/ref.gph @@ -11,7 +11,7 @@ i {{$.Selector}} {{$.Host}} {{$.Port}} {{ end -}} {{ end -}} 1🗂️ Repository {{combine $.Selector ".."}} {{$.Host}} {{$.Port}} -1📄 Files {{$.Selector}}/tree {{$.Host}} {{$.Port}} +1📄 Files {{join $.Selector "/tree"}} {{$.Host}} {{$.Port}} {{ if ne .Parents nil -}} 0🔩 Full Diff {{join $.Selector "../../diff" .ParentHash .Hash}} {{$.Host}} {{$.Port}} {{ else -}} diff --git a/templates/repo_home.gph b/templates/repo_home.gph index 2ab17c2..29ed876 100644 --- a/templates/repo_home.gph +++ b/templates/repo_home.gph @@ -3,15 +3,15 @@ i{{ range .Repo.NameBytes }}-{{ end }} {{.Selector}} {{.Host}} {{.Port}} i {{.Selector}} {{.Host}} {{.Port}} i{{.Repo.Description}} {{.Selector}} {{.Host}} {{.Port}} i {{.Selector}} {{.Host}} {{.Port}} -1⌥ Branches {{.Selector}}/branches {{.Host}} {{.Port}} -1🏷️ Tags {{.Selector}}/tags {{.Host}} {{.Port}} -1📄 Files {{.Selector}}/refs/HEAD/tree {{.Host}} {{.Port}} +1⌥ Branches {{join .Selector "/branches"}} {{.Host}} {{.Port}} +1🏷️ Tags {{join .Selector "/tags"}} {{.Host}} {{.Port}} +1📄 Files {{join .Selector "/refs/HEAD/tree"}} {{.Host}} {{.Port}} i {{.Selector}} {{.Host}} {{.Port}} iLatest Commits: {{.Selector}} {{.Host}} {{.Port}} i {{.Selector}} {{.Host}} {{.Port}} {{ with .Repo.Commits .Ctx "HEAD" 5 -}} {{ range . -}} -1{{.ShortMessage}} {{$.Selector}}/refs/{{.Hash}} {{$.Host}} {{$.Port}} +1{{.ShortMessage}} {{join $.Selector "/refs/" .Hash}} {{$.Host}} {{$.Port}} {{ end -}} {{ if len . | eq 0 -}} i(no commits to show) {{$.Selector}} {{$.Host}} {{$.Port}} diff --git a/templates/repo_root.gph b/templates/repo_root.gph index 35592a4..e4e2754 100644 --- a/templates/repo_root.gph +++ b/templates/repo_root.gph @@ -2,6 +2,6 @@ iRepositories {{.Selector}} {{.Host}} {{.Port}} i------------ {{.Selector}} {{.Host}} {{.Port}} i {{.Selector}} {{.Host}} {{.Port}} {{ range .Repos -}} -1{{.}} {{$.Selector}}/{{.}} {{$.Host}} {{$.Port}} +1{{.}} {{join $.Selector .}} {{$.Host}} {{$.Port}} {{ end -}} . -- cgit v1.2.3