diff --git a/dir-index.html b/dir-index.html index 2e5d507d36cb7ae81a1399c7646eeb0ad7064c35..7f2ce117699d8ba624a6de2c7401b4b88bd3860b 100644 --- a/dir-index.html +++ b/dir-index.html @@ -55,7 +55,14 @@
- Index of {{ .Path }} + + Index of + {{ range .Breadcrumbs -}} + /{{ if .Path }}{{ .Name }}{{ else }}{{ .Name }}{{ end }} + {{- else }} + {{ .Path }} + {{ end }} + {{ if .Hash }}
{{ .Hash }} diff --git a/test/main.go b/test/main.go index e4a4153f0ac9f782492eea59435b0fba94c4e255..6c851aeb595e6c547880e0fca9eefdc50494bfa1 100644 --- a/test/main.go +++ b/test/main.go @@ -15,6 +15,7 @@ type listingTemplateData struct { Listing []directoryItem Size string Path string + Breadcrumbs []breadcrumb BackLink string Hash string } @@ -25,20 +26,41 @@ type directoryItem struct { Path string } +type breadcrumb struct { + Name string + Path string +} + +var testPath = "/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7/a/b/c" var testData = listingTemplateData{ Listing: []directoryItem{{ Size: "25 MiB", Name: "short-film.mov", - Path: "short-film.mov", + Path: testPath + "/short-film.mov", }, { Size: "1 KiB", Name: "this-piece-of-papers-got-47-words-37-sentences-58-words-we-wanna-know.txt", - Path: "this-piece-of-papers-got-47-words-37-sentences-58-words-we-wanna-know.txt", + Path: testPath + "/this-piece-of-papers-got-47-words-37-sentences-58-words-we-wanna-know.txt", }}, Size: "25 MiB", - Path: "/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm", - BackLink: "/..", - Hash: "QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm", + Path: testPath, + Breadcrumbs: []breadcrumb{{ + Name: "ipfs", + }, { + Name: "QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7", + Path: testPath + "/../../..", + }, { + Name: "a", + Path: testPath + "/../..", + }, { + Name: "b", + Path: testPath + "/..", + }, { + Name: "c", + Path: testPath, + }}, + BackLink: testPath + "/..", + Hash: "QmFooBazBar2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7", } func main() {