Comment replies on comment page

There is now a reply form on the comment pages to reply to that comment
Syntax:
>> postID-commentID

Signed-off-by: deadvey <deadvey@deadvey.com>
This commit is contained in:
2025-09-24 17:33:25 +01:00
parent ef7178cc3f
commit e597fd78f7
7 changed files with 27 additions and 6 deletions

View File

@@ -1 +1 @@
{"hitcount":19} {"hitcount":27}

View File

@@ -38,5 +38,6 @@
"posts_tagged": "Posts Tagged", "posts_tagged": "Posts Tagged",
"home_page": "Home Page", "home_page": "Home Page",
"site_index": "Site Index", "site_index": "Site Index",
"reply": "reply",
"attribution": "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>" "attribution": "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"
} }

View File

@@ -38,5 +38,6 @@
"posts_tagged": "Posts Tagged", "posts_tagged": "Posts Tagged",
"home_page": "Home Page", "home_page": "Home Page",
"site_index": "Site Index", "site_index": "Site Index",
"reply": "reply",
"attribution": "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>" "attribution": "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"
} }

View File

@@ -12,6 +12,7 @@
"comment": "Comment", "comment": "Comment",
"submit": "Sumbit", "submit": "Sumbit",
"site_ran_by": "Site is ran by",
"signups_unavailable": "Sorry, this server does not allow signups", "signups_unavailable": "Sorry, this server does not allow signups",
"user_exists": "Sorry, this user already exists, try a different username", "user_exists": "Sorry, this user already exists, try a different username",
"user_doesnt_exist": "Sorry, this user does not exist", "user_doesnt_exist": "Sorry, this user does not exist",
@@ -20,9 +21,11 @@
"incorrect_password": "Incorrect Password", "incorrect_password": "Incorrect Password",
"rss_disabled": "Sorry, RSS is disabled", "rss_disabled": "Sorry, RSS is disabled",
"atom_disabled": "Sorry, ATOM is disabled", "atom_disabled": "Sorry, ATOM is disabled",
"AI_consent": "The content on this website may not be copied, scraped, or used to train AI models or large language models (LLMs) without prior written consent.",
"rss_feed": "RSS Feed", "rss_feed": "RSS Feed",
"atom_feed": "ATOM Feed", "atom_feed": "ATOM Feed",
"no_tags": "No Tags",
"new_post": "New Post", "new_post": "New Post",
"edit_post": "Edit Post", "edit_post": "Edit Post",
"sign_up": "Sign Up", "sign_up": "Sign Up",
@@ -35,5 +38,6 @@
"posts_tagged": "Posts Tagged", "posts_tagged": "Posts Tagged",
"home_page": "Home Page", "home_page": "Home Page",
"site_index": "Site Index", "site_index": "Site Index",
"reply": "reply",
"attribution": "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>" "attribution": "Powered by blogger-nodejs: <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs'>Source Code</a>, <a href='https://git.javalsai.tuxcord.net/deadvey/blogger-nodejs/raw/branch/master/LICENSE'>license (WTFPL)</a>"
} }

View File

@@ -74,6 +74,7 @@ export function get_userID(username) {
// returns a string with some character replaced by their entities // returns a string with some character replaced by their entities
export function escape_input(input) { export function escape_input(input) {
let output = input let output = input
.replaceAll("&", "&amp;") // This must be first
.replaceAll("<", "&lt;") .replaceAll("<", "&lt;")
.replaceAll(">", "&gt;") .replaceAll(">", "&gt;")
.replaceAll("\\", "&#92;") .replaceAll("\\", "&#92;")
@@ -81,18 +82,19 @@ export function escape_input(input) {
.replaceAll("'", "&#39;") .replaceAll("'", "&#39;")
.replaceAll("/", "&#47;") .replaceAll("/", "&#47;")
.replaceAll("%", "&#37;") .replaceAll("%", "&#37;")
.replaceAll("&", "&amp;")
return output return output
} }
// Render comment content by replacing the >> int with a url link to that comment // Render comment content by replacing the >> int with a url link to that comment
export function render_comment(comment_content) { export function render_comment(comment_content) {
console.log(comment_content)
return comment_content return comment_content
.replaceAll(/>> ([0-9]*)/g, "<a href='/comment/$1'>>> $1</a>") .replaceAll(/>> ([0-9]*)-([0-9]*)/g, "<a href='/comment/$1-$2'>>> $1-$2</a>")
.replaceAll(/>>([0-9]*)/g, "<a href='/comment/$1'>>>$1</a>") .replaceAll(/>>([0-9]*)-([0-9]*)/g, "<a href='/comment/$1-$2'>>>$1-$2</a>")
.replaceAll(/&gt;&gt; ([0-9]*)/g, "<a href='/comment/$1'>>> $1</a>") .replaceAll(/&gt;&gt; ([0-9]*)-([0-9]*)/g, "<a href='/comment/$1-$2'>>> $1-$2</a>")
.replaceAll(/&gt;&gt;([0-9]*)/g, "<a href='/comment/$1'>>>$1</a>") .replaceAll(/&gt;&gt;([0-9]*)-([0-9]*)/g, "<a href='/comment/$1-$2'>>>$1-$2</a>")
.replaceAll("\n", "<br/>") .replaceAll("\n", "<br/>")
}; };
export function render_md(content) { export function render_md(content) {
const markdownit = require("markdown-it") const markdownit = require("markdown-it")

View File

@@ -120,6 +120,7 @@ router.get("/comment/:postID-:commentID", (req,res) => {
locale, locale,
comment, comment,
postID, postID,
commentID,
fromUnixTime, fromUnixTime,
format, format,
getUnixTime, getUnixTime,

View File

@@ -10,5 +10,17 @@
<div id="comment"> <div id="comment">
<%- include("../partials/comment"); %> <%- include("../partials/comment"); %>
</div> </div>
<%- config.seperator %>
<b><%= locale.reply %>:</b>
<div id="post-commentform">
<!-- Comment form -->
<form method="POST" action="/submit_comment">
<input type="hidden" name="post_index" value="<%= postID %>">
<label><%= locale.username %>:</label><br/><input name="name"><br/><br/>
<label><%= locale.comment %>:</label><br/><textarea name="content">>> <%- postID %>-<%- commentID %>
</textarea><br/>
<button type="submit"><%= locale.submit %></button>
</form>
</div>
</body> </body>
</html> </html>