From 00c509d0ec5cd9c10f11749f069abc72c1b72848 Mon Sep 17 00:00:00 2001 From: Akif9748 Date: Fri, 16 Sep 2022 21:57:27 +0300 Subject: [PATCH] Added markdown editor --- README.md | 7 +++++-- public/js/thread.js | 4 ++-- routes/threads.js | 6 ++---- views/thread.ejs | 32 +++++++++++++++++++------------- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index fbe7b8c..086f178 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,14 @@ Akf-forum has got an API for AJAX (fetch), other clients etc. And, you can learn | To do | Is done? | Priority | | ----- | -------- | -------- | | Profile Message | 🟡 | LOW | -| IPs of users will add SecretModel | ⚪ | MEDIUM | +| IPs of users will add UserModel with select- | ⚪ | MEDIUM | | Better Auth | ⚪ | MEDIUM | +- mod role, permissions - Fix footer, theme, category pages - upload other photos, model for it - +- category system bloat. +- replace not found errors with no perm +- prewiev for send messages in markdown format. ## Major Version History - V4: Caching - V3: New Theme diff --git a/public/js/thread.js b/public/js/thread.js index 1ea48c0..5f4b5b6 100644 --- a/public/js/thread.js +++ b/public/js/thread.js @@ -33,13 +33,13 @@ window.send_edit = async function (id) { const res = await request(`/api/messages/${id}/`, "PATCH", { content }); if (res.error) return; alert(`Message updated`); - message.querySelector(".content").innerHTML = res.content; + message.querySelector(".content").innerHTML = converter.makeHtml(res.content); } window.edit_message = async function (id) { const content = document.getElementById(`message-${id}`).querySelector(".content"); content.innerHTML = ` - + `; } diff --git a/routes/threads.js b/routes/threads.js index f8a9010..084bb90 100644 --- a/routes/threads.js +++ b/routes/threads.js @@ -30,10 +30,8 @@ app.get("/:id/", async (req, res) => { if (!user || !user.admin) query.deleted = false; const messages = await Promise.all(await MessageModel.find(query).sort({ time: 1 }).limit(10).skip(page * 10) - .then(messages => messages.map(async message => { - message.content = clearContent(message.content) - return await message.get_author(); - }))); + .then(messages => messages.map(message => message.get_author()))); + res.reply("thread", { page, thread, messages, scroll: req.query.scroll || messages[0]?.id }); thread.save(); diff --git a/views/thread.ejs b/views/thread.ejs index 1c2de28..5e3fe45 100644 --- a/views/thread.ejs +++ b/views/thread.ejs @@ -6,14 +6,13 @@ <%- include("extra/navbar") %> + + - <% if (user){ %> - - <% }; %>
<%= thread.title %>
@@ -52,7 +51,7 @@
-
<%- message.content %>
+
<%= message.content %>
<% if(user){ %> <% if(user.id === message.authorID || user.admin){ %> @@ -92,7 +91,22 @@ <% }); %> + + + <% if (user){ %> +
@@ -121,7 +135,7 @@ let tp = Number("<%= thread.pages %>") let tm = Number("<%= thread.count %>") if (tp * 10 === tm) tp++; - if (res) location.href = `/threads/${data.get("threadID")}?page=${tp-1}`; + if (res) location.href = `/threads/<%= thread.id %>?page=${tp-1}`; }); @@ -148,14 +162,6 @@
- - \ No newline at end of file