From deab971dd03db6cf9609d312c6fdb414d58f4c69 Mon Sep 17 00:00:00 2001 From: Kevin Neaton Date: Fri, 17 Jul 2020 22:42:15 -0400 Subject: [PATCH] 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 c4da35a..7c3b659 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 625456e..3c73cf4 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", -- GitLab