- 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() {