diff options
Diffstat (limited to '')
-rw-r--r-- | index.go | 40 | ||||
-rw-r--r-- | tmpl/login.html | 4 | ||||
-rw-r--r-- | tmpl/student.html | 6 |
3 files changed, 28 insertions, 22 deletions
@@ -48,13 +48,12 @@ func handleIndex(w http.ResponseWriter, req *http.Request) { err = tmpl.ExecuteTemplate( w, "login", - map[string]string{ - "authURL": authURL, - /* - * We directly generate the login URL here - * instead of doing so in a redirect to save - * requests. - */ + struct { + AuthURL string + Notes string + }{ + authURL, + "", }, ) if err != nil { @@ -87,9 +86,12 @@ func handleIndex(w http.ResponseWriter, req *http.Request) { err = tmpl.ExecuteTemplate( w, "login", - map[string]interface{}{ - "authURL": authURL, - "notes": "Your session is invalid or has expired.", + struct { + AuthURL string + Notes string + }{ + authURL, + "Your session is invalid or has expired.", }, ) if err != nil { @@ -129,16 +131,20 @@ func handleIndex(w http.ResponseWriter, req *http.Request) { }) err = func() error { + /* Horrifying syntax */ return tmpl.ExecuteTemplate( w, "student", - map[string]interface{}{ - "open": true, - "user": map[string]interface{}{ - "Name": userName, - "Department": userDepartment, - }, - "courses": &_courses, + struct { + Open bool + Name string + Department string + Courses *map[int]*courseT + }{ + true, + userName, + userDepartment, + &_courses, }, ) }() diff --git a/tmpl/login.html b/tmpl/login.html index 54b68d3..d4c2da1 100644 --- a/tmpl/login.html +++ b/tmpl/login.html @@ -48,13 +48,13 @@ <main> <div id="login-box"> <p> - {{- .notes -}} + {{- if eq .Notes "" -}}{{- .Notes -}}{{- end -}} </p> <p> You have not authenticated. You must sign in to use this service. </p> <p> - <a class="btn btn-primary" href="{{- .authURL -}}">Sign in with Microsoft</a> + <a class="btn btn-primary" href="{{- .AuthURL -}}">Sign in with Microsoft</a> </p> </div> </main> diff --git a/tmpl/student.html b/tmpl/student.html index 8b6982b..0503b04 100644 --- a/tmpl/student.html +++ b/tmpl/student.html @@ -3,7 +3,7 @@ <html lang="en"> <head> <title> - {{ .user.Name }} – CCA Selection System + {{ .Name }} – CCA Selection System </title> <link rel="stylesheet" href="/static/style.css" /> <meta charset="utf-8" /> @@ -38,7 +38,7 @@ </nav> </div> <div class="header-right"> - <p>{{- .user.Name }} ({{ .user.Department -}})</p> + <p>{{- .Name }} ({{ .Department -}})</p> </div> </div> </header> @@ -131,7 +131,7 @@ </tr> </thead> <tbody> - {{- range .courses }} + {{- range .Courses }} <tr class="courseitem" id="course{{.ID}}"> {{ if lt .Selected .Max -}} <th scope="row"><input aria-label="Enroll in course" class="coursecheckbox" type="checkbox" id="tick{{.ID}}" name="tick{{.ID}}" value="tick{{.ID}}"></input><span id="coursestatus{{.ID}}"></span></td> |