diff --git a/client/comment.js b/client/comment.js index 4aef341..ba53870 100644 --- a/client/comment.js +++ b/client/comment.js @@ -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 ]); diff --git a/form/comment.js b/form/comment.js index f062b97..bbd1304 100644 --- a/form/comment.js +++ b/form/comment.js @@ -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; \ No newline at end of file diff --git a/form/delete_video.js b/form/delete_video.js index 71d98e6..e483db9 100644 --- a/form/delete_video.js +++ b/form/delete_video.js @@ -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(); diff --git a/static/main.css b/static/main.css index ae92813..bf76f30 100644 --- a/static/main.css +++ b/static/main.css @@ -170,7 +170,8 @@ body { .progressbar, .progressbar-div, -.avatar-img { +.avatar-img, +.captcha { border-radius: var(--border-radius) } diff --git a/views/comments.ejs b/views/comments.ejs index 4e216cc..d9ac2f4 100644 --- a/views/comments.ejs +++ b/views/comments.ejs @@ -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 }) + -%>
<% for (let comment of comments) { %> diff --git a/views/form.ejs b/views/form.ejs index 1303e71..a21e2dd 100644 --- a/views/form.ejs +++ b/views/form.ejs @@ -1,3 +1,3 @@ <%- include('header.ejs') -%> - <%- include('form_bare.ejs') -%> + <%- include('form_bare.ejs', {noCaptcha: false}) -%> <%- include('footer.ejs') -%> \ No newline at end of file diff --git a/views/form_bare.ejs b/views/form_bare.ejs index 9db2eec..3d4980a 100644 --- a/views/form_bare.ejs +++ b/views/form_bare.ejs @@ -3,20 +3,22 @@ <%= title %>
- - - - - <% for (let elem of data) { %> + <% if (!noCaptcha) { %> - <%= elem.label %> + - <% if (elem.type=='textarea' ) { %> - - <% } else { %> - > - <% } %> - <% } %> - + + <% } %> + <% for (let elem of data) { %> + + <%= elem.label %> + + <% if (elem.type=='textarea' ) { %> + + <% } else { %> + > + <% } %> + <% } %> + \ No newline at end of file diff --git a/views/main.ejs b/views/main.ejs index 99c781c..3c5e989 100644 --- a/views/main.ejs +++ b/views/main.ejs @@ -2,8 +2,7 @@