From beb1120fde2f33fef0e2967f1cba9ab7526b2fcb Mon Sep 17 00:00:00 2001 From: Kevin Neaton Date: Wed, 1 Jul 2020 21:50:27 -0400 Subject: [PATCH 1/8] Display viewed directory's size --- dir-index.html | 65 +++++++++++++++++++++++++++++++++----------------- test/main.go | 2 ++ 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/dir-index.html b/dir-index.html index 945c1a1dc..2e5d507d3 100644 --- a/dir-index.html +++ b/dir-index.html @@ -20,6 +20,20 @@ + {{ .Path }} @@ -39,7 +53,8 @@
-
+
+
Index of {{ .Path }} {{ if .Hash }}
@@ -47,28 +62,34 @@
{{ end }}
- - - - - - - {{ range .Listing }} - - - - - + {{ if .Size }} +
+  {{ .Size }} +
{{ end }} -
-
 
-
- .. -
-
 
-
- {{ .Name }} - {{ .Size }}
+
+ + + + + + + {{ range .Listing }} + + + + + + {{ end }} +
+
 
+
+ .. +
+
 
+
+ {{ .Name }} + {{ .Size }}
diff --git a/test/main.go b/test/main.go index 22ea89503..e4a4153f0 100644 --- a/test/main.go +++ b/test/main.go @@ -13,6 +13,7 @@ const templateFile = "../dir-index.html" // Copied from go-ipfs/core/corehttp/gateway_indexPage.go type listingTemplateData struct { Listing []directoryItem + Size string Path string BackLink string Hash string @@ -34,6 +35,7 @@ var testData = listingTemplateData{ 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", }}, + Size: "25 MiB", Path: "/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm", BackLink: "/..", Hash: "QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm", From 8c03fc4579b8a65b019629eab08573c10b299285 Mon Sep 17 00:00:00 2001 From: Kevin Neaton Date: Thu, 2 Jul 2020 20:44:26 -0400 Subject: [PATCH 2/8] Make path components into links --- dir-index.html | 9 ++++++++- test/main.go | 32 +++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/dir-index.html b/dir-index.html index 2e5d507d3..7f2ce1176 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 e4a4153f0..6c851aeb5 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() { From 51e423e4a6f82507d43dbbc9f8f2f322dea912ed Mon Sep 17 00:00:00 2001 From: Kevin Neaton Date: Fri, 3 Jul 2020 00:53:44 -0400 Subject: [PATCH 3/8] Add CID column --- dir-index.html | 22 ++++++++++++++++++++++ test/main.go | 3 +++ 2 files changed, 25 insertions(+) diff --git a/dir-index.html b/dir-index.html index 7f2ce1176..75ec45020 100644 --- a/dir-index.html +++ b/dir-index.html @@ -33,6 +33,17 @@ .ml-auto { margin-left: auto; } + .text-truncate { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + .table-responsive { + display: block; + width: 100%; + overflow-x: auto; + -webkit-overflow-scrolling: touch; + } {{ .Path }} @@ -75,6 +86,7 @@
{{ end }}
+
+ {{ range .Listing }} @@ -93,10 +106,19 @@ + {{ end }}
@@ -84,6 +96,7 @@ ..
{{ .Name }} + {{ if .Hash }} + + {{ slice .Hash 0 40 }} + {{ slice .Hash 40 }} + + {{ end }} + {{ .Size }}
+
diff --git a/test/main.go b/test/main.go index 6c851aeb5..208b2ad54 100644 --- a/test/main.go +++ b/test/main.go @@ -24,6 +24,7 @@ type directoryItem struct { Size string Name string Path string + Hash string } type breadcrumb struct { @@ -37,10 +38,12 @@ var testData = listingTemplateData{ Size: "25 MiB", Name: "short-film.mov", Path: testPath + "/short-film.mov", + Hash: "QmQuxBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7", }, { 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", }}, Size: "25 MiB", Path: testPath, From 84cf3eb263838e0a7596885f817f9f1755573063 Mon Sep 17 00:00:00 2001 From: Kevin Neaton Date: Tue, 7 Jul 2020 08:32:46 -0400 Subject: [PATCH 4/8] minify css additions --- dir-index.html | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/dir-index.html b/dir-index.html index 75ec45020..1fc14a88d 100644 --- a/dir-index.html +++ b/dir-index.html @@ -18,32 +18,7 @@ - {{ .Path }} From c5d042ac5fd9c15631f95c6656e686a65f9f65ba Mon Sep 17 00:00:00 2001 From: Kevin Neaton Date: Tue, 7 Jul 2020 09:18:22 -0400 Subject: [PATCH 5/8] Fix type-icon size at narrow viewport widths The presence of additional content in the table was causing the width of the type-icon column to be reduced. Applying the width to the column and it's contents prevents this from happening. --- dir-index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dir-index.html b/dir-index.html index 1fc14a88d..342809e11 100644 --- a/dir-index.html +++ b/dir-index.html @@ -18,7 +18,7 @@ {{ .Path }} From ce0dceac341c878d42d27cc78f71cbe4bbb54237 Mon Sep 17 00:00:00 2001 From: Kevin Neaton Date: Tue, 14 Jul 2020 23:25:48 -0400 Subject: [PATCH 6/8] Use short hash for uniform CID presentation of directory items --- dir-index.html | 9 ++++----- test/main.go | 3 +++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dir-index.html b/dir-index.html index 342809e11..c4da35a76 100644 --- a/dir-index.html +++ b/dir-index.html @@ -18,7 +18,7 @@ {{ .Path }} @@ -81,11 +81,10 @@ {{ .Name }} - + {{ if .Hash }} - - {{ slice .Hash 0 40 }} - {{ slice .Hash 40 }} + + {{ .ShortHash }} {{ end }} diff --git a/test/main.go b/test/main.go index 208b2ad54..625456ed9 100644 --- a/test/main.go +++ b/test/main.go @@ -25,6 +25,7 @@ type directoryItem struct { Name string Path string Hash string + ShortHash string } type breadcrumb struct { @@ -39,11 +40,13 @@ var testData = listingTemplateData{ 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, From deab971dd03db6cf9609d312c6fdb414d58f4c69 Mon Sep 17 00:00:00 2001 From: Kevin Neaton Date: Fri, 17 Jul 2020 22:42:15 -0400 Subject: [PATCH 7/8] Use gateway URL when linking to another CID root This is necessary to support subdomain resolution. E.g. {cid}.ipfs.localhost --- dir-index.html | 5 +++-- test/main.go | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dir-index.html b/dir-index.html index c4da35a76..7c3b65907 100644 --- a/dir-index.html +++ b/dir-index.html @@ -1,4 +1,5 @@ +{{ $root := . }} @@ -44,7 +45,7 @@ Index of {{ range .Breadcrumbs -}} - /{{ if .Path }}{{ .Name }}{{ else }}{{ .Name }}{{ end }} + /{{ if .Path }}{{ .Name }}{{ else }}{{ .Name }}{{ end }} {{- else }} {{ .Path }} {{ end }} @@ -83,7 +84,7 @@ {{ if .Hash }} - + {{ .ShortHash }} {{ end }} diff --git a/test/main.go b/test/main.go index 625456ed9..3c73cf49b 100644 --- a/test/main.go +++ b/test/main.go @@ -12,6 +12,7 @@ const templateFile = "../dir-index.html" // Copied from go-ipfs/core/corehttp/gateway_indexPage.go type listingTemplateData struct { + GatewayURL string Listing []directoryItem Size string Path string @@ -35,6 +36,7 @@ type breadcrumb struct { var testPath = "/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7/a/b/c" var testData = listingTemplateData{ + GatewayURL: "//localhost:3000", Listing: []directoryItem{{ Size: "25 MiB", Name: "short-film.mov", From fbb6b729e93e3e170f37d2221cb4e0002c7fd146 Mon Sep 17 00:00:00 2001 From: Kevin Neaton Date: Fri, 17 Jul 2020 23:59:13 -0400 Subject: [PATCH 8/8] chore: format test/main.go --- test/main.go | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/test/main.go b/test/main.go index 3c73cf49b..fc3208335 100644 --- a/test/main.go +++ b/test/main.go @@ -12,20 +12,20 @@ const templateFile = "../dir-index.html" // Copied from go-ipfs/core/corehttp/gateway_indexPage.go type listingTemplateData struct { - GatewayURL string - Listing []directoryItem - Size string - Path string + GatewayURL string + Listing []directoryItem + Size string + Path string Breadcrumbs []breadcrumb - BackLink string - Hash string + BackLink string + Hash string } type directoryItem struct { - Size string - Name string - Path string - Hash string + Size string + Name string + Path string + Hash string ShortHash string } @@ -38,16 +38,16 @@ var testPath = "/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7/a/b/c" var testData = listingTemplateData{ GatewayURL: "//localhost:3000", Listing: []directoryItem{{ - Size: "25 MiB", - Name: "short-film.mov", - Path: testPath + "/short-film.mov", - Hash: "QmQuxBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7", + 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", + 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",