From b184d456ea2975a9d1e969406d5729a0a4305a78 Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 17 Sep 2020 16:47:17 -0400 Subject: [PATCH] templates cleanup --- main.go | 34 ++++++++++++++++++++++++++++++---- templates/header.html | 9 +++++---- templates/index.html | 5 ++--- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index bfaf7c1..ceb1d92 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,18 @@ func signupPage(res http.ResponseWriter, req *http.Request) { if u != "" { http.Redirect(res, req, "/", 302) } else { - tpl.ExecuteTemplate(res, "register", nil) + data := struct { + Title string + Username string + ShowLogin bool + ShowLogout bool + }{ + "Register", + "Unregistered", + false, + false, + } + tpl.ExecuteTemplate(res, "register", data) } return } @@ -55,7 +66,18 @@ func loginPage(res http.ResponseWriter, req *http.Request) { if u != "" { http.Redirect(res, req, "/", 302) } else { - tpl.ExecuteTemplate(res, "login", nil) + data := struct { + Title string + Username string + ShowLogin bool + ShowLogout bool + }{ + "Login", + "Unregistered", + true, + false, + } + tpl.ExecuteTemplate(res, "login", data) } return } @@ -86,11 +108,15 @@ func homePage(res http.ResponseWriter, req *http.Request) { uname = u } data := struct { - Title string - Username string + Title string + Username string + ShowLogin bool + ShowLogout bool }{ "Index", uname, + true, + true, } tpl.ExecuteTemplate(res, "index", data) diff --git a/templates/header.html b/templates/header.html index d0d814e..f9ea387 100644 --- a/templates/header.html +++ b/templates/header.html @@ -4,11 +4,12 @@ GuildGate +

Guild Gate: {{.Title}}

{{end}} diff --git a/templates/index.html b/templates/index.html index ebc139d..523f50b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,7 +1,6 @@ {{ define "index" }} {{ template "header" .}} - Register - Login - Get Token +

Register

+

Get Token

{{template "footer" .}} {{ end }}