Commit 8c03fc45 authored by Kevin Neaton's avatar Kevin Neaton

Make path components into links

parent beb1120f
...@@ -55,7 +55,14 @@ ...@@ -55,7 +55,14 @@
<div id="content"> <div id="content">
<div id="content-header" class="d-flex flex-wrap"> <div id="content-header" class="d-flex flex-wrap">
<div> <div>
<strong>Index of {{ .Path }}</strong> <strong>
Index of
{{ range .Breadcrumbs -}}
/{{ if .Path }}<a href="{{ .Path | urlEscape }}">{{ .Name }}</a>{{ else }}{{ .Name }}{{ end }}
{{- else }}
{{ .Path }}
{{ end }}
</strong>
{{ if .Hash }} {{ if .Hash }}
<div class="ipfs-hash"> <div class="ipfs-hash">
{{ .Hash }} {{ .Hash }}
......
...@@ -15,6 +15,7 @@ type listingTemplateData struct { ...@@ -15,6 +15,7 @@ type listingTemplateData struct {
Listing []directoryItem Listing []directoryItem
Size string Size string
Path string Path string
Breadcrumbs []breadcrumb
BackLink string BackLink string
Hash string Hash string
} }
...@@ -25,20 +26,41 @@ type directoryItem struct { ...@@ -25,20 +26,41 @@ type directoryItem struct {
Path string Path string
} }
type breadcrumb struct {
Name string
Path string
}
var testPath = "/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7/a/b/c"
var testData = listingTemplateData{ var testData = listingTemplateData{
Listing: []directoryItem{{ Listing: []directoryItem{{
Size: "25 MiB", Size: "25 MiB",
Name: "short-film.mov", Name: "short-film.mov",
Path: "short-film.mov", Path: testPath + "/short-film.mov",
}, { }, {
Size: "1 KiB", Size: "1 KiB",
Name: "this-piece-of-papers-got-47-words-37-sentences-58-words-we-wanna-know.txt", 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", Path: testPath + "/this-piece-of-papers-got-47-words-37-sentences-58-words-we-wanna-know.txt",
}}, }},
Size: "25 MiB", Size: "25 MiB",
Path: "/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm", Path: testPath,
BackLink: "/..", Breadcrumbs: []breadcrumb{{
Hash: "QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm", Name: "ipfs",
}, {
Name: "QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7",
Path: testPath + "/../../..",
}, {
Name: "a",
Path: testPath + "/../..",
}, {
Name: "b",
Path: testPath + "/..",
}, {
Name: "c",
Path: testPath,
}},
BackLink: testPath + "/..",
Hash: "QmFooBazBar2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7",
} }
func main() { func main() {
......
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