From 960b0245b2c93df8464b7a883ef5286012c2b668 Mon Sep 17 00:00:00 2001 From: Lou Knauer Date: Wed, 8 Dec 2021 10:09:47 +0100 Subject: [PATCH] templates for the login page --- templates/404.html | 10 +++++++++ templates/base.html | 24 +++++++++++++++++++++ templates/login.html | 48 ++++++++++++++++++++++++++++++++++++++++++ templates/templates.go | 29 +++++++++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 templates/404.html create mode 100644 templates/base.html create mode 100644 templates/login.html create mode 100644 templates/templates.go diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000..c937561 --- /dev/null +++ b/templates/404.html @@ -0,0 +1,10 @@ +{{template "base.html" .}} +{{define "content"}} +
+
+ +
+
+{{end}} diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..32d6f6b --- /dev/null +++ b/templates/base.html @@ -0,0 +1,24 @@ + + + + + + {{.Title}} + + + + + + + +
+
+
+ {{block "content" .}} + Whoops, you should not see this... + {{end}} +
+
+
+ + \ No newline at end of file diff --git a/templates/login.html b/templates/login.html new file mode 100644 index 0000000..35776a4 --- /dev/null +++ b/templates/login.html @@ -0,0 +1,48 @@ +{{template "base.html" .}} +{{define "content"}} +
+
+

+ ClusterCockpit Login +

+
+
+
+
+ {{if .Login.Error}} + + {{end}} + + {{if .Login.Info}} + + {{end}} +
+
+
+
+
+
+ + +
+
+ + +
+ +
+
+
+
+
+
+
+ +
+
+
+{{end}} diff --git a/templates/templates.go b/templates/templates.go new file mode 100644 index 0000000..c1c7c07 --- /dev/null +++ b/templates/templates.go @@ -0,0 +1,29 @@ +package templates + +import ( + "html/template" + "log" + "net/http" +) + +var templates *template.Template + +type Page struct { + Title string + Login *LoginPage +} + +type LoginPage struct { + Error string + Info string +} + +func init() { + templates = template.Must(template.ParseGlob("./templates/*.html")) +} + +func Render(rw http.ResponseWriter, r *http.Request, name string, page *Page) { + if err := templates.ExecuteTemplate(rw, name, page); err != nil { + log.Printf("template error: %s\n", err.Error()) + } +}