Author: Honza Pokorny <me@honza.ca>
Add links to parents in tree
include/blob.html | 5 ++--- include/tree.html | 2 ++ pkg/smithy/smithy.go | 13 ++++++++-----
diff --git a/include/blob.html b/include/blob.html index 2a4c127bb21b73667f1f3e639c2aa68f037a2592..334dcf02fe9a5bdcc4ce9570b0d4066adb32e358 100644 --- a/include/blob.html +++ b/include/blob.html @@ -27,9 +27,8 @@ {{ $repo := .RepoName }} {{ $subtree := .SubTree }} {{ $ref := .RefName }} -ref: {{ .RefName }} - -<p>{{ .Path }}</p> +<p>ref: {{ $ref }}</p> +<p>./<a href="/{{ $repo }}/tree/{{ $ref }}/{{ .ParentPath }}">{{ .ParentPath }}</a>/{{ .File.Name }}</p> <hr> diff --git a/include/tree.html b/include/tree.html index c04d489b6884cb55419dabbb482581829f05861a..fd8aaab9204b2ea6a5f826bd15910fba84ee9e43 100644 --- a/include/tree.html +++ b/include/tree.html @@ -29,6 +29,8 @@ ref: {{ .RefName }} +<p><a href="/{{ $repo }}/tree/{{ $ref }}/{{ .ParentPath }}">{{ .ParentPath }}</a>/{{ $subtree}}</p> + <p> path: {{ .Path }} </p> diff --git a/pkg/smithy/smithy.go b/pkg/smithy/smithy.go index 58d5441bff63dfdbc0c7909c60d5f065cf594c6c..b05f70b100c2b027eda0e26497061961e9305a5c 100644 --- a/pkg/smithy/smithy.go +++ b/pkg/smithy/smithy.go @@ -367,6 +367,7 @@ if len(urlParts) > 2 { treePath = urlParts[2] } + parentPath := filepath.Dir(treePath) commitObj, err := r.CommitObject(*revision) if err != nil { @@ -410,11 +411,12 @@ return } entries := ConvertTreeEntries(subTree.Entries) ctx.HTML(http.StatusOK, "tree.html", gin.H{ - "RepoName": repoName, - "RefName": refNameString, - "SubTree": out.Name, - "Path": treePath, - "Files": entries, + "RepoName": repoName, + "ParentPath": parentPath, + "RefName": refNameString, + "SubTree": out.Name, + "Path": treePath, + "Files": entries, }) return } @@ -438,6 +440,7 @@ ctx.HTML(http.StatusOK, "blob.html", gin.H{ "RepoName": repoName, "RefName": refNameString, "File": out, + "ParentPath": parentPath, "Path": treePath, "Contents": contents, "ContentsHighlighted": template.HTML(syntaxHighlighted),