some beta stuff
This commit is contained in:
parent
2c480909ee
commit
4eddd1a0c7
7 changed files with 82 additions and 9 deletions
|
@ -42,6 +42,9 @@ body {
|
||||||
border-top-right-radius: 10px;
|
border-top-right-radius: 10px;
|
||||||
max-width: calc(100vw - 40px);
|
max-width: calc(100vw - 40px);
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.scroller {
|
.scroller {
|
||||||
|
@ -199,4 +202,12 @@ h1 {
|
||||||
.commentbox {
|
.commentbox {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-img {
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
margin-right: 8px;
|
||||||
|
border-radius: 15px;
|
||||||
|
object-fit: cover;
|
||||||
}
|
}
|
|
@ -14,7 +14,12 @@ router.post('/', async (req, res, next) => {
|
||||||
let { username } = res.auth;
|
let { username } = res.auth;
|
||||||
let { post, type, id } = req.body;
|
let { post, type, id } = req.body;
|
||||||
|
|
||||||
if (!username || !post || !id || !type) {
|
if (!username) {
|
||||||
|
apiStat(res, next, 'Log in to chat with the community.')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!post || !id || !type) {
|
||||||
apiStat(res, next, 'Fields are missing.')
|
apiStat(res, next, 'Fields are missing.')
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,11 @@ const aliases = {
|
||||||
const routers = {
|
const routers = {
|
||||||
'/you': './routes/you.js',
|
'/you': './routes/you.js',
|
||||||
'/api/form/you': './routes/youApi.js',
|
'/api/form/you': './routes/youApi.js',
|
||||||
|
'/api/file/you': './routes/youApi.js',
|
||||||
'/api/file/comment': './routes/commenter.js',
|
'/api/file/comment': './routes/commenter.js',
|
||||||
'/walls': './routes/walls.js',
|
'/walls': './routes/walls.js',
|
||||||
'/comment': './routes/comment.js'
|
'/comment': './routes/comment.js',
|
||||||
|
'/users': './routes/user.js'
|
||||||
}
|
}
|
||||||
|
|
||||||
function doAliases(app) {
|
function doAliases(app) {
|
||||||
|
@ -74,14 +76,14 @@ async function auther(req, res, next) {
|
||||||
|
|
||||||
function initr(req, res, next) {
|
function initr(req, res, next) {
|
||||||
let headerCtx = [
|
let headerCtx = [
|
||||||
{ link: '/walls/get/home/0', icon: '/icon.svg', name: 'DervNet' },
|
{ link: '/walls/get/hub/main/0', icon: '/icon.svg', name: 'DervNet' },
|
||||||
{ link: '/walls/list', icon: '/walls.svg', name: 'Explore' },
|
{ link: '/walls/list', icon: '/walls.svg', name: 'Explore' },
|
||||||
{ link: '/you/logout', icon: '/logout.svg', name: 'Leave' } // fix icon
|
{ link: '/you/logout', icon: '/logout.svg', name: 'Leave' } // fix icon
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!res.auth || !res.auth.valid) {
|
if (!res.auth || !res.auth.valid) {
|
||||||
headerCtx = [
|
headerCtx = [
|
||||||
{ link: '/walls/get/home/0', icon: '/icon.svg', name: 'DervNet' },
|
{ link: '/walls/get/hub/main/0', icon: '/icon.svg', name: 'DervNet' },
|
||||||
{ link: '/walls/list', icon: '/walls.svg', name: 'Explore' },
|
{ link: '/walls/list', icon: '/walls.svg', name: 'Explore' },
|
||||||
{ link: '/you/login', icon: '/login.svg', name: 'Log in' },
|
{ link: '/you/login', icon: '/login.svg', name: 'Log in' },
|
||||||
{ link: '/you/new', icon: '/join.svg', name: 'Join' }
|
{ link: '/you/new', icon: '/join.svg', name: 'Join' }
|
||||||
|
|
15
routes/user.js
Normal file
15
routes/user.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import { Router } from "express";
|
||||||
|
const router = Router();
|
||||||
|
|
||||||
|
//todo: fix jank
|
||||||
|
|
||||||
|
router.get('/:username', (req, res, next) => {
|
||||||
|
res.ctx.mainPage = 'user'
|
||||||
|
res.ctx.mainCtx = {
|
||||||
|
username: req.params.username,
|
||||||
|
isYou: res.auth && req.params.username == res.auth.username
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router;
|
|
@ -3,6 +3,7 @@ import { apiStat } from "../lib.js";
|
||||||
import { hash, compare } from "bcrypt";
|
import { hash, compare } from "bcrypt";
|
||||||
import { initDb } from "../db.js";
|
import { initDb } from "../db.js";
|
||||||
import { randomBytes } from 'node:crypto';
|
import { randomBytes } from 'node:crypto';
|
||||||
|
import { rename } from 'node:fs/promises';
|
||||||
|
|
||||||
let db = await initDb();
|
let db = await initDb();
|
||||||
|
|
||||||
|
@ -14,6 +15,21 @@ function legalName(user) {
|
||||||
return user.search(/[^A-Za-z0-9\-\_]/g) == -1;
|
return user.search(/[^A-Za-z0-9\-\_]/g) == -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
router.post('/settings', async (req, res, next) => {
|
||||||
|
let {file} = req;
|
||||||
|
let {username, valid} = res.auth;
|
||||||
|
|
||||||
|
console.log(file)
|
||||||
|
|
||||||
|
if (!valid) return;
|
||||||
|
|
||||||
|
if (file) {
|
||||||
|
await rename(file.path,`./uploads/pfp_${username}.png`);
|
||||||
|
}
|
||||||
|
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
router.post('/logout', (req, res, next) => {
|
router.post('/logout', (req, res, next) => {
|
||||||
res.clearCookie('token');
|
res.clearCookie('token');
|
||||||
apiStat(res, next, `Goodbye!`, '/');
|
apiStat(res, next, `Goodbye!`, '/');
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
<div class='main'>
|
<div class='main'>
|
||||||
<h1 class="header-big">
|
<h1 class="header-big">
|
||||||
<% if (username) { %>
|
<% if (username) { %>
|
||||||
|
<img src="/uploads/pfp_<%= username %>.png" class="avatar-img">
|
||||||
<a class='link' href='/users/<%= username %>'><%= username %></a>
|
<a class='link' href='/users/<%= username %>'><%= username %></a>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
Context
|
Context
|
||||||
<% } %>
|
<% } %>
|
||||||
</h1>
|
</h1>
|
||||||
<% for (let contentN of content) { %>
|
<% for (let contentN of content) { %>
|
||||||
<% if (contentN[0] == 'file' && contentN [1]) { %>
|
<% if (contentN[0] == 'file' && contentN [1]) { %>
|
||||||
<img class='art' src='<%= new URL(contentN[1], 'https://tbg.dervland.net/') %>'>
|
<img class='art' src='<%= new URL(contentN[1], 'https://tbg.dervland.net/') %>'>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<div class='commentbox'><%= contentN[0] %></div>
|
<div class='commentbox'><%= contentN[0] %></div>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if (!isNaN(date * 1)) { %>
|
<% if (!isNaN(date * 1)) { %>
|
||||||
<div class='sub'><b>Posted on</b> <%= new Date(date).toISOString() %> </div>
|
<div class='sub'><b>Posted on</b> <%= new Date(date).toISOString() %> </div>
|
||||||
|
|
23
views/user.ejs
Normal file
23
views/user.ejs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<div class='main'>
|
||||||
|
<h1 class="header-big">
|
||||||
|
<img src="/uploads/pfp_<%= username %>.png" class="avatar-img">
|
||||||
|
<span><%= username %></span>
|
||||||
|
</h1>
|
||||||
|
<span>A very cool person!</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if (isYou) { %>
|
||||||
|
<%- include('form.ejs', {
|
||||||
|
title: "Your Settings",
|
||||||
|
message: 'Configure your profile.',
|
||||||
|
action: "/api/file/you/settings",
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
"key": "Avatar",
|
||||||
|
"type": "file",
|
||||||
|
"name": "file",
|
||||||
|
"default": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}) %>
|
||||||
|
<% } %>
|
Loading…
Reference in a new issue