Post doesn't exist page

This commit is contained in:
2025-08-01 23:21:43 +01:00
parent 88b198365d
commit cdfc5f2c30
3 changed files with 36 additions and 22 deletions

View File

@@ -25,6 +25,7 @@
"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",
"comment_doesnt_exist": "This comment doesn't exist, this could be because the post it was attached to was deleted", "comment_doesnt_exist": "This comment doesn't exist, this could be because the post it was attached to was deleted",
"post_doesnt_exist": "This post doesn't exist or was deleted",
"delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)", "delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)",
"incorrect_password": "Incorrect Password", "incorrect_password": "Incorrect Password",
"rss_disabled": "Sorry, RSS is disabled", "rss_disabled": "Sorry, RSS is disabled",

View File

@@ -9,7 +9,7 @@
"timeline_length": 20, "timeline_length": 20,
"enable_hitcount": true, "enable_hitcount": true,
"charset": "UTF-8", "charset": "UTF-8",
"root_path": "/path/to/blogger-webroot", "root_path": "/path/to/webroot",
"edit_account_base_url": "/edit_account", "edit_account_base_url": "/edit_account",
"new_post_url": "/post", "new_post_url": "/post",
"signup_url": "/signup", "signup_url": "/signup",
@@ -25,7 +25,8 @@
"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",
"comment_doesnt_exist": "This comment doesn't exist, this could be because the post it was attached to was deleted", "comment_doesnt_exist": "This comment doesn't exist, this could be because the post it was attached to was deleted",
"delete_account_confirmation": "I agree that my account and all of my posts will be permanently deleted instantly", "post_doesnt_exist": "This post doesn't exist or was deleted",
"delete_account_confirmation": "Delete my account - (I agree that my account and all of my posts will be permanently deleted instantly)",
"incorrect_password": "Incorrect Password", "incorrect_password": "Incorrect Password",
"rss_disabled": "Sorry, RSS is disabled", "rss_disabled": "Sorry, RSS is disabled",
"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

@@ -186,19 +186,31 @@ app.get("/user/:username", (req, res) => {
}); // /user/:username }); // /user/:username
app.get("/post/:post_index", (req, res) => { app.get("/post/:post_index", (req, res) => {
const postID = req.params.post_index const postID = req.params.post_index
res.render("pages/post", if (posts[postID]["deleted"] == true) {
{ res.render("partials/message", {
message: config.string.post_doesnt_exist,
config, config,
post: posts[postID],
postID: postID,
user: users[posts[postID].userID],
comments: comments.comments[postID],
fromUnixTime,
format,
getUnixTime,
func,
converter,
}) })
}
else if (typeof posts[postID]["deleted"] == "undefined" || posts[postID]["deleted"] == false) {
res.render("pages/post",
{
config,
post: posts[postID],
postID: postID,
user: users[posts[postID].userID],
comments: comments.comments[postID],
fromUnixTime,
format,
getUnixTime,
func,
converter,
})
}
else {
console.log("Error loading page")
res.redirect(301,"/")
}
}); // /post/:post_index }); // /post/:post_index
app.get("/tag/:tag", (req,res) => { app.get("/tag/:tag", (req,res) => {
const tag = req.params.tag const tag = req.params.tag
@@ -431,15 +443,15 @@ app.post("/submit_edit_user", (req,res) => {
} }
}); // /submit_delete_account }); // /submit_delete_account
app.post("/submit_edit_post", (req,res) => { app.post("/submit_edit_post", (req,res) => {
const password = crypto.createHash('sha512').update(req.body.password).digest('hex'); const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
const postID = req.body.postID const postID = req.body.postID
const userID = req.body.userID const userID = req.body.userID
const title = req.body.title const title = req.body.title
const content = req.body.content const content = req.body.content
const tags = req.body.tags.split(','); const tags = req.body.tags.split(',');
const delete_bool = req.body.delete const delete_bool = req.body.delete
const unix_timestamp = getUnixTime(new Date()) const unix_timestamp = getUnixTime(new Date())
console.log(users[userID]['prettyname'], "is editting the post titled:", title); console.log(users[userID]['prettyname'], "is editting the post titled:", title);
if (users[userID]['hash'] == password) { // password matches if (users[userID]['hash'] == password) { // password matches
let post = posts[postID] let post = posts[postID]