From d5f23d6533c35f7b27fd3c9bd7c585f15f5e262b Mon Sep 17 00:00:00 2001 From: Kirill Fedoseev Date: Sat, 7 Aug 2021 18:50:54 +0400 Subject: [PATCH] Fix domain main (closes #1, closes #2) --- handlers/block.go | 6 +++--- handlers/charts.go | 2 +- handlers/epoch.go | 4 ++-- handlers/pageData.go | 3 ++- handlers/validator.go | 6 +++--- services/notifications.go | 2 +- templates/layout.html | 2 +- templates/login.html | 2 +- templates/register.html | 2 +- types/templates.go | 1 + 10 files changed, 16 insertions(+), 14 deletions(-) diff --git a/handlers/block.go b/handlers/block.go index 019662ef43..e3648a6a80 100644 --- a/handlers/block.go +++ b/handlers/block.go @@ -50,7 +50,7 @@ func Block(w http.ResponseWriter, r *http.Request) { data := InitPageData(w, r, "blocks", "/blocks", "") if err != nil { - data.Meta.Title = fmt.Sprintf("%v - Slot %v - beaconcha.in - %v", utils.Config.Frontend.SiteName, slotOrHash, time.Now().Year()) + data.Meta.Title = fmt.Sprintf("%v - Slot %v - %v - %v", utils.Config.Frontend.SiteName, slotOrHash, utils.Config.Frontend.SiteDomain, time.Now().Year()) data.Meta.Path = "/block/" + slotOrHash logger.Errorf("error retrieving block data: %v", err) err = blockNotFoundTemplate.ExecuteTemplate(w, "layout", data) @@ -96,7 +96,7 @@ func Block(w http.ResponseWriter, r *http.Request) { blockSlot, blockRootHash) if err != nil { - data.Meta.Title = fmt.Sprintf("%v - Slot %v - beaconcha.in - %v", utils.Config.Frontend.SiteName, slotOrHash, time.Now().Year()) + data.Meta.Title = fmt.Sprintf("%v - Slot %v - %v - %v", utils.Config.Frontend.SiteName, slotOrHash, utils.Config.Frontend.SiteDomain, time.Now().Year()) data.Meta.Path = "/block/" + slotOrHash logger.Errorf("error retrieving block data: %v", err) err = blockNotFoundTemplate.ExecuteTemplate(w, "layout", data) @@ -109,7 +109,7 @@ func Block(w http.ResponseWriter, r *http.Request) { return } - data.Meta.Title = fmt.Sprintf("%v - Slot %v - beaconcha.in - %v", utils.Config.Frontend.SiteName, blockPageData.Slot, time.Now().Year()) + data.Meta.Title = fmt.Sprintf("%v - Slot %v - %v - %v", utils.Config.Frontend.SiteName, blockPageData.Slot, utils.Config.Frontend.SiteDomain, time.Now().Year()) data.Meta.Path = fmt.Sprintf("/block/%v", blockPageData.Slot) blockPageData.Ts = utils.SlotToTime(blockPageData.Slot) diff --git a/handlers/charts.go b/handlers/charts.go index bca6f9d6f6..04c8b4af9f 100644 --- a/handlers/charts.go +++ b/handlers/charts.go @@ -89,7 +89,7 @@ func GenericChart(w http.ResponseWriter, r *http.Request) { return } - data.Meta.Title = fmt.Sprintf("%v - %v Chart - beaconcha.in - %v", chartData.Title, utils.Config.Frontend.SiteName, time.Now().Year()) + data.Meta.Title = fmt.Sprintf("%v - %v Chart - %v - %v", chartData.Title, utils.Config.Frontend.SiteName, utils.Config.Frontend.SiteDomain, time.Now().Year()) data.Meta.Path = "/charts/" + chartVar data.Data = chartData diff --git a/handlers/epoch.go b/handlers/epoch.go index d97c743434..a61f0b0593 100644 --- a/handlers/epoch.go +++ b/handlers/epoch.go @@ -31,7 +31,7 @@ func Epoch(w http.ResponseWriter, r *http.Request) { epoch, err := strconv.ParseUint(epochString, 10, 64) if err != nil { - data.Meta.Title = fmt.Sprintf("%v - Epoch %v - beaconcha.in - %v", utils.Config.Frontend.SiteName, epochString, time.Now().Year()) + data.Meta.Title = fmt.Sprintf("%v - Epoch %v - %v - %v", utils.Config.Frontend.SiteName, epochString, utils.Config.Frontend.SiteDomain, time.Now().Year()) data.Meta.Path = "/epoch/" + epochString logger.Errorf("error parsing epoch index %v: %v", epochString, err) err = epochNotFoundTemplate.ExecuteTemplate(w, "layout", data) @@ -44,7 +44,7 @@ func Epoch(w http.ResponseWriter, r *http.Request) { return } - data.Meta.Title = fmt.Sprintf("%v - Epoch %v - beaconcha.in - %v", utils.Config.Frontend.SiteName, epoch, time.Now().Year()) + data.Meta.Title = fmt.Sprintf("%v - Epoch %v - %v - %v", utils.Config.Frontend.SiteName, epoch, utils.Config.Frontend.SiteDomain, time.Now().Year()) data.Meta.Path = fmt.Sprintf("/epoch/%v", epoch) epochPageData := types.EpochPageData{} diff --git a/handlers/pageData.go b/handlers/pageData.go index a4873b6335..523e360fbf 100644 --- a/handlers/pageData.go +++ b/handlers/pageData.go @@ -21,12 +21,13 @@ func InitPageData(w http.ResponseWriter, r *http.Request, active, path, title st data := &types.PageData{ HeaderAd: false, Meta: &types.Meta{ - Title: fmt.Sprintf("%v - %v - beaconcha.in - %v", utils.Config.Frontend.SiteName, title, time.Now().Year()), + Title: fmt.Sprintf("%v - %v - %v - %v", utils.Config.Frontend.SiteName, title, utils.Config.Frontend.SiteDomain, time.Now().Year()), Description: "beaconcha.in makes the Ethereum 2.0. beacon chain accessible to non-technical end users", Path: path, GATag: utils.Config.Frontend.GATag, NoTrack: false, }, + SiteDomain: utils.Config.Frontend.SiteDomain, Active: active, Data: &types.Empty{}, User: user, diff --git a/handlers/validator.go b/handlers/validator.go index b544e24297..0d0c8e89e4 100644 --- a/handlers/validator.go +++ b/handlers/validator.go @@ -108,7 +108,7 @@ func Validator(w http.ResponseWriter, r *http.Request) { } validatorPageData.DepositsCount = uint64(len(deposits.Eth1Deposits)) if err != nil || len(deposits.Eth1Deposits) == 0 { - data.Meta.Title = fmt.Sprintf("%v - Validator %x - beaconcha.in - %v", utils.Config.Frontend.SiteName, pubKey, time.Now().Year()) + data.Meta.Title = fmt.Sprintf("%v - Validator %x - %v - %v", utils.Config.Frontend.SiteName, pubKey, utils.Config.Frontend.SiteDomain, time.Now().Year()) data.Meta.Path = fmt.Sprintf("/validator/%v", index) err := validatorNotFoundTemplate.ExecuteTemplate(w, "layout", data) if err != nil { @@ -207,7 +207,7 @@ func Validator(w http.ResponseWriter, r *http.Request) { // GetAvgOptimalInclusionDistance(index) - data.Meta.Title = fmt.Sprintf("%v - Validator %v - beaconcha.in - %v", utils.Config.Frontend.SiteName, index, time.Now().Year()) + data.Meta.Title = fmt.Sprintf("%v - Validator %v - %v - %v", utils.Config.Frontend.SiteName, index, utils.Config.Frontend.SiteDomain, time.Now().Year()) data.Meta.Path = fmt.Sprintf("/validator/%v", index) // logger.Infof("retrieving data, elapsed: %v", time.Since(start)) @@ -1399,7 +1399,7 @@ func ValidatorStatsTable(w http.ResponseWriter, r *http.Request) { } } - data.Meta.Title = fmt.Sprintf("%v - Daily Validator Statistics %v - beaconcha.in - %v", utils.Config.Frontend.SiteName, index, time.Now().Year()) + data.Meta.Title = fmt.Sprintf("%v - Daily Validator Statistics %v - %v - %v", utils.Config.Frontend.SiteName, index, utils.Config.Frontend.SiteDomain, time.Now().Year()) data.Meta.Path = fmt.Sprintf("/validator/%v/stats", index) validatorStatsTablePageData := &types.ValidatorStatsTablePageData{ diff --git a/services/notifications.go b/services/notifications.go index 33d9951234..7a9534eb57 100644 --- a/services/notifications.go +++ b/services/notifications.go @@ -895,7 +895,7 @@ func (n *ethClientNotification) GetInfo(includeUrl bool) string { case "Lighthouse": url = "https://github.com/sigp/lighthouse/releases" default: - url = "https://beaconcha.in/ethClients" + url = fmt.Sprintf("https://%s/ethClients", utils.Config.Frontend.SiteDomain) } return generalPart + " " + url diff --git a/templates/layout.html b/templates/layout.html index 66f57c0cf0..4976743524 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -312,7 +312,7 @@
- beaconcha.in + {{$.SiteDomain}}