Stub out all SSR, built login page

This commit is contained in:
Ean Milligan
2026-04-10 02:37:13 -04:00
parent 318f096d33
commit 5b28f36bef
4 changed files with 77 additions and 4 deletions

3
ssr/buildHome.ts Normal file
View File

@@ -0,0 +1,3 @@
export default (userId: string) => {
return `${userId}`;
};

19
ssr/buildLogin.ts Normal file
View File

@@ -0,0 +1,19 @@
export default `<div>
<script>
function doLogin() {
fetch('/api/auth', {
method:'POST',
body:JSON.stringify({ name:document.getElementById('name').value.trim(), pin:document.getElementById('pin').value.trim() })
}).catch((e)=>{e.text().then((text)=>{alert(text);});}).then((r) => {
if(r.status===200){r.json().then((j)=>{localStorage.setItem('name', document.getElementById('name').value.trim());window.location.replace('/api/home/'+j.id);});}
else{r.text().then((text)=>{alert(text);});}
});
}
</script>
<p>Please sign in:</p>
<label>Name: <input id="name" type="text" autocomplete="off"/></label>
<br/>
<label>PIN: <input id="pin" type="password" autocomplete="off"/></label>
<br/>
<button onclick="doLogin()">Sign In</button>
</div>`;

36
ssr/buildPage.ts Normal file
View File

@@ -0,0 +1,36 @@
import { STATUS_CODE, STATUS_TEXT } from '@std/http/status';
// Utilize the pre-existing stylesheets, do a little tweaking to make it ours
const buildPage = (str: string) =>
`<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>XIVPlan+DB Manager</title>
<meta name="distribution" content="web">
<meta name="web_author" content="Ean Milligan (ean@milligan.dev)">
<meta name="author" content="Ean Milligan (ean@milligan.dev)">
<meta name="designer" content="Ean Milligan (ean@milligan.dev)">
<meta name="publisher" content="Ean Milligan (ean@milligan.dev)">
<meta name="robots" content="noindex, nofollow">
<style>
body {
background-color:black;
color:white;
}
a {
text-decoration:none;
color:white;
}
</style>
</head>
<body>
<header><h1><a href="/api/home">XIVPlan+DB Manager</a></h1></header>
${str}
</body>
</html>`;
const htmlHeaders = new Headers();
htmlHeaders.append('Content-Type', 'text/html');
export default (str: string) => new Response(buildPage(str), { status: STATUS_CODE.OK, statusText: STATUS_TEXT[STATUS_CODE.OK], headers: htmlHeaders });