flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit 543b6a470d38804179b76ecdc947a3d969c279a1
parent 9cae990bcac0b7990cfe3f57f1d5fc5c14969e3e
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Thu, 22 Oct 2020 17:18:53 -0700

add register template

Diffstat:
Mhttp.go | 16++++++++++++++--
Atemplates/register.html | 37+++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/http.go b/http.go @@ -84,7 +84,7 @@ func loginHandler(w http.ResponseWriter, r *http.Request) { data := struct { Error string PageTitle string - }{"", c.SiteTitle} + }{"", "Login"} err := t.ExecuteTemplate(w, "login.html", data) if err != nil { log.Println(err) @@ -118,8 +118,19 @@ func loginHandler(w http.ResponseWriter, r *http.Request) { } } -func register(w http.ResponseWriter, r *http.Request) { +func registerHandler(w http.ResponseWriter, r *http.Request) { if r.Method == "GET" { + data := struct { + Domain string + Errors []string + PageTitle string + }{c.RootDomain, nil, "Register"} + err := t.ExecuteTemplate(w, "register.html", data) + if err != nil { + log.Println(err) + renderError(w, InternalServerErrorMsg, 500) + return + } } else if r.Method == "POST" { } } @@ -144,6 +155,7 @@ func runHTTPServer() { http.HandleFunc(c.RootDomain+"/my_site", mySiteHandler) http.HandleFunc(c.RootDomain+"/edit/", editFileHandler) http.HandleFunc(c.RootDomain+"/login", loginHandler) + http.HandleFunc(c.RootDomain+"/register", registerHandler) // http.HandleFunc("/delete/", deleteFileHandler) // login+register functions diff --git a/templates/register.html b/templates/register.html @@ -0,0 +1,37 @@ +{{template "header" .}} +<h1>Register</h1> +<form action="/register" method="post"> + <div> + <label for="username">Username</label> + <input + id="username" + name="username" + size="32" + type="text" + value="" + />.{{.Domain}} + </div> + <div> + <label for="email">Email</label> + <input id="email" name="email" size="64" type="text" value="" /> + </div> + <div> + <label for="password">Password</label> + <input id="password" name="password" size="32" type="password" value="" /> + </div> + <div> + <label for="password2">Repeat Password</label> + <input id="password2" name="password2" size="32" type="password" value="" /> + </div> + <div class="error">{{ range .Errors}}<p>{{.}}</p>{{end}} </div> + <div> + <input + class="button" + id="submit" + name="submit" + type="submit" + value="Join" + /> + </div> +</form> +{{template "footer" .}}