Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
configs/environ.overrides.json
configs/environ.override.json

vendor/
data*/
profile/
Expand All @@ -19,4 +22,4 @@ __debug*
.gocache/
__pycache__/
.dev/
.spec/
.spec/
1 change: 0 additions & 1 deletion api/embed/about

This file was deleted.

1 change: 0 additions & 1 deletion api/embed/tos_link

This file was deleted.

33 changes: 7 additions & 26 deletions api/text.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
package api

import (
"embed"
"fmt"
"net/url"
"strings"
)
import "strings"

//go:embed embed/*
var embedded embed.FS

// Text contains static overridable texts used in explorer
// Text contains static overridable texts used in explorer and API.
var Text struct {
BlockbookAbout, TOSLink string
}

func init() {
if about, err := embedded.ReadFile("embed/about"); err == nil {
Text.BlockbookAbout = strings.TrimSpace(string(about))
} else {
panic(err)
}
if tosLinkB, err := embedded.ReadFile("embed/tos_link"); err == nil {
tosLink := strings.TrimSpace(string(tosLinkB))
if _, err := url.ParseRequestURI(tosLink); err == nil {
Text.TOSLink = tosLink
} else {
panic(fmt.Sprint("tos_link is not valid URL:", err.Error()))
}
} else {
panic(err)
}
// SetBranding sets BlockbookAbout and TOSLink from branding loaded at process startup.
// Callers must pass values already validated by common.LoadBranding (about non-empty, tos_link a valid absolute URL).
func SetBranding(about, tosLink string) {
Text.BlockbookAbout = strings.TrimSpace(about)
Text.TOSLink = strings.TrimSpace(tosLink)
}
12 changes: 11 additions & 1 deletion blockbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
_ "net/http/pprof"
"os"
"path/filepath"
"os/signal"
"runtime/debug"
"strconv"
Expand Down Expand Up @@ -108,6 +109,7 @@ var (
callbacksOnNewTx []bchain.OnNewTxFunc
callbacksOnNewFiatRatesTicker []fiat.OnNewFiatRatesTicker
chanOsSignal chan os.Signal
appBranding *common.Branding
)

func init() {
Expand Down Expand Up @@ -176,6 +178,14 @@ func mainWithExitCode() int {
return exitCodeFatal
}

configsDir := filepath.Clean(filepath.Join(filepath.Dir(*configFile), ".."))
appBranding, err = common.LoadBranding(configsDir)
if err != nil {
glog.Error("branding: ", err)
return exitCodeFatal
}
api.SetBranding(appBranding.About, appBranding.TOSLink)

metrics, err = common.GetMetrics(config.CoinName)
if err != nil {
glog.Error("metrics: ", err)
Expand Down Expand Up @@ -442,7 +452,7 @@ func startInternalServer() (*server.InternalServer, error) {

func startPublicServer() (*server.PublicServer, error) {
// start public server in limited functionality, extend it after sync is finished by calling ConnectFullPublicInterface
publicServer, err := server.NewPublicServer(*publicBinding, *certFiles, index, chain, mempool, txCache, *explorerURL, metrics, internalState, fiatRates, *debugMode)
publicServer, err := server.NewPublicServer(*publicBinding, *certFiles, index, chain, mempool, txCache, *explorerURL, metrics, internalState, fiatRates, *debugMode, appBranding)
if err != nil {
return nil, err
}
Expand Down
Loading