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> <!DOCTYPE html>
{{ $root := . }}
<html> <html>
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
...@@ -44,7 +45,7 @@ ...@@ -44,7 +45,7 @@
<strong> <strong>
Index of Index of
{{ range .Breadcrumbs -}} {{ 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 }} {{- else }}
{{ .Path }} {{ .Path }}
{{ end }} {{ end }}
...@@ -83,7 +84,7 @@ ...@@ -83,7 +84,7 @@
</td> </td>
<td class="no-linebreak"> <td class="no-linebreak">
{{ if .Hash }} {{ if .Hash }}
<a href="/ipfs/{{ .Hash | urlEscape }}"> <a href="{{ $root.GatewayURL }}/ipfs/{{ .Hash | urlEscape }}">
{{ .ShortHash }} {{ .ShortHash }}
</a> </a>
{{ end }} {{ end }}
......
...@@ -12,6 +12,7 @@ const templateFile = "../dir-index.html" ...@@ -12,6 +12,7 @@ const templateFile = "../dir-index.html"
// Copied from go-ipfs/core/corehttp/gateway_indexPage.go // Copied from go-ipfs/core/corehttp/gateway_indexPage.go
type listingTemplateData struct { type listingTemplateData struct {
GatewayURL string
Listing []directoryItem Listing []directoryItem
Size string Size string
Path string Path string
...@@ -35,6 +36,7 @@ type breadcrumb struct { ...@@ -35,6 +36,7 @@ type breadcrumb struct {
var testPath = "/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7/a/b/c" var testPath = "/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7/a/b/c"
var testData = listingTemplateData{ var testData = listingTemplateData{
GatewayURL: "//localhost:3000",
Listing: []directoryItem{{ Listing: []directoryItem{{
Size: "25 MiB", Size: "25 MiB",
Name: "short-film.mov", 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