update readme and build

This commit is contained in:
2026-05-24 07:18:54 +00:00
parent 45e18b5423
commit 5b4803bc49
9 changed files with 447 additions and 38 deletions
+95
View File
@@ -0,0 +1,95 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GoTermix — Sign in</title>
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
<link rel="stylesheet" href="/static/app.css" />
<style>
/* login page overrides — no tab bar or toolbar offsets */
body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
</style>
</head>
<body>
<div class="m-card" style="max-width:360px;width:100%;margin:16px;">
<div class="auth-card">
<div class="auth-logo"><em>&gt;_</em> GoTermix</div>
<div class="auth-sub">Authentication required</div>
<label class="m-label" for="fUser">Username</label>
<input class="m-input" type="text" id="fUser"
autofocus autocomplete="username"
placeholder="username" spellcheck="false"
maxlength="64">
<label class="m-label" for="fPass">Password</label>
<input class="m-input" type="password" id="fPass"
autocomplete="current-password"
placeholder="password"
maxlength="1024">
<div class="auth-err" id="authErr"></div>
<button class="auth-btn" id="authBtn" onclick="doLogin()">
<div class="auth-spin"></div>
<span class="btn-text">Sign in</span>
</button>
</div>
</div>
<script>
const CSRF_TOKEN = "[[CSRF_TOKEN]]";
const NEXT = "[[NEXT]]";
document.getElementById('fUser').addEventListener('keydown', e => {
if (e.key === 'Enter') document.getElementById('fPass').focus();
});
document.getElementById('fPass').addEventListener('keydown', e => {
if (e.key === 'Enter') doLogin();
});
async function doLogin() {
const username = document.getElementById('fUser').value.trim();
const password = document.getElementById('fPass').value;
const btn = document.getElementById('authBtn');
if (!username || !password) { showErr('Enter username and password'); return; }
btn.disabled = true; btn.classList.add('busy');
document.getElementById('authErr').classList.remove('show');
const form = new URLSearchParams();
form.append('username', username);
form.append('password', password);
form.append('csrf_token', CSRF_TOKEN);
try {
const res = await fetch('/auth', {
method: 'POST',
body: form,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
});
const data = await res.json();
if (data.ok) {
window.location.href = NEXT || '/';
} else {
showErr(data.error || 'Authentication failed');
}
} catch (_) {
showErr('Network error — try again');
} finally {
btn.disabled = false; btn.classList.remove('busy');
}
}
function showErr(msg) {
const e = document.getElementById('authErr');
e.textContent = msg; e.classList.add('show');
document.getElementById('fPass').value = '';
document.getElementById('fPass').focus();
}
</script>
</body>
</html>