~netlandish/links

049d82098fdcb2fd6dd56f02f78363d59efe09d0 — Peter Sanchez 5 months ago c005d37
Adding environment banner
3 files changed, 32 insertions(+), 0 deletions(-)

M core/templates.go
M static/css/style.css
M templates/base.html
M core/templates.go => core/templates.go +13 -0
@@ 14,6 14,11 @@ import (
	"netlandish.com/x/gobwebs/server"
)

const (
	productionEnv = "production"
	stagingEnv    = "staging"
)

// AddGlobalTmpl provides global tmpl vars for templates
func AddGlobalTmpl(c echo.Context) gobwebs.Map {
	gctx := c.(*server.Context)


@@ 74,6 79,14 @@ func AddGlobalTmpl(c echo.Context) gobwebs.Map {
		gmap["currentUser"] = user
		// To avoid nil pointer error
		gmap["currentUserID"] = user.ID

		// Display the environment name in the base template
		if user.IsSuperUser() || user.IsStaff() {
			switch gctx.Server.Config.Environment {
			case productionEnv, stagingEnv:
				gmap["env"] = gctx.Server.Config.Environment
			}
		}
	}

	gmap["currentOrg"] = links.GetOrgSelection(c)

M static/css/style.css => static/css/style.css +14 -0
@@ 13,6 13,20 @@ body {
  text-rendering: optimizeLegibility;
}

#env-banner {
  text-align: center;
  color: white;
  text-transform: uppercase;
  z-index: 10000;
  position: relative;
}
.env-production {
  background-color: red;
}
.env-staging {
  background-color: green;
}

.root-container {
  display: flex;
  flex-direction: row;

M templates/base.html => templates/base.html +5 -0
@@ 15,6 15,11 @@
    {{ block "extrahead" . }}{{ end }}
  </head>
  <body class="container{{if .hideNav}} full-contaiter{{end}}"{{if or .useTagAutocomplete .advancedSearch}} data-autocomplete="{{reverse "core:tag_autocomplete"}}?org={{.autoCompleteOrgID}}"{{end}}>
    {{if .env }}
    <div id="env-banner" class="env-{{.env}}">
        {{ .env }} enviroment
    </div>
    {{end}}
    {{ if .hideNav }}
        <div class="full-content-title">
          <h1>{{.base_pd.Title}}</h1>