Commit deab971d authored by Kevin Neaton's avatar Kevin Neaton

Use gateway URL when linking to another CID root

This is necessary to support subdomain resolution.

E.g. {cid}.ipfs.localhost
parent ce0dceac
<!DOCTYPE html>
{{ $root := . }}
<html>
<head>
<meta charset="utf-8" />
......@@ -44,7 +45,7 @@
<strong>
Index of
{{ range .Breadcrumbs -}}
/{{ if .Path }}<a href="{{ .Path | urlEscape }}">{{ .Name }}</a>{{ else }}{{ .Name }}{{ end }}
/{{ if .Path }}<a href="{{ $root.GatewayURL }}{{ .Path | urlEscape }}">{{ .Name }}</a>{{ else }}{{ .Name }}{{ end }}
{{- else }}
{{ .Path }}
{{ end }}
......@@ -83,7 +84,7 @@
</td>
<td class="no-linebreak">
{{ if .Hash }}
<a href="/ipfs/{{ .Hash | urlEscape }}">
<a href="{{ $root.GatewayURL }}/ipfs/{{ .Hash | urlEscape }}">
{{ .ShortHash }}
</a>
{{ end }}
......
......@@ -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",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment