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 { 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,
|
||||
id
|
||||
]);
|
||||
|
|
|
@ -2,16 +2,11 @@ import Route from "../route.js";
|
|||
import initDb from "../db.js";
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import auth from "../form/auth.js";
|
||||
import captcha from "./captcha.js";
|
||||
|
||||
let db = await initDb();
|
||||
|
||||
// TODO: rewrite
|
||||
let main = new Route([auth,captcha], async function (req, res, input) {
|
||||
let { captchaMatch} = input;
|
||||
|
||||
if (!captchaMatch) return { 'success': false, 'message': 'Captcha is incorrect' };
|
||||
|
||||
let main = new Route([auth], async function (req, res, input) {
|
||||
let { username } = input;
|
||||
let id = randomUUID();
|
||||
|
||||
|
@ -28,7 +23,7 @@ let main = new Route([auth,captcha], async function (req, res, input) {
|
|||
id
|
||||
]);
|
||||
|
||||
res.send({ redir: `?` });
|
||||
res.send({ 'message': 'Comment sent', redirect: `/client/${targetType}?id=${targetId}` });
|
||||
});
|
||||
|
||||
export default main;
|
|
@ -1,6 +1,5 @@
|
|||
import Route from "../route.js";
|
||||
import initDb from "../db.js";
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import auth from "../form/auth.js";
|
||||
|
||||
let db = await initDb();
|
||||
|
|
|
@ -170,7 +170,8 @@ body {
|
|||
|
||||
.progressbar,
|
||||
.progressbar-div,
|
||||
.avatar-img {
|
||||
.avatar-img,
|
||||
.captcha {
|
||||
border-radius: var(--border-radius)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<%- include('form_bare.ejs', { data: [ { label: "" , type: "text" , name: "targetId" , hidden: id }, { label: "" ,
|
||||
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">
|
||||
<% for (let comment of comments) { %>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<%- include('header.ejs') -%>
|
||||
<%- include('form_bare.ejs') -%>
|
||||
<%- include('form_bare.ejs', {noCaptcha: false}) -%>
|
||||
<%- include('footer.ejs') -%>
|
|
@ -3,10 +3,12 @@
|
|||
<%= title %>
|
||||
</h1>
|
||||
<div class='form-message'></div>
|
||||
<% if (!noCaptcha) { %>
|
||||
<span class='form-key'>
|
||||
<img src='/client/captcha'>
|
||||
<img class='captcha' src='/client/captcha'>
|
||||
</span>
|
||||
<input class='form-input' type='text' name='challenger' value='Type the captcha'>
|
||||
<% } %>
|
||||
<% for (let elem of data) { %>
|
||||
<span class='form-key'>
|
||||
<%= elem.label %>
|
||||
|
@ -14,8 +16,8 @@
|
|||
<% if (elem.type=='textarea' ) { %>
|
||||
<textarea class='form-input' name='<%= elem.name %>'></textarea>
|
||||
<% } else { %>
|
||||
<input class='form-input' type='<%= elem.type %>' name='<%= elem.name %>' value='<%= elem.hidden %>'
|
||||
<%=elem.hidden ? 'hidden ' : '' %>>
|
||||
<input class='form-input' type='<%= elem.type %>' name='<%= elem.name %>'
|
||||
value='<%= elem.hidden %>' <%=elem.hidden ? 'hidden ' : '' %>>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<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-content'>
|
||||
<h1>BiglyChat</h1>
|
||||
<p>BiglyChat is a niche community for broadcasting videos to your fanbase, with integrated games and active
|
||||
developers.</p>
|
||||
<p>BiglyChat is a niche community for broadcasting videos to your fanbase.</p>
|
||||
<h2>Community</h2>
|
||||
<%if (username=='!nobody' ) { %>
|
||||
<a class='form-button' href="/client/register">Join the Community</a>
|
||||
|
|
Loading…
Reference in a new issue