Skip to content

Commit

Permalink
Merge pull request #9 from eirsyl/env-customization
Browse files Browse the repository at this point in the history
Add env variables for site title, header color and logo, fixes #3
  • Loading branch information
eirsyl authored Oct 4, 2017
2 parents 52023bc + ec5427f commit 1a2b5dd
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ all variables you can use.
|POSTGRES_ADDRESS |The address of the postgres instance|
|POSTGRES_USER |The postgres username for authorization|
|POSTGRES_PASSWORD|The postgres password for authorization|
|POSTGRES_DB |The postgres db name|
|POSTGRES_DB |The postgres db name|
|SITE_OWNER |The owner of the side, visible in page title|
|SITE_COLOR |The background color applied on the header element|
|SITE_LOGO |Custom logo, served from another site or local path inside the static folder|
20 changes: 19 additions & 1 deletion src/routes/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/eirsyl/statuspage/src"
"github.com/gin-gonic/gin"
"net/http"
"os"
)

func Dashboard(c *gin.Context) {
Expand All @@ -20,8 +21,25 @@ func Dashboard(c *gin.Context) {
panic(err)
}

owner := os.Getenv("SITE_OWNER")
if owner == "" {
owner = "Abakus"
}

color := os.Getenv("SITE_COLOR")
if color == "" {
color = "#343434"
}

logo := os.Getenv("SITE_LOGO")
if logo == "" {
logo = "static/img/logo.png"
}

c.HTML(http.StatusOK, "index.tmpl", gin.H{
"owner": "Abakus",
"owner": owner,
"backgroundColor": color,
"logo": logo,
"services": src.AggregateServices(res),
"mostCriticalStatus": src.MostCriticalStatus(res),
"incidents": src.AggregateIncidents(inc),
Expand Down
1 change: 0 additions & 1 deletion static/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ a {

.header {
z-index: -1;
background-color: #343434;
position: absolute;
top: 0;
left: 0;
Expand Down
8 changes: 7 additions & 1 deletion templates/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@
<link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
<link rel="stylesheet" href="static/css/app.css" />
<link rel="stylesheet" href="static/css/font-awesome.min.css">

<style>
.header {
background-color: {{ .backgroundColor }};
}
</style>
</head>
<body>
<div class="header"></div>
<div class="page">
<div class="spacer">

<div class="flex row">
<img class="logo" src="static/img/logo.png" />
<img class="logo" src="{{ .logo }}" />
</div>

<div class="info-header">
Expand Down

0 comments on commit 1a2b5dd

Please sign in to comment.