Skip to content

Commit

Permalink
Fix domain main (closes #1, closes #2)
Browse files Browse the repository at this point in the history
  • Loading branch information
k1rill-fedoseev committed Aug 7, 2021
1 parent 3864215 commit 8adfa20
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions handlers/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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)
Expand Down Expand Up @@ -92,7 +92,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)
Expand All @@ -105,7 +105,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)
Expand Down
2 changes: 1 addition & 1 deletion handlers/charts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions handlers/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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)
Expand All @@ -43,7 +43,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{}
Expand Down
3 changes: 2 additions & 1 deletion handlers/pageData.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,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: getUser(w, r),
Expand Down
6 changes: 3 additions & 3 deletions handlers/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,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 {
Expand Down Expand Up @@ -206,7 +206,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))
Expand Down Expand Up @@ -1324,7 +1324,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{
Expand Down
2 changes: 1 addition & 1 deletion services/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,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
Expand Down
2 changes: 1 addition & 1 deletion templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
<a class=navbar-brand href="/">
<i {{ if eq .Active "index"}}style="color: var(--font-color)" {{else}}style="opacity: .7"{{end}}
class="fas fa-satellite-dish mr-2"></i>
<span class="brand-text">beaconcha.in</span>
<span class="brand-text">{{$.SiteDomain}}</span>
</a>

<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
Expand Down
2 changes: 1 addition & 1 deletion templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<div class="container mt-2">
<div class="row my-3">
<div class="col-lg-6 col-sm-8 col-xl-5 mx-auto">
<h1 class="h2">Sign in to <i>beaconcha.in</i></h1>
<h1 class="h2">Sign in to <i>{{$.SiteDomain}}</i></h1>
<p>Manage and track the progress of your validator.</p>
{{if .Flashes}}
{{range $i, $flash := .Flashes}}
Expand Down
2 changes: 1 addition & 1 deletion templates/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<div class="container">
<div class="row my-3">
<div class="col-lg-6 col-sm-8 col-xl-5 mx-auto">
<h1 class="h2">Sign up to <i>beaconcha.in</i></h1>
<h1 class="h2">Sign up to <i>{{$.SiteDomain}}</i></h1>
<p>Manage and track the progress of your validator.</p>
{{if .Flashes}}
{{range $i, $flash := .Flashes}}
Expand Down
1 change: 1 addition & 0 deletions types/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type PageData struct {
Active string
HeaderAd bool
Meta *Meta
SiteDomain string
ShowSyncingMessage bool
User *User
Data interface{}
Expand Down

0 comments on commit 8adfa20

Please sign in to comment.