Comment submission works
I fixed the comment submission to use the new way of storing comments and their counter. I also fixed the AI-consent field in en-US because I accidently had · instead of spaces (from when I copy pasted from vim) Signed-off-by: deadvey <deadvey@deadvey.com>
This commit is contained in:
@@ -1 +1 @@
|
||||
{"hitcount":16,"comment_counter":1}
|
||||
{"hitcount":19}
|
@@ -21,7 +21,7 @@
|
||||
"incorrect_password": "Incorrect Password",
|
||||
"rss_disabled": "Sorry, RSS 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.",
|
||||
"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",
|
||||
"atom_feed": "ATOM Feed",
|
||||
|
@@ -16,23 +16,24 @@ const router = express.Router();
|
||||
////////////////////// Form actions /////////////////////////
|
||||
router.post("/submit_comment", (req,res) => {
|
||||
const unix_timestamp = getUnixTime(new Date())
|
||||
const postID = parseInt(req.body.post_index)
|
||||
const content = func.escape_input(req.body.content)
|
||||
let name = func.escape_input(req.body.name)
|
||||
if (name == "") {
|
||||
name = config.default_commenter_username
|
||||
}
|
||||
|
||||
let comments = data.getdata('comments')
|
||||
|
||||
new_comment = {
|
||||
"name": name,
|
||||
"content": func.escape_input(req.body.content),
|
||||
"id": data.getdata('other_data').comment_counter,
|
||||
"content": content,
|
||||
"id": comments[postID].length,
|
||||
"pubdate": unix_timestamp,
|
||||
"postID": req.body.post_index,
|
||||
"postID": postID,
|
||||
};
|
||||
let other_data = data.getdata('other_data')
|
||||
other_data.comment_counter += 1;
|
||||
let comments = data.getdata('comments')
|
||||
comments[req.body.post_index].push(new_comment);
|
||||
comments[postID].push(new_comment);
|
||||
fs.writeFileSync(`../data/comments.json`, `${JSON.stringify(comments)}`, 'utf-8');
|
||||
fs.writeFileSync('../data/data.json', JSON.stringify(other_data), 'utf-8');
|
||||
|
||||
res.redirect(301,`/post/${req.body.post_index}`)
|
||||
}); // /submit_comment
|
||||
|
Reference in New Issue
Block a user