Show platform flag on every page

This commit is contained in:
Megan O'Keefe 2020-04-22 12:38:24 -04:00
parent ff50ec1040
commit 65c5c3ebf1
7 changed files with 42 additions and 28 deletions

View file

@ -40,9 +40,10 @@ type platformDetails struct {
var (
templates = template.Must(template.New("").
Funcs(template.FuncMap{
Funcs(template.FuncMap{
"renderMoney": renderMoney,
}).ParseGlob("templates/*.html"))
plat platformDetails
)
func (fe *frontendServer) homeHandler(w http.ResponseWriter, r *http.Request) {
@ -80,7 +81,7 @@ func (fe *frontendServer) homeHandler(w http.ResponseWriter, r *http.Request) {
//get env and render correct platform banner.
var env = os.Getenv("ENV_PLATFORM")
plat := platformDetails{}
plat = platformDetails{}
plat.setPlatformDetails(strings.ToLower(env))
if err := templates.ExecuteTemplate(w, "home", map[string]interface{}{
@ -168,6 +169,8 @@ func (fe *frontendServer) productHandler(w http.ResponseWriter, r *http.Request)
"product": product,
"recommendations": recommendations,
"cart_size": cartSize(cart),
"platform_css": plat.css,
"platform_name": plat.provider,
}); err != nil {
log.Println(err)
}
@ -275,6 +278,8 @@ func (fe *frontendServer) viewCartHandler(w http.ResponseWriter, r *http.Request
"total_cost": totalPrice,
"items": items,
"expiration_years": []int{year, year + 1, year + 2, year + 3, year + 4},
"platform_css": plat.css,
"platform_name": plat.provider,
}); err != nil {
log.Println(err)
}
@ -335,6 +340,8 @@ func (fe *frontendServer) placeOrderHandler(w http.ResponseWriter, r *http.Reque
"order": order.GetOrder(),
"total_paid": &totalPaid,
"recommendations": recommendations,
"platform_css": plat.css,
"platform_name": plat.provider,
}); err != nil {
log.Println(err)
}

View file

@ -6,9 +6,7 @@ body {
font-family: 'Roboto', sans-serif;
}
hr {
border-top: 1px solid #b4b2bb;
}
.text-muted {
color: #707070;
@ -232,7 +230,6 @@ footer .footer-top .app {
footer .footer-top .footer-social {
padding: 31px;
border-bottom: 1px solid #b4b2bb;
}
footer .footer-top .footer-social h4 {
@ -243,9 +240,6 @@ footer .footer-top .footer-social div {
width: 50%;
}
.footer-top .social {
border-right: 1px solid #b4b2bb;
}
.footer-top .social h4 {
font-size: 24px;
@ -264,6 +258,7 @@ footer .footer-top .footer-social div {
.footer-top .app {
justify-content: flex-end;
padding-left: 100px;
}
.footer-top .app h4 {
@ -546,7 +541,6 @@ main.home {
.aws-platform,
.aws-platform .platform-flag {
background-color: #ff9900;
color: #000000;
}
.onprem-platform,
@ -561,7 +555,7 @@ main.home {
.azure-platform,
.azure-platform .platform-flag {
background-color:#F25022;
background-color: #f35426;
}
.platform-flag {
@ -620,4 +614,4 @@ form #currency_form {
display: flex;
align-items: center;
outline:none !important;
}
}

View file

@ -1,6 +1,10 @@
{{ define "cart" }}
{{ template "header" . }}
<div {{ with $.platform_css }} class="{{.}}" {{ end }}>
<span class="platform-flag">
{{$.platform_name}}
</span>
</div>
<main role="main" class="cart">
<div class="cart-bg">
<div class="container py-3 px-lg-5 py-lg-5">
@ -21,11 +25,11 @@
<button class="btn btn-secondary empty-btn" type="submit">Empty cart</button>
<a class="btn btn-info" href="/" role="button">Keep browsing</a>
</form>
</div>
</div>
<hr>
{{ range $.items }}
<div class="product-item">
<div class="row pt-2 mb-2">
@ -74,7 +78,7 @@
<input type="text" class="form-control"
name="zip_code" id="zip_code" value="94043" required pattern="\d{4,5}">
</div>
</div>
<div class="form-row">
<div class="col-md-5 mb-3">
@ -90,7 +94,7 @@
<div class="col-md-5 mb-3">
<label for="country">Country</label>
<input type="text" class="form-control" id="country"
placeholder="Country Name"
placeholder="Country Name"
name="country" value="United States" required>
</div>
</div>
@ -145,7 +149,7 @@
</div>
</div>
{{ end }} <!-- end if $.items -->
</div>
{{ if $.recommendations}}
{{ template "recommendations" $.recommendations }}

View file

@ -1,12 +1,16 @@
{{ define "error" }}
{{ template "header" . }}
<div {{ with $.platform_css }} class="{{.}}" {{ end }}>
<span class="platform-flag">
{{$.platform_name}}
</span>
</div>
<main role="main">
<div class="py-5">
<div class="container bg-light py-3 px-lg-5 py-lg-5">
<h1>Uh, oh!</h1>
<p>Something has failed. Below are some details for debugging.</p>
<p><strong>HTTP Status:</strong> {{.status_code}} {{.status}}</p>
<pre class="border border-danger p-3"
style="white-space: pre-wrap; word-break: keep-all;">

View file

@ -3,12 +3,8 @@
<footer class="py-5">
<div class="footer-top">
<div class="container footer-social">
<div class="social">
<h5>© 2020 Google Inc - <a href="https://github.com/GoogleCloudPlatform/microservices-demo">Source Code</a></h5>
</div>
<div class="app">
<h5>This website is hosted for demo purposes only. It is not an actual shop. This is not a Google product.</h5>
</div>
<p>© 2020 Google Inc (<a href="https://github.com/GoogleCloudPlatform/microservices-demo">Source Code</a>) — </p>
<p class="footer-disclaimer"> This website is hosted for demo purposes only. It is not an actual shop. This is not a Google product.</p>
</div>
</div>

View file

@ -1,6 +1,10 @@
{{ define "order" }}
{{ template "header" . }}
<div {{ with $.platform_css }} class="{{.}}" {{ end }}>
<span class="platform-flag">
{{$.platform_name}}
</span>
</div>
<main role="main" class="order">
<div class="py-5">
<div class="container py-3 px-lg-5">
@ -20,7 +24,7 @@
<p class="mg-bt"><strong>USD {{renderMoney .total_paid}}</strong></p>
</div>
</div>
</div>
<div class="container py-3 px-lg-5">
<div class="row py-2 text-center">

View file

@ -1,5 +1,10 @@
{{ define "product" }}
{{ template "header" . }}
<div {{ with $.platform_css }} class="{{.}}" {{ end }}>
<span class="platform-flag">
{{$.platform_name}}
</span>
</div>
<main role="main">
<div class="h-product">