diff options
-rw-r--r-- | http_handle_login.go | 18 | ||||
-rw-r--r-- | http_server.go | 16 | ||||
-rw-r--r-- | static/style.css | 73 | ||||
-rw-r--r-- | templates/login.html.tmpl | 54 |
4 files changed, 157 insertions, 4 deletions
diff --git a/http_handle_login.go b/http_handle_login.go new file mode 100644 index 0000000..ef094f1 --- /dev/null +++ b/http_handle_login.go @@ -0,0 +1,18 @@ +package main + +import ( + "net/http" +) + +func handle_login(w http.ResponseWriter, r *http.Request, params map[string]any) { + if r.Method != "POST" { + err := templates.ExecuteTemplate(w, "login", params) + if err != nil { + _, _ = w.Write([]byte("Error rendering template: " + err.Error())) + return + } + } + + _ = r.PostFormValue("username") + _ = r.PostFormValue("password") +} diff --git a/http_server.go b/http_server.go index 4d2d77c..ddbe8ce 100644 --- a/http_server.go +++ b/http_server.go @@ -34,12 +34,11 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) { switch segments[1] { case "static": static_handler.ServeHTTP(w, r) + return case "source": source_handler.ServeHTTP(w, r) - default: - http.Error(w, fmt.Sprintf("Unknown system module type: %s", segments[1]), http.StatusNotFound) + return } - return } params := make(map[string]any) @@ -52,6 +51,17 @@ func (router *http_router_t) ServeHTTP(w http.ResponseWriter, r *http.Request) { params["user_id"] = string(_user_id) } + if segments[0] == ":" { + switch segments[1] { + case "login": + handle_login(w, r, params) + return + default: + http.Error(w, fmt.Sprintf("Unknown system module type: %s", segments[1]), http.StatusNotFound) + return + } + } + fmt.Printf("%#v\n", params) separator_index := -1 diff --git a/static/style.css b/static/style.css index 40f130a..4ebcdfd 100644 --- a/static/style.css +++ b/static/style.css @@ -11,6 +11,10 @@ html { --text-decoration-color: hsl(0, 0%, 72%); --darker-box-background-color: hsl(0, 0%, 92%); --lighter-box-background-color: hsl(0, 0%, 95%); + --primary-color: hsl(320, 50%, 36%); + --primary-color-contrast: hsl(320, 0%, 100%); + --danger-color: hsl(0, 50%, 36%); + --danger-color-contrast: hsl(0, 0%, 100%); } @media (prefers-color-scheme: dark) { html { @@ -67,7 +71,7 @@ td, th { padding: 3px 5px; border: var(--lighter-border-color) solid 1px; } -th { +th, thead, tfoot { background-color: var(--lighter-box-background-color); } th[scope=row] { @@ -164,3 +168,70 @@ pre.chunk { .file-header { font-family: monospace; } + +textarea { + box-sizing: border-box; + background-color: var(--lighter-box-background-color); + resize: vertical; +} +textarea, +input[type=text], +input[type=password] { + font-family: sans-serif; + font-size: smaller; + background-color: var(--lighter-box-background-color); + color: var(--text-color); + border: none; + padding: 0.3rem; + width: 100%; + box-sizing: border-box; +} +td.tdinput, th.tdinput { + padding: 0; +} +td.tdinput textarea, +td.tdinput input[type=text], +td.tdinput input[type=password], +th.tdinput textarea, +th.tdinput input[type=text], +th.tdinput input[type=password] { + background-color: transparent; +} +.btn-primary { + background: var(--primary-color); + color: var(--primary-color-contrast); + border: var(--lighter-border-color) 1px solid; + font-weight: bold; +} +.btn-danger { + background: var(--danger-color); + color: var(--danger-color-contrast); + border: var(--lighter-border-color) 1px solid; + font-weight: bold; +} +.btn-white { + background: var(--primary-color-contrast); + color: var(--primary-color); + border: var(--lighter-border-color) 1px solid; +} +.btn-normal, +input[type=file]::file-selector-button { + background: var(--lighter-box-background-color); + border: var(--lighter-border-color) 1px solid !important; + color: var(--light-text-color); +} +.btn, .btn-white, .btn-danger, .btn-normal, .btn-primary, +input[type=submit], +input[type=file]::file-selector-button { + display: inline-block; + width: auto; + min-width: fit-content; + border-radius: 0; + padding: .1rem .75rem; + font-size: 0.9rem; + transition: background .1s linear; + cursor: pointer; +} +a.btn, a.btn-white, a.btn-danger, a.btn-normal, a.btn-primary { + text-decoration: none; +} diff --git a/templates/login.html.tmpl b/templates/login.html.tmpl new file mode 100644 index 0000000..ca9d87e --- /dev/null +++ b/templates/login.html.tmpl @@ -0,0 +1,54 @@ +{{- define "login" -}} +<!DOCTYPE html> +<html lang="en"> + <head> + {{ template "head_common" . }} + <title>Login – Lindenii Forge</title> + </head> + <body class="index"> + <div class="padding-wrapper"> + <form method="POST" enctype="application/x-www-form-urlencoded"> + <table> + <thead> + <tr> + <th class="title-row" colspan="2"> + Password Authentication + </th> + </tr> + </thead> + <tbody> + <tr> + <th scope="row">Username</th> + <td class="tdinput"> + <input id="usernameinput" name="username" type="text" /> + </td> + </tr> + <tr> + <th scope="row">Password</th> + <td class="tdinput"> + <input id="passwordinput" name="password" type="password" /> + </td> + </tr> + </tbody> + <tfoot> + <tr> + <td class="th-like" colspan="2"> + <div class="flex-justify"> + <div class="left"> + </div> + <div class="right"> + <input class="btn-primary" type="submit" value="Submit" /> + </div> + </div> + </td> + </tr> + </tfoot> + </table> + </form> + </div> + <footer> + {{ template "footer" . }} + </footer> + </body> +</html> +{{- end -}} |