121 lines
4.8 KiB
Cheetah
121 lines
4.8 KiB
Cheetah
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>{{ .title }}</title>
|
|
{{template "head" .}}
|
|
</head>
|
|
<body>
|
|
{{template "navbar" .}}
|
|
|
|
<div class="position-absolute top-50 start-50 translate-middle text-center">
|
|
{{if .loggedIn}}
|
|
<div>Welcome to the {{ .title }}.</div>
|
|
{{else}}
|
|
<div>
|
|
<a class="link-secondary" href="/login">Login</a> to continue.
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
|
|
{{template "scripts" .}}
|
|
</body>
|
|
</html>
|
|
|
|
{{define "head"}}
|
|
<link rel="apple-touch-icon" sizes="180x180" href="../static/icons/apple-touch-icon.png">
|
|
<link rel="icon" type="image/png" sizes="32x32" href="../static/icons/favicon-32x32.png">
|
|
<link rel="icon" type="image/png" sizes="16x16" href="../static/icons/favicon-16x16.png">
|
|
<link rel="manifest" href="../static/icons/site.webmanifest">
|
|
<link rel="mask-icon" href="../static/icons/safari-pinned-tab.svg" color="#5bbad5">
|
|
<meta name="msapplication-TileColor" content="#da532c">
|
|
<meta name="theme-color" content="#ffffff">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
|
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
|
{{end}}
|
|
|
|
{{define "navbar"}}
|
|
<nav class="navbar navbar-expand-md navbar-light bg-light">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="/">SuperSave</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
|
|
data-bs-target="#navbarSupportedContent"
|
|
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
|
<ul class="ms-auto navbar-nav mb-2 mb-lg-0">
|
|
{{if .loggedIn}}
|
|
<li class="nav-item me-2">
|
|
<a class="btn btn-primary" href="/tasks">Tasks</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="btn btn-danger" href="/logout">Logout</a>
|
|
</li>
|
|
{{else}}
|
|
<li class="nav-item">
|
|
<a class="btn btn-primary" href="/login">Login</a>
|
|
</li>
|
|
{{end}}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
{{end}}
|
|
|
|
{{define "userForm"}}
|
|
<form class="row g-3 needs-validation mb-3" novalidate>
|
|
<div class="col-12">
|
|
<label for="username" class="form-label">Username</label>
|
|
<div class="input-group has-validation">
|
|
<span class="input-group-text" id="inputGroupPrepend">@</span>
|
|
<input type="text" class="form-control" id="username"
|
|
aria-describedby="inputGroupPrepend" required>
|
|
<div class="invalid-feedback">
|
|
Please choose a username.
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-12">
|
|
<label for="password" class="form-label">Password</label>
|
|
<input type="password" class="form-control" id="password" aria-describedby="passwordHelp" required>
|
|
<div id="invalidPassword" class="invalid-feedback">
|
|
Please choose a password.
|
|
</div>
|
|
</div>
|
|
<div class="col-12">
|
|
<button class="btn btn-primary" id="button" type="submit">Submit form</button>
|
|
</div>
|
|
</form>
|
|
{{end}}
|
|
|
|
{{define "scripts"}}
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
|
|
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
|
|
crossorigin="anonymous"></script>
|
|
<script>
|
|
let form = document.querySelector('.needs-validation')
|
|
if (form) {
|
|
form.addEventListener('submit', function (event) {
|
|
if (!form.checkValidity()) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
} else {
|
|
document.getElementById("button").disabled = true;
|
|
event.preventDefault();
|
|
let data = new FormData();
|
|
let form_element = document.getElementsByClassName('form-control');
|
|
for (let i = 0; i < form_element.length; i++) {
|
|
data.append(form_element[i].id, form_element[i].value);
|
|
}
|
|
submitForm(data);
|
|
}
|
|
form.classList.add('was-validated');
|
|
}, false);
|
|
}
|
|
|
|
function redirect(location) {
|
|
window.location.href = location;
|
|
}
|
|
</script>
|
|
{{end}}
|