Skip to content

Commit 7715487

Browse files
author
Lars Gierth
committed
gateway: bring back dir-index-html assets
License: MIT Signed-off-by: Lars Gierth <[email protected]>
1 parent 6f69dad commit 7715487

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

assets/assets.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:generate go-bindata -pkg=assets init-doc ../vendor/dir-index-html-v1.0.0
1+
//go:generate go-bindata -pkg=assets -prefix=$GOPATH/src/gx/ipfs/QmQfeKxQtBN721pekQh6Jq24adFUjnU65YdY3GNczfuG2T init-doc $GOPATH/src/gx/ipfs/QmQfeKxQtBN721pekQh6Jq24adFUjnU65YdY3GNczfuG2T/dir-index-html
22
//go:generate gofmt -w bindata.go
33

44
package assets
@@ -12,6 +12,8 @@ import (
1212
"github.com/ipfs/go-ipfs/core"
1313
"github.com/ipfs/go-ipfs/core/coreunix"
1414
uio "github.com/ipfs/go-ipfs/unixfs/io"
15+
16+
_ "gx/ipfs/QmQfeKxQtBN721pekQh6Jq24adFUjnU65YdY3GNczfuG2T/dir-index-html"
1517
)
1618

1719
// initDocPaths lists the paths for the docs we want to seed during --init
@@ -30,8 +32,10 @@ func SeedInitDocs(nd *core.IpfsNode) (*key.Key, error) {
3032
}
3133

3234
var initDirIndex = []string{
33-
filepath.Join("..", "vendor", "dir-index-html-v1.0.0", "knownIcons.txt"),
34-
filepath.Join("..", "vendor", "dir-index-html-v1.0.0", "dir-index.html"),
35+
// assumes path to this file (assets.go) is:
36+
// $GOPATH/src/github.com/ipfs/go-ipfs/assets/assets.go
37+
filepath.Join("..", "..", "..", "..", "gx", "ipfs", "QmQfeKxQtBN721pekQh6Jq24adFUjnU65YdY3GNczfuG2T", "dir-index-html", "knownIcons.txt"),
38+
filepath.Join("..", "..", "..", "..", "gx", "ipfs", "QmQfeKxQtBN721pekQh6Jq24adFUjnU65YdY3GNczfuG2T", "dir-index-html", "dir-index.html"),
3539
}
3640

3741
func SeedInitDirIndex(nd *core.IpfsNode) (*key.Key, error) {

core/corehttp/gateway_indexPage.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ type directoryItem struct {
2525
var listingTemplate *template.Template
2626

2727
func init() {
28-
assetPath := "../vendor/dir-index-html-v1.0.0/"
29-
knownIconsBytes, err := assets.Asset(assetPath + "knownIcons.txt")
28+
knownIconsBytes, err := assets.Asset("dir-index-html/knownIcons.txt")
3029
if err != nil {
3130
panic(err)
3231
}
@@ -53,7 +52,7 @@ func init() {
5352
}
5453

5554
// Directory listing template
56-
dirIndexBytes, err := assets.Asset(assetPath + "dir-index.html")
55+
dirIndexBytes, err := assets.Asset("dir-index-html/dir-index.html")
5756
if err != nil {
5857
panic(err)
5958
}

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@
203203
"hash": "Qmf4ETeAWXuThBfWwonVyFqGFSgTWepUDEr1txcctvpTXS",
204204
"name": "go-libp2p",
205205
"version": "3.4.1"
206+
},
207+
{
208+
"author": "lgierth",
209+
"hash": "QmQfeKxQtBN721pekQh6Jq24adFUjnU65YdY3GNczfuG2T",
210+
"name": "dir-index-html",
211+
"version": "1.0.3",
212+
"comment": "This one needs code updates in assets/assets.go too."
206213
}
207214
],
208215
"gxVersion": "0.4.0",

0 commit comments

Comments
 (0)