From 8b9ddcf048e7d589643578c77e0e01a3a367812a Mon Sep 17 00:00:00 2001 From: DeaDvey Date: Sat, 2 Aug 2025 00:51:33 +0100 Subject: [PATCH] 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... --- README.md | 2 ++ src/server.js | 28 +++++++++++++++++++++++ views/indexes/all_pages.ejs | 45 +++++++++++++++++++++++++++++++++++++ views/indexes/comments.ejs | 13 +++++++++++ views/indexes/posts.ejs | 13 +++++++++++ views/indexes/users.ejs | 13 +++++++++++ views/pages/tag.ejs | 1 + 7 files changed, 115 insertions(+) create mode 100644 views/indexes/all_pages.ejs create mode 100644 views/indexes/comments.ejs create mode 100644 views/indexes/posts.ejs create mode 100644 views/indexes/users.ejs diff --git a/README.md b/README.md index 370df42..8462222 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/server.js b/src/server.js index 6881ddb..8994821 100644 --- a/src/server.js +++ b/src/server.js @@ -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) => { diff --git a/views/indexes/all_pages.ejs b/views/indexes/all_pages.ejs new file mode 100644 index 0000000..37dac60 --- /dev/null +++ b/views/indexes/all_pages.ejs @@ -0,0 +1,45 @@ + + + + <%- include("../partials/head") %> + + + Misc:
+ Home Page
+ Posts Index
+ Users Index
+ Comments Index
+ New Post Form
+ Signup Form
+ Posts:
+ <% for (let postID = 0; postID < posts.length; postID++) { %> + <% if (posts[postID]["deleted"] != true) { %> + <%= posts[postID]["title"] %>
+ <% }; %> + <% }; %> + Comments:
+ <% for (let postID = 0; postID < comments.length; postID++) { %> + <% for (let comment_index = 0; comment_index < comments[postID].length; comment_index++) { %> + "><%= comments[postID][comment_index]["id"] %>
+ <% }; %> + <% }; %> + Users:
+ <% for (let userID = 0; userID < users.length; userID++) { %> + <% if (users[userID]["deleted"] != true) { %> + "><%= users[userID]["username"] %>
+ <% }; %> + <% }; %> + Edit Posts:
+ <% for (let postID = 0; postID < posts.length; postID++) { %> + <% if (posts[postID]["deleted"] != true) { %> + Edit <%= posts[postID]["title"] %>
+ <% }; %> + <% }; %> + Edit Users:
+ <% for (let userID = 0; userID < users.length; userID++) { %> + <% if (users[userID]["deleted"] != true) { %> + ">Edit <%= users[userID]["username"] %>
+ <% }; %> + <% }; %> + + diff --git a/views/indexes/comments.ejs b/views/indexes/comments.ejs new file mode 100644 index 0000000..15846e4 --- /dev/null +++ b/views/indexes/comments.ejs @@ -0,0 +1,13 @@ + + + + <%- include("../partials/head") %> + + + <% for (let postID = 0; postID < comments.length; postID++) { %> + <% for (let comment_index = 0; comment_index < comments[postID].length; comment_index++) { %> + "><%= comments[postID][comment_index]["id"] %>
+ <% }; %> + <% }; %> + + diff --git a/views/indexes/posts.ejs b/views/indexes/posts.ejs new file mode 100644 index 0000000..f38db27 --- /dev/null +++ b/views/indexes/posts.ejs @@ -0,0 +1,13 @@ + + + + <%- include("../partials/head") %> + + + <% for (let postID = 0; postID < posts.length; postID++) { %> + <% if (posts[postID]["deleted"] != true) { %> + <%= posts[postID]["title"] %>
+ <% }; %> + <% }; %> + + diff --git a/views/indexes/users.ejs b/views/indexes/users.ejs new file mode 100644 index 0000000..503e222 --- /dev/null +++ b/views/indexes/users.ejs @@ -0,0 +1,13 @@ + + + + <%- include("../partials/head") %> + + + <% for (let userID = 0; userID < users.length; userID++) { %> + <% if (users[userID]["deleted"] != true) { %> + "><%= users[userID]["username"] %>
+ <% }; %> + <% }; %> + + diff --git a/views/pages/tag.ejs b/views/pages/tag.ejs index fc54ed8..9033241 100644 --- a/views/pages/tag.ejs +++ b/views/pages/tag.ejs @@ -5,6 +5,7 @@