Compare commits

...

3 Commits

Author SHA1 Message Date
8b9ddcf048 Added page indexes for comments, posts, users and pages overall, should
add one for tags but it might be inefficient as I don't store all tags
in an array or anything...
2025-08-02 00:51:33 +01:00
5f2aba0c2b Site wide header (currently only used for a link to / but will add
index's for stuff later)
2025-08-01 23:27:28 +01:00
cdfc5f2c30 Post doesn't exist page 2025-08-01 23:21:43 +01:00
15 changed files with 164 additions and 23 deletions

View File

@@ -23,6 +23,7 @@ Read the [configuation guide](docs/CONFIG.md) for configuration help (in config.
* Markdown syntax in posts
* Commenting on posts and replying to other comments
* site wide custom CSS
* Page indexes
# Bugs
* probably scales like shit
@@ -37,6 +38,7 @@ Read the [configuation guide](docs/CONFIG.md) for configuration help (in config.
* /postID and /userID pages
* site index
* Make EJS modification more user friendly
* API for returning posts, users, comments, tags other?...
TODO (not finished)
# EJS variable names

View File

@@ -25,6 +25,7 @@
"user_exists": "Sorry, this user already exists, try a different username",
"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",
"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",
"rss_disabled": "Sorry, RSS is disabled",

View File

@@ -9,7 +9,7 @@
"timeline_length": 20,
"enable_hitcount": true,
"charset": "UTF-8",
"root_path": "/path/to/blogger-webroot",
"root_path": "/path/to/webroot",
"edit_account_base_url": "/edit_account",
"new_post_url": "/post",
"signup_url": "/signup",
@@ -25,7 +25,8 @@
"user_exists": "Sorry, this user already exists, try a different username",
"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",
"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",
"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>"

View File

@@ -141,6 +141,34 @@ app.get("/user/:username/atom", (req,res) => {
};
});
///////////////////// Page index's ///////////////////////
app.get("/index/pages", (req,res) => {
res.render("indexes/all_pages", {
config,
posts,
users,
comments: comments.comments,
});
}); // /index/posts
app.get("/index/posts", (req,res) => {
res.render("indexes/posts", {
config,
posts,
});
}); // /index/posts
app.get("/index/users", (req,res) => {
res.render("indexes/users", {
config,
users,
});
}); // /index/posts
app.get("/index/comments", (req,res) => {
res.render("indexes/comments", {
config,
comments: comments.comments,
});
}); // /index/posts
///////////////////// Standard Pages //////////////////////
app.get("/", (req,res) => {
@@ -186,19 +214,31 @@ app.get("/user/:username", (req, res) => {
}); // /user/:username
app.get("/post/:post_index", (req, res) => {
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,
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
app.get("/tag/:tag", (req,res) => {
const tag = req.params.tag
@@ -431,15 +471,15 @@ app.post("/submit_edit_user", (req,res) => {
}
}); // /submit_delete_account
app.post("/submit_edit_post", (req,res) => {
const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
const postID = req.body.postID
const userID = req.body.userID
const title = req.body.title
const content = req.body.content
const tags = req.body.tags.split(',');
const delete_bool = req.body.delete
const unix_timestamp = getUnixTime(new Date())
console.log(users[userID]['prettyname'], "is editting the post titled:", title);
const password = crypto.createHash('sha512').update(req.body.password).digest('hex');
const postID = req.body.postID
const userID = req.body.userID
const title = req.body.title
const content = req.body.content
const tags = req.body.tags.split(',');
const delete_bool = req.body.delete
const unix_timestamp = getUnixTime(new Date())
console.log(users[userID]['prettyname'], "is editting the post titled:", title);
if (users[userID]['hash'] == password) { // password matches
let post = posts[postID]

View File

@@ -0,0 +1 @@
<a href="/">Home Page</a><br/>

View File

@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="<%= config.charset %>">
<head>
<%- include("../partials/head") %>
</head>
<body>
Misc:<br/>
<a href="/">Home Page</a><br/>
<a href="/index/posts">Posts Index</a><br/>
<a href="/index/users">Users Index</a><br/>
<a href="/index/comments">Comments Index</a><br/>
<a href="<%= config.new_post_url %>">New Post Form</a><br/>
<a href="<%= config.signup_url %>">Signup Form</a><br/>
Posts:<br/>
<% for (let postID = 0; postID < posts.length; postID++) { %>
<% if (posts[postID]["deleted"] != true) { %>
<a href="/post/<%= postID %>"><%= posts[postID]["title"] %></a><br/>
<% }; %>
<% }; %>
Comments:<br/>
<% for (let postID = 0; postID < comments.length; postID++) { %>
<% for (let comment_index = 0; comment_index < comments[postID].length; comment_index++) { %>
<a href="/comment/<%= comments[postID][comment_index]["id"] %>"><%= comments[postID][comment_index]["id"] %></a><br/>
<% }; %>
<% }; %>
Users:<br/>
<% for (let userID = 0; userID < users.length; userID++) { %>
<% if (users[userID]["deleted"] != true) { %>
<a href="/user/<%= users[userID]["username"] %>"><%= users[userID]["username"] %></a><br/>
<% }; %>
<% }; %>
Edit Posts:<br/>
<% for (let postID = 0; postID < posts.length; postID++) { %>
<% if (posts[postID]["deleted"] != true) { %>
<a href="/<%= config.edit_post_base_url %>/<%= postID %>">Edit <%= posts[postID]["title"] %></a><br/>
<% }; %>
<% }; %>
Edit Users:<br/>
<% for (let userID = 0; userID < users.length; userID++) { %>
<% if (users[userID]["deleted"] != true) { %>
<a href="/<%= config.edit_account_base_url %>/<%= users[userID]["username"] %>">Edit <%= users[userID]["username"] %></a><br/>
<% }; %>
<% }; %>
</body>
</html>

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="<%= config.charset %>">
<head>
<%- include("../partials/head") %>
</head>
<body>
<% for (let postID = 0; postID < comments.length; postID++) { %>
<% for (let comment_index = 0; comment_index < comments[postID].length; comment_index++) { %>
<a href="/comment/<%= comments[postID][comment_index]["id"] %>"><%= comments[postID][comment_index]["id"] %></a><br/>
<% }; %>
<% }; %>
</body>
</html>

13
views/indexes/posts.ejs Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="<%= config.charset %>">
<head>
<%- include("../partials/head") %>
</head>
<body>
<% for (let postID = 0; postID < posts.length; postID++) { %>
<% if (posts[postID]["deleted"] != true) { %>
<a href="/post/<%= postID %>"><%= posts[postID]["title"] %></a><br/>
<% }; %>
<% }; %>
</body>
</html>

13
views/indexes/users.ejs Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="<%= config.charset %>">
<head>
<%- include("../partials/head") %>
</head>
<body>
<% for (let userID = 0; userID < users.length; userID++) { %>
<% if (users[userID]["deleted"] != true) { %>
<a href="/user/<%= users[userID]["username"] %>"><%= users[userID]["username"] %></a><br/>
<% }; %>
<% }; %>
</body>
</html>

View File

@@ -4,6 +4,9 @@
<%- include('../partials/head'); %>
</head>
<body>
<div id="header">
<%- include("../headers/site_wide") %>
</div>
<div id="comment">
<%- include("../partials/comment"); %>
</div>

View File

@@ -4,6 +4,9 @@
<%- include('../partials/head'); %>
</head>
<body>
<div id="header">
<%- include("../headers/site_wide") %>
</div>
<div id="posts">
<%- include('../posts/post'); %>
</div>

View File

@@ -5,6 +5,7 @@
</head>
<body>
<div id="header">
<%- include('../headers/site_wide'); %>
<%- include('../headers/tag'); %>
</div>
<div id="posts">

View File

@@ -5,6 +5,7 @@
</head>
<body>
<div id="header">
<%- include("../headers/site_wide") %>
<%- include('../headers/timeline'); %>
</div>
<div id="posts">

View File

@@ -5,6 +5,7 @@
</head>
<body>
<div id="header">
<%- include("../headers/site_wide") %>
<%- include('../headers/user'); %>
</div>
<div id="posts">

View File

@@ -1,9 +1,12 @@
<!DOCTYPE html>
<html lang="<%=config.language%>
<html lang="<%= config.language %>">
<head>
<%- include('head') %>
</head>
<body>
<div id="header">
<%- include("../headers/site_wide") %>
</div>
<%- message %>
</body>
</html>