templates cleanup
This commit is contained in:
parent
8e8781b06b
commit
b184d456ea
30
main.go
30
main.go
@ -21,7 +21,18 @@ func signupPage(res http.ResponseWriter, req *http.Request) {
|
|||||||
if u != "" {
|
if u != "" {
|
||||||
http.Redirect(res, req, "/", 302)
|
http.Redirect(res, req, "/", 302)
|
||||||
} else {
|
} 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
|
return
|
||||||
}
|
}
|
||||||
@ -55,7 +66,18 @@ func loginPage(res http.ResponseWriter, req *http.Request) {
|
|||||||
if u != "" {
|
if u != "" {
|
||||||
http.Redirect(res, req, "/", 302)
|
http.Redirect(res, req, "/", 302)
|
||||||
} else {
|
} 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
|
return
|
||||||
}
|
}
|
||||||
@ -88,9 +110,13 @@ func homePage(res http.ResponseWriter, req *http.Request) {
|
|||||||
data := struct {
|
data := struct {
|
||||||
Title string
|
Title string
|
||||||
Username string
|
Username string
|
||||||
|
ShowLogin bool
|
||||||
|
ShowLogout bool
|
||||||
}{
|
}{
|
||||||
"Index",
|
"Index",
|
||||||
uname,
|
uname,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
}
|
}
|
||||||
|
|
||||||
tpl.ExecuteTemplate(res, "index", data)
|
tpl.ExecuteTemplate(res, "index", data)
|
||||||
|
@ -4,11 +4,12 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>GuildGate</title>
|
<title>GuildGate</title>
|
||||||
</head>
|
</head>
|
||||||
|
<h1>Guild Gate: {{.Title}}</h1>
|
||||||
<body>
|
<body>
|
||||||
<nav>
|
<nav>
|
||||||
<li>Logged in as: {{.Username}}
|
<div style="overflow: hidden;">
|
||||||
<!-- <li><a href="/">Home</a></li>
|
<p style="float: left;">Logged in as: {{.Username}}</p>
|
||||||
<li><a href="/login">Login</a></li>
|
<p style="float: right;"><a href="/">Home</a> {{if .ShowLogin}}<a href="/login">Login</a> {{end}}{{if .ShowLogout}}<a href="/logout">Logout</a>{{end}}</p>
|
||||||
<li><a href="/logout">Logout</a></li>--!>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
{{ define "index" }}
|
{{ define "index" }}
|
||||||
{{ template "header" .}}
|
{{ template "header" .}}
|
||||||
<a href="/register">Register</a>
|
<p><a href="/register">Register</a></p>
|
||||||
<a href="/login">Login</a>
|
<p><a href="/token">Get Token</a></p>
|
||||||
<a href="/token">Get Token</a>
|
|
||||||
{{template "footer" .}}
|
{{template "footer" .}}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
Loading…
Reference in New Issue
Block a user