aboutsummaryrefslogtreecommitdiff
path: root/internal/webui/html
diff options
context:
space:
mode:
authorJulien Dessaux2021-04-21 17:23:07 +0200
committerJulien Dessaux2021-04-21 17:23:07 +0200
commit4a2fb7e82d5d617298cb28b66485fc6f30c55781 (patch)
tree4ae55d8208e3ebf603f3a17ac56f6efd0e011efc /internal/webui/html
parentImplemented the ResumeSession function (diff)
downloadtrains-4a2fb7e82d5d617298cb28b66485fc6f30c55781.tar.gz
trains-4a2fb7e82d5d617298cb28b66485fc6f30c55781.tar.bz2
trains-4a2fb7e82d5d617298cb28b66485fc6f30c55781.zip
Reworked the webui package, added authentication feature and tests
Diffstat (limited to '')
-rw-r--r--internal/webui/html/base.html18
-rw-r--r--internal/webui/html/index.html24
-rw-r--r--internal/webui/html/login.html13
-rw-r--r--internal/webui/html/root.html15
4 files changed, 46 insertions, 24 deletions
diff --git a/internal/webui/html/base.html b/internal/webui/html/base.html
new file mode 100644
index 0000000..7522e94
--- /dev/null
+++ b/internal/webui/html/base.html
@@ -0,0 +1,18 @@
+{{ define "base" }}
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>{{ .Title }}</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+
+ <link rel="icon" type="image/png" href="/static/favicon.png" />
+ <link rel="stylesheet" href="/static/main.css">
+ </head>
+ <body>
+ <main>
+ {{ template "main" . }}
+ </main>
+ </body>
+</html>
+{{ end }}
diff --git a/internal/webui/html/index.html b/internal/webui/html/index.html
deleted file mode 100644
index a0a7d82..0000000
--- a/internal/webui/html/index.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!doctype html>
-<html lang="en">
- <head>
- <meta charset="utf-8">
- <title>{{ .Title }}</title>
- <meta name="viewport" content="width=device-width, initial-scale=1">
-
- <link rel="icon" type="image/png" href="/static/favicon.png" />
- <link rel="stylesheet" href="/static/main.css">
- </head>
- <body>
- <h3>Horaires des prochains trains à Crépieux la Pape</h3>
- <table>
- <thead>
- <tr><th>Arrivée en gare</th><th>Direction</th></tr>
- </thead>
- <tbody>
- {{ range .Departures }}
- <tr{{ if .Odd }} style="color:#111111;"{{ end }}><td>{{ .Arrival }}</td><td>{{ .DisplayName }}</td></tr>
- {{ end }}
- </tbody>
- </table>
- </body>
-</html>
diff --git a/internal/webui/html/login.html b/internal/webui/html/login.html
new file mode 100644
index 0000000..33e9f02
--- /dev/null
+++ b/internal/webui/html/login.html
@@ -0,0 +1,13 @@
+{{ template "base" . }}
+
+{{ define "main" }}
+<form action="/login" method="post">
+ <label for="username"><b>Username</b></label>
+ <input type="text" placeholder="Enter Username" name="username" required>
+
+ <label for="password"><b>Password</b></label>
+ <input type="password" placeholder="Enter Password" name="password" required>
+
+ <button type="submit">Login</button>
+</form>
+{{ end }}
diff --git a/internal/webui/html/root.html b/internal/webui/html/root.html
new file mode 100644
index 0000000..a293ee7
--- /dev/null
+++ b/internal/webui/html/root.html
@@ -0,0 +1,15 @@
+{{ template "base" . }}
+
+{{ define "main" }}
+<h3>Horaires des prochains trains à Crépieux la Pape</h3>
+<table>
+ <thead>
+ <tr><th>Arrivée en gare</th><th>Direction</th></tr>
+ </thead>
+ <tbody>
+ {{ range .Departures }}
+ <tr{{ if .Odd }} style="color:#111111;"{{ end }}><td>{{ .Arrival }}</td><td>{{ .DisplayName }}</td></tr>
+ {{ end }}
+ </tbody>
+</table>
+{{ end }}