From beb1120fde2f33fef0e2967f1cba9ab7526b2fcb Mon Sep 17 00:00:00 2001 From: Kevin Neaton Date: Wed, 1 Jul 2020 21:50:27 -0400 Subject: [PATCH] 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 945c1a1..2e5d507 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 22ea895..e4a4153 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", -- GitLab