@cryptotaxi247 / kubo / commits / 02aa6b471

gateway: bring back dir-index-html assets

License: MIT Signed-off-by: Lars Gierth <larsg@systemli.org>

Lars Gierth committed Sep 1, 2016 at 02:59 UTC 02aa6b4714a63e424212ce2e29d0f4db03fb3b33
3 files changed +17 -6
assets/assets.go
+8 -3
@@ -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
2 //go:generate gofmt -w bindata.go
3
4 package assets
@@ -6,12 +6,16 @@ package assets
6 import (
7 "bytes"
8 "fmt"
9 + "os"
10 "path/filepath"
11
12 "github.com/ipfs/go-ipfs/core"
13 "github.com/ipfs/go-ipfs/core/coreunix"
14 uio "github.com/ipfs/go-ipfs/unixfs/io"
15 cid "gx/ipfs/QmXfiyr2RWEXpVDdaYnD2HNiBk6UBddsvEP4RPfXb6nGqY/go-cid"
16 +
17 + // this import keeps gx from thinking the dep isn't used
18 + _ "gx/ipfs/QmQfeKxQtBN721pekQh6Jq24adFUjnU65YdY3GNczfuG2T/dir-index-html"
19 )
20
21 // initDocPaths lists the paths for the docs we want to seed during --init
@@ -29,9 +33,10 @@ func SeedInitDocs(nd *core.IpfsNode) (*cid.Cid, error) {
33 return addAssetList(nd, initDocPaths)
34 }
35
36 +var initDirPath = filepath.Join(os.Getenv("GOPATH"), "gx", "ipfs", "QmQfeKxQtBN721pekQh6Jq24adFUjnU65YdY3GNczfuG2T", "dir-index-html")
37 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"),
38 + filepath.Join(initDirPath, "knownIcons.txt"),
39 + filepath.Join(initDirPath, "dir-index.html"),
40 }
41
42 func SeedInitDirIndex(nd *core.IpfsNode) (*cid.Cid, error) {
core/corehttp/gateway_indexPage.go
+2 -3
@@ -25,8 +25,7 @@ type directoryItem struct {
25 var listingTemplate *template.Template
26
27 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")
29 if err != nil {
30 panic(err)
31 }
@@ -53,7 +52,7 @@ func init() {
52 }
53
54 // Directory listing template
56 - dirIndexBytes, err := assets.Asset(assetPath + "dir-index.html")
55 + dirIndexBytes, err := assets.Asset("dir-index-html/dir-index.html")
56 if err != nil {
57 panic(err)
58 }
package.json
+7
@@ -281,6 +281,13 @@
281 "hash": "QmRcAVqrbY5wryx7hfNLtiUZbCcstzaJL7YJFBboitcqWF",
282 "name": "go-ipld-cbor",
283 "version": "0.3.0"
284 + },
285 + {
286 + "author": "lgierth",
287 + "hash": "QmQfeKxQtBN721pekQh6Jq24adFUjnU65YdY3GNczfuG2T",
288 + "name": "dir-index-html",
289 + "version": "1.0.3",
290 + "comment": "This one needs code updates in assets/assets.go too."
291 }
292 ],
293 "gxVersion": "0.4.0",