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

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

View File

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