From ce0dceac341c878d42d27cc78f71cbe4bbb54237 Mon Sep 17 00:00:00 2001 From: Kevin Neaton Date: Tue, 14 Jul 2020 23:25:48 -0400 Subject: [PATCH] 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 342809e..c4da35a 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 208b2ad..625456e 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, -- GitLab