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 Jan 26, 2022
1 parent dc25ba8 commit d5f23d6
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 @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
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 @@ -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)
Expand All @@ -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{}
Expand Down
3 changes: 2 additions & 1 deletion handlers/pageData.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions handlers/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion services/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
<div class="container">
<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" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
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 d5f23d6

Please sign in to comment.