diff --git a/dir-index.html b/dir-index.html index 945c1a1dc0a7809fd6e48d6386612d837e076454..7c3b65907b417bca54ab7d1a55239d0daed8e65e 100644 --- a/dir-index.html +++ b/dir-index.html @@ -1,4 +1,5 @@ +{{ $root := . }} @@ -18,7 +19,7 @@ {{ .Path }} @@ -39,36 +40,60 @@
-
- Index of {{ .Path }} +
+
+ + Index of + {{ range .Breadcrumbs -}} + /{{ if .Path }}{{ .Name }}{{ else }}{{ .Name }}{{ end }} + {{- else }} + {{ .Path }} + {{ end }} + {{ if .Hash }}
{{ .Hash }}
{{ end }}
- - - - - - - {{ range .Listing }} - - - - - + {{ if .Size }} +
+  {{ .Size }} +
{{ end }} -
-
 
-
- .. -
-
 
-
- {{ .Name }} - {{ .Size }}
+
+
+ + + + + + + + {{ range .Listing }} + + + + + + + {{ end }} +
+
 
+
+ .. +
+
 
+
+ {{ .Name }} + + {{ if .Hash }} + + {{ .ShortHash }} + + {{ end }} + {{ .Size }}
+
diff --git a/test/main.go b/test/main.go index 22ea89503c6d7d20f7b7d6e3ad54313770cc6ad3..fc3208335c8492edec1b4f279943d4fca9f4b1b6 100644 --- a/test/main.go +++ b/test/main.go @@ -12,31 +12,63 @@ const templateFile = "../dir-index.html" // Copied from go-ipfs/core/corehttp/gateway_indexPage.go type listingTemplateData struct { - Listing []directoryItem - Path string - BackLink string - Hash string + GatewayURL string + Listing []directoryItem + Size string + Path string + Breadcrumbs []breadcrumb + BackLink string + Hash string } type directoryItem struct { - Size string + Size string + Name string + Path string + Hash string + ShortHash string +} + +type breadcrumb struct { Name string Path string } +var testPath = "/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7/a/b/c" var testData = listingTemplateData{ + GatewayURL: "//localhost:3000", Listing: []directoryItem{{ - Size: "25 MiB", - Name: "short-film.mov", - Path: "short-film.mov", + Size: "25 MiB", + Name: "short-film.mov", + Path: testPath + "/short-film.mov", + Hash: "QmQuxBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7", + ShortHash: "QmQu\u2026xDu7", + }, { + Size: "1 KiB", + Name: "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", + Hash: "QmquXbaRQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7", + ShortHash: "Qmqu\u2026xDu7", + }}, + Size: "25 MiB", + Path: testPath, + Breadcrumbs: []breadcrumb{{ + Name: "ipfs", + }, { + Name: "QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7", + Path: testPath + "/../../..", + }, { + Name: "a", + Path: testPath + "/../..", + }, { + Name: "b", + Path: testPath + "/..", }, { - 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", + Name: "c", + Path: testPath, }}, - Path: "/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm", - BackLink: "/..", - Hash: "QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm", + BackLink: testPath + "/..", + Hash: "QmFooBazBar2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7", } func main() {