Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
dir-index-html
Commits
8c03fc45
Commit
8c03fc45
authored
Jul 02, 2020
by
Kevin Neaton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make path components into links
parent
beb1120f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
6 deletions
+35
-6
dir-index.html
dir-index.html
+8
-1
test/main.go
test/main.go
+27
-5
No files found.
dir-index.html
View file @
8c03fc45
...
...
@@ -55,7 +55,14 @@
<div
id=
"content"
>
<div
id=
"content-header"
class=
"d-flex flex-wrap"
>
<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 }}
<div
class=
"ipfs-hash"
>
{{ .Hash }}
...
...
test/main.go
View file @
8c03fc45
...
...
@@ -15,6 +15,7 @@ type listingTemplateData struct {
Listing
[]
directoryItem
Size
string
Path
string
Breadcrumbs
[]
breadcrumb
BackLink
string
Hash
string
}
...
...
@@ -25,20 +26,41 @@ type directoryItem struct {
Path
string
}
type
breadcrumb
struct
{
Name
string
Path
string
}
var
testPath
=
"/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7/a/b/c"
var
testData
=
listingTemplateData
{
Listing
:
[]
directoryItem
{{
Size
:
"25 MiB"
,
Name
:
"short-film.mov"
,
Path
:
"
short-film.mov"
,
Path
:
testPath
+
"/
short-film.mov"
,
},
{
Size
:
"1 KiB"
,
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"
,
Path
:
"/ipfs/QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm"
,
BackLink
:
"/.."
,
Hash
:
"QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7RgQm"
,
Path
:
testPath
,
Breadcrumbs
:
[]
breadcrumb
{{
Name
:
"ipfs"
,
},
{
Name
:
"QmFooBarQXB2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7"
,
Path
:
testPath
+
"/../../.."
,
},
{
Name
:
"a"
,
Path
:
testPath
+
"/../.."
,
},
{
Name
:
"b"
,
Path
:
testPath
+
"/.."
,
},
{
Name
:
"c"
,
Path
:
testPath
,
}},
BackLink
:
testPath
+
"/.."
,
Hash
:
"QmFooBazBar2mzChmMeKY47C43LxUdg1NDJ5MWcKMKxDu7"
,
}
func
main
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment