Skip to content

Commit

Permalink
Make it possible to override branding
Browse files Browse the repository at this point in the history
  • Loading branch information
prusnak committed Jul 17, 2022
1 parent 85440eb commit eada68d
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 33 deletions.
11 changes: 11 additions & 0 deletions controllers/home.ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ func NewHomeController(svc *service.LndhubService, html string) *HomeController
}
}

type HomepageBranding struct {
Title string
Desc string
Url string
Logo string
Favicon string
Footer map[string]string
}

type HomepageContent struct {
NumActiveChannels int
NumPendingChannels int
Expand All @@ -40,6 +49,7 @@ type HomepageContent struct {
BlockHeight int
Uris []string
Channels []Channel
Branding service.BrandingConfig
}

type Channel struct {
Expand Down Expand Up @@ -111,6 +121,7 @@ func (controller *HomeController) Home(c echo.Context) error {
BlockHeight: int(info.BlockHeight),
Channels: channelSlice,
Uris: info.Uris,
Branding: controller.svc.Config.Branding,
}
var buf bytes.Buffer
err = tmpl.Execute(&buf, content)
Expand Down
33 changes: 33 additions & 0 deletions lib/service/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package service

import (
"fmt"
"strings"
)

type Config struct {
DatabaseUri string `envconfig:"DATABASE_URI" required:"true"`
SentryDSN string `envconfig:"SENTRY_DSN"`
Expand All @@ -24,4 +29,32 @@ type Config struct {
MaxReceiveAmount int64 `envconfig:"MAX_RECEIVE_AMOUNT" default:"0"`
MaxSendAmount int64 `envconfig:"MAX_SEND_AMOUNT" default:"0"`
MaxAccountBalance int64 `envconfig:"MAX_ACCOUNT_BALANCE" default:"0"`
Branding BrandingConfig
}

type BrandingConfig struct {
Title string `envconfig:"BRANDING_TITLE" default:"LndHub.go - Alby Lightning"`
Desc string `envconfig:"BRANDING_DESC" default:"Alby server for the Lightning Network"`
Url string `envconfig:"BRANDING_URL" default:"https://ln.getalby.com"`
Logo string `envconfig:"BRANDING_LOGO" default:"/static/img/alby.svg"`
Favicon string `envconfig:"BRANDING_FAVICON" default:"/static/img/favicon.png"`
Footer FooterLinkMap `envconfig:"BRANDING_FOOTER" default:"about=https://getalby.com;community=https://t.me/getAlby"`
}

// envconfig map decoder uses colon (:) as the default separator
// we have to override the decoder so we can use colon for the protocol prefix (e.g. "https:")

type FooterLinkMap map[string]string

func (flm *FooterLinkMap) Decode(value string) error {
m := map[string]string{}
for _, pair := range strings.Split(value, ";") {
kvpair := strings.Split(pair, "=")
if len(kvpair) != 2 {
return fmt.Errorf("invalid map item: %q", pair)
}
m[kvpair[0]] = kvpair[1]
}
*flm = m
return nil
}
6 changes: 3 additions & 3 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ body {
top: 24px;
right: 24px;
}

#progressbar {
appearance: none;
margin: 0;
Expand Down Expand Up @@ -186,6 +185,9 @@ footer a {
body {
padding-right: 300px;
}
.logo {
width: 200px;
}
.sidebar {
position: fixed;
top: 0;
Expand Down Expand Up @@ -249,5 +251,3 @@ footer a {
}

}


22 changes: 22 additions & 0 deletions static/img/alby.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit eada68d

Please sign in to comment.