diff --git a/Gopkg.lock b/Gopkg.lock index 24370914..826be382 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -49,6 +49,12 @@ revision = "259ab82a6cad3992b4e21ff5cac294ccb06474bc" version = "v1.7.0" +[[projects]] + name = "github.com/gobuffalo/packr" + packages = ["."] + revision = "5a2cbb54c4e7d482e3f518c56f1f86f133d5204f" + version = "v1.13.7" + [[projects]] name = "github.com/gogo/protobuf" packages = ["proto"] @@ -121,6 +127,12 @@ packages = ["."] revision = "5b443b6471cea4b4f9f85025530c04c93233f76a" +[[projects]] + name = "github.com/pkg/errors" + packages = ["."] + revision = "645ef00459ed84a119197bfb8d8205042c6df63d" + version = "v0.8.0" + [[projects]] name = "github.com/prometheus/client_golang" packages = ["prometheus","prometheus/promhttp"] @@ -196,6 +208,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "37517a6a6dbd6e924bf6761b562697a069e952f72f4d3ef984faf72738e91670" + inputs-digest = "3a7b863bec3806ba9460f3961e2d6e8ff4b77e5f66d196b1f79bd37fa6bf8d82" solver-name = "gps-cdcl" solver-version = 1 diff --git a/api/text.go b/api/text.go new file mode 100644 index 00000000..80fc48b5 --- /dev/null +++ b/api/text.go @@ -0,0 +1,31 @@ +package api + +import ( + "fmt" + "net/url" + "strings" + + "github.com/gobuffalo/packr" +) + +var Text struct { + BlockbookAbout, TOSLink string +} + +func init() { + box := packr.NewBox("../static/text") + if about, err := box.MustString("about"); err == nil { + Text.BlockbookAbout = strings.TrimSpace(about) + } else { + panic(err) + } + if tosLink, err := box.MustString("tos_link"); err == nil { + if _, err := url.ParseRequestURI(tosLink); err == nil { + Text.TOSLink = strings.TrimSpace(tosLink) + } else { + panic(fmt.Sprint("tos_link is not valid URL:", err.Error())) + } + } else { + panic(err) + } +} diff --git a/api/types.go b/api/types.go index 98f52bfb..5ef4efa5 100644 --- a/api/types.go +++ b/api/types.go @@ -8,8 +8,6 @@ import ( "time" ) -const BlockbookAbout = "Blockbook - blockchain indexer for TREZOR wallet https://trezor.io/. Do not use for any other purpose." - type ApiError struct { Text string Public bool diff --git a/api/worker.go b/api/worker.go index a33cbc50..a12fd90d 100644 --- a/api/worker.go +++ b/api/worker.go @@ -585,7 +585,7 @@ func (w *Worker) GetSystemInfo(internal bool) (*SystemInfo, error) { DbSize: w.db.DatabaseSizeOnDisk(), DbSizeFromColumns: dbs, DbColumns: dbc, - About: BlockbookAbout, + About: Text.BlockbookAbout, } glog.Info("GetSystemInfo finished in ", time.Since(start)) return &SystemInfo{bi, ci}, nil diff --git a/build/docker/bin/Dockerfile b/build/docker/bin/Dockerfile index 0b02037e..a3e4c63e 100644 --- a/build/docker/bin/Dockerfile +++ b/build/docker/bin/Dockerfile @@ -32,8 +32,11 @@ RUN cd /opt/rocksdb && CFLAGS=-fPIC CXXFLAGS=-fPIC make -j 4 release RUN strip /opt/rocksdb/ldb /opt/rocksdb/sst_dump && \ cp /opt/rocksdb/ldb /opt/rocksdb/sst_dump /build +# install build tools RUN go get github.com/golang/dep/cmd/dep +RUN go get github.com/gobuffalo/packr/... +# download pre-loaded depencencies RUN \ cleanup() { rm -rf $GOPATH/src/blockbook; } && \ trap cleanup EXIT && \ diff --git a/build/docker/bin/Makefile b/build/docker/bin/Makefile index 05aafcae..1ca70395 100644 --- a/build/docker/bin/Makefile +++ b/build/docker/bin/Makefile @@ -11,12 +11,12 @@ export BLOCKBOOK_SRC all: build tools -build: prepare-sources +build: prepare-sources generate-data cd $(BLOCKBOOK_SRC) && go build -o $(CURDIR)/blockbook -ldflags="-s -w $(LDFLAGS)" $(ARGS) cp $(CURDIR)/blockbook /out/blockbook chown $(PACKAGER) /out/blockbook -build-debug: prepare-sources +build-debug: prepare-sources generate-data cd $(BLOCKBOOK_SRC) && go build -o $(CURDIR)/blockbook -ldflags="$(LDFLAGS)" $(ARGS) cp $(CURDIR)/blockbook /out/blockbook chown $(PACKAGER) /out/blockbook @@ -25,13 +25,13 @@ tools: cp $(CURDIR)/{ldb,sst_dump} /out chown $(PACKAGER) /out/{ldb,sst_dump} -test: prepare-sources +test: prepare-sources generate-data cd $(BLOCKBOOK_SRC) && go test -tags unittest `go list ./... | grep -vP '^blockbook/(contrib|tests)'` $(ARGS) -test-integration: prepare-sources +test-integration: prepare-sources generate-data cd $(BLOCKBOOK_SRC) && go test -tags integration `go list blockbook/tests/...` $(ARGS) -test-all: prepare-sources +test-all: prepare-sources generate-data cd $(BLOCKBOOK_SRC) && go test -tags 'unittest integration' `go list ./... | grep -v '^blockbook/contrib'` $(ARGS) prepare-sources: @@ -46,3 +46,6 @@ prepare-vendor: else \ echo "Update of vendor not demanded, keeping version from src" ; \ fi + +generate-data: + cd $(BLOCKBOOK_SRC) && packr clean && packr diff --git a/server/public.go b/server/public.go index 48ee1e79..18642b86 100644 --- a/server/public.go +++ b/server/public.go @@ -230,6 +230,7 @@ func (s *PublicServer) newTemplateData() *TemplateData { CoinShortcut: s.is.CoinShortcut, CoinLabel: s.is.CoinLabel, InternalExplorer: s.internalExplorer && !s.is.InitialSync, + TOSLink: api.Text.TOSLink, } } @@ -325,6 +326,7 @@ type TemplateData struct { PrevPage int NextPage int PagingRange []int + TOSLink string } func parseTemplates() []*template.Template { diff --git a/server/socketio.go b/server/socketio.go index 67ce0a90..0e988ec1 100644 --- a/server/socketio.go +++ b/server/socketio.go @@ -592,7 +592,7 @@ func (s *SocketIoServer) getInfo() (res resultGetInfo, err error) { res.Result.Network = s.chain.GetNetworkName() res.Result.Subversion = s.chain.GetSubversion() res.Result.CoinName = s.chain.GetCoinName() - res.Result.About = api.BlockbookAbout + res.Result.About = api.Text.BlockbookAbout return } diff --git a/static/templates/base.html b/static/templates/base.html index 9f5103c4..5c9e9d2c 100644 --- a/static/templates/base.html +++ b/static/templates/base.html @@ -73,7 +73,7 @@ © 2018 SatoshiLabs