comments and captcha stuff
This commit is contained in:
parent
afdf5f8d43
commit
80c0ec9056
8 changed files with 25 additions and 28 deletions
|
@ -9,7 +9,7 @@ let main = new Route([auth], async function (req, res, input) {
|
||||||
let {id} = req.query;
|
let {id} = req.query;
|
||||||
let { username } = input;
|
let { username } = input;
|
||||||
|
|
||||||
let comments = await db.all('SELECT * FROM comment WHERE targetType = ? AND targetId = ?', [
|
let comments = await db.all('SELECT * FROM comment WHERE targetType = ? AND targetId = ? ORDER BY date DESC', [
|
||||||
route,
|
route,
|
||||||
id
|
id
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -2,16 +2,11 @@ import Route from "../route.js";
|
||||||
import initDb from "../db.js";
|
import initDb from "../db.js";
|
||||||
import { randomUUID } from 'node:crypto';
|
import { randomUUID } from 'node:crypto';
|
||||||
import auth from "../form/auth.js";
|
import auth from "../form/auth.js";
|
||||||
import captcha from "./captcha.js";
|
|
||||||
|
|
||||||
let db = await initDb();
|
let db = await initDb();
|
||||||
|
|
||||||
// TODO: rewrite
|
// TODO: rewrite
|
||||||
let main = new Route([auth,captcha], async function (req, res, input) {
|
let main = new Route([auth], async function (req, res, input) {
|
||||||
let { captchaMatch} = input;
|
|
||||||
|
|
||||||
if (!captchaMatch) return { 'success': false, 'message': 'Captcha is incorrect' };
|
|
||||||
|
|
||||||
let { username } = input;
|
let { username } = input;
|
||||||
let id = randomUUID();
|
let id = randomUUID();
|
||||||
|
|
||||||
|
@ -28,7 +23,7 @@ let main = new Route([auth,captcha], async function (req, res, input) {
|
||||||
id
|
id
|
||||||
]);
|
]);
|
||||||
|
|
||||||
res.send({ redir: `?` });
|
res.send({ 'message': 'Comment sent', redirect: `/client/${targetType}?id=${targetId}` });
|
||||||
});
|
});
|
||||||
|
|
||||||
export default main;
|
export default main;
|
|
@ -1,6 +1,5 @@
|
||||||
import Route from "../route.js";
|
import Route from "../route.js";
|
||||||
import initDb from "../db.js";
|
import initDb from "../db.js";
|
||||||
import { randomUUID } from 'node:crypto';
|
|
||||||
import auth from "../form/auth.js";
|
import auth from "../form/auth.js";
|
||||||
|
|
||||||
let db = await initDb();
|
let db = await initDb();
|
||||||
|
|
|
@ -170,7 +170,8 @@ body {
|
||||||
|
|
||||||
.progressbar,
|
.progressbar,
|
||||||
.progressbar-div,
|
.progressbar-div,
|
||||||
.avatar-img {
|
.avatar-img,
|
||||||
|
.captcha {
|
||||||
border-radius: var(--border-radius)
|
border-radius: var(--border-radius)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<%- include('form_bare.ejs', { data: [ { label: "" , type: "text" , name: "targetId" , hidden: id }, { label: "" ,
|
<%- include('form_bare.ejs', { data: [ { label: "" , type: "text" , name: "targetId" , hidden: id }, { label: "" ,
|
||||||
type: "text" , name: "targetType" , hidden: route }, { label: "Your thoughts..." , type: "textarea" ,
|
type: "text" , name: "targetType" , hidden: route }, { label: "Your thoughts..." , type: "textarea" ,
|
||||||
name: "content" , hidden: route }, ], 'route' : '/api/form/comment' , 'title' : 'Comments' , }) -%>
|
name: "content" , hidden: route }, ], 'route' : '/api/form/comment' , 'title' : 'Comments' , noCaptcha: true })
|
||||||
|
-%>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<% for (let comment of comments) { %>
|
<% for (let comment of comments) { %>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<%- include('header.ejs') -%>
|
<%- include('header.ejs') -%>
|
||||||
<%- include('form_bare.ejs') -%>
|
<%- include('form_bare.ejs', {noCaptcha: false}) -%>
|
||||||
<%- include('footer.ejs') -%>
|
<%- include('footer.ejs') -%>
|
|
@ -3,10 +3,12 @@
|
||||||
<%= title %>
|
<%= title %>
|
||||||
</h1>
|
</h1>
|
||||||
<div class='form-message'></div>
|
<div class='form-message'></div>
|
||||||
|
<% if (!noCaptcha) { %>
|
||||||
<span class='form-key'>
|
<span class='form-key'>
|
||||||
<img src='/client/captcha'>
|
<img class='captcha' src='/client/captcha'>
|
||||||
</span>
|
</span>
|
||||||
<input class='form-input' type='text' name='challenger' value='Type the captcha'>
|
<input class='form-input' type='text' name='challenger' value='Type the captcha'>
|
||||||
|
<% } %>
|
||||||
<% for (let elem of data) { %>
|
<% for (let elem of data) { %>
|
||||||
<span class='form-key'>
|
<span class='form-key'>
|
||||||
<%= elem.label %>
|
<%= elem.label %>
|
||||||
|
@ -14,8 +16,8 @@
|
||||||
<% if (elem.type=='textarea' ) { %>
|
<% if (elem.type=='textarea' ) { %>
|
||||||
<textarea class='form-input' name='<%= elem.name %>'></textarea>
|
<textarea class='form-input' name='<%= elem.name %>'></textarea>
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<input class='form-input' type='<%= elem.type %>' name='<%= elem.name %>' value='<%= elem.hidden %>'
|
<input class='form-input' type='<%= elem.type %>' name='<%= elem.name %>'
|
||||||
<%=elem.hidden ? 'hidden ' : '' %>>
|
value='<%= elem.hidden %>' <%=elem.hidden ? 'hidden ' : '' %>>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
<input class='form-button' type='Submit' name='Submit'>
|
<input class='form-button' type='Submit' name='Submit'>
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
<div class='banner'><img class='banner-background' src='/static/img/bg.svg'>
|
<div class='banner'><img class='banner-background' src='/static/img/bg.svg'>
|
||||||
<div class='banner-content'>
|
<div class='banner-content'>
|
||||||
<h1>BiglyChat</h1>
|
<h1>BiglyChat</h1>
|
||||||
<p>BiglyChat is a niche community for broadcasting videos to your fanbase, with integrated games and active
|
<p>BiglyChat is a niche community for broadcasting videos to your fanbase.</p>
|
||||||
developers.</p>
|
|
||||||
<h2>Community</h2>
|
<h2>Community</h2>
|
||||||
<%if (username=='!nobody' ) { %>
|
<%if (username=='!nobody' ) { %>
|
||||||
<a class='form-button' href="/client/register">Join the Community</a>
|
<a class='form-button' href="/client/register">Join the Community</a>
|
||||||
|
|
Loading…
Reference in a new issue