This commit is contained in:
biglyderv 2024-11-25 14:12:43 -05:00
parent 153c74bd22
commit 9287290479
11 changed files with 321 additions and 24 deletions

View file

@ -1,13 +1,12 @@
import Route from "../route.js";
import form from "../comp/form.js";
// TODO: rewrite
let main = new Route([], async function (req, res, input) {
return `<div class='form-message'></div>
<form enctype='multipart/form-data' method='POST' action='/api/form/login'>
Username: <input type='text' name='user'><br/>
Password: <input type='password' name='pass'><br/>
<input type='submit'>
</form>`;
return form([
{ label: "Username", type: "text", name: "user" },
{ label: "Password", type: "password", name: "pass" }
],'/api/form/register')
});
export default main;

View file

@ -1,9 +1,23 @@
import Route from "../route.js";
import Auth from "../form/auth.js";
import Format from "../common/format.js";
import auth from "../form/auth.js";
import format from "../common/format.js";
let main = new Route([Auth], async function (req, res, input) {
return `Hello world! Your name is: ${Format.escape(input.username)}`
let main = new Route([auth], async function (req, res, input) {
let { username } = input;
let cta = (username == '!nobody') ?
'<div class="button"><a href="/client/register">Join</a></div>' :
'<div class="button"><a href="/client/chat?channel=main">Chat</a></div>';
return `<div class='area'>
<h1>About</h1>
<p>
<b>BiglyChat</b> is a chat service built on <a href='https://codeberg.org/onezDerv/bigly-chat'>free software</a>.
</p>
<p>
Anyone can selfhost an instance to take control of their community.
</p>
${cta}
</div>`
});
export default main;

View file

@ -1,14 +1,13 @@
import Route from "../route.js";
import form from "../comp/form.js";
// TODO: rewrite
let main = new Route([], async function (req, res, input) {
return `<div class='form-message'></div>
<form enctype='multipart/form-data' method='POST' action='/api/form/register'>
Username: <input type='text' name='user'><br/>
Password: <input type='password' name='pass'><br/>
Password (again): <input type='password' name='pass2'><br/>
<input type='submit'>
</form>`;
return form([
{ label: "Username", type: "text", name: "user" },
{ label: "Password", type: "password", name: "pass" },
{ label: "Password (again)", type: "password", name: "pass2" },
],'/api/form/register')
});
export default main;