data.getdata() is fully implemented

I think it all works now...

Signed-off-by: deadvey <deadvey@deadvey.com>
This commit is contained in:
2025-09-24 19:31:32 +01:00
parent e597fd78f7
commit 22a7983737
10 changed files with 28 additions and 16 deletions

View File

@@ -1 +1 @@
{"hitcount":27}
{"hitcount":37}

View File

@@ -38,19 +38,19 @@ router.get(`${config.edit_account_base_url}/:user_id`, (req,res) => {
res.render("forms/edit_account", {
config,
locale,
user: users[userID],
user: data.getdata('users', userID),
userID
});
}); // /delete_account
router.get(`${config.edit_post_base_url}/:post_id`, (req,res) => {
const post_id = req.params.post_id
const post = posts[post_id]
const user = users[post['userID']]
const postID = req.params.post_id
const post = data.getdata('posts', postID)
const user = data.getdata('users', post.userID)
res.render("forms/edit_post", {
config,
locale,
post,
post_id,
postID,
user,
});
}); // /edit/:post_id

View File

@@ -9,9 +9,9 @@ const router = express.Router();
router.get("/index/pages", (req,res) => {
res.render("indexes/all_pages", {
config,
posts,
users,
comments: comments.comments,
posts: data.getdata('posts'),
users: data.getdata('users'),
comments: data.getdata('comments'),
});
}); // /index/posts
router.get("/index/posts", (req,res) => {

View File

@@ -7,6 +7,8 @@ const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date util
const router = express.Router();
///////////////////// Standard Pages //////////////////////
// Timeline
router.get("/", (req,res) => {
// Increment the hitcount
if (config.enable_hitcount) {
@@ -27,6 +29,8 @@ router.get("/", (req,res) => {
func,
})
}); // /
// Users
router.get("/user/:username", (req, res) => {
const userID = func.get_userID(req.params.username)
let user = data.getdata('users', userID)
@@ -53,6 +57,8 @@ router.get("/user/:username", (req, res) => {
})
}
}); // /user/:username
// Posts
router.get("/post/:post_index", (req, res) => {
const postID = req.params.post_index
let post = data.getdata('posts', postID)
@@ -85,6 +91,7 @@ router.get("/post/:post_index", (req, res) => {
}); // /post/:post_index
// Tags
router.get("/tag/:tag", (req,res) => {
const tag = req.params.tag
res.render("pages/tag",
@@ -101,6 +108,9 @@ router.get("/tag/:tag", (req,res) => {
func,
})
}); // /tag/:tag
// Comments
router.get("/comment/:postID-:commentID", (req,res) => {
const commentID = req.params.commentID;
const postID = req.params.postID;

View File

@@ -3,6 +3,8 @@ const config = require('../../config')
const data = require('../data')
const func = require('../functions')
const { fromUnixTime, format, getUnixTime } = require("date-fns") // A date utility library
const router = express.Router();
////////////////////// SYNDICATION ////////////////////////

View File

@@ -6,7 +6,7 @@
<body>
<form action="/submit_edit_post" method="POST" onsubmit="sha512password()">
<input name="userID" type="hidden" value="<%= post['userID'] %>">
<input name="postID" type="hidden" value="<%= post_id %>">
<input name="postID" type="hidden" value="<%= postID %>">
<label><%= locale.password %>:</label><br/>
<input type="password" required id="password" name="password"><br/><br/>

View File

@@ -1,7 +1,7 @@
<h1>
<%= user.prettyname %>
</h1>
<p><%# func.render_md(user.description) %></p>
<p><%- func.render_md(user.description) %></p>
<a href="<%= config.edit_account_base_url %>/<%= userID %>"><%= locale.edit_account %></a><br/>
<a href="/user/<%= user.username %>/rss"><%= locale.rss_feed %></a><br/>
<a href="/user/<%= user.username %>/atom"><%= locale.atom_feed %></a>

View File

@@ -21,7 +21,7 @@
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/>
<a href="/comment/<%= postID %>-<%= comment_index %>"><%= postID %>-<%= comment_index %></a><br/>
<% }; %>
<% }; %>
Users:<br/>
@@ -33,13 +33,13 @@
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/>
<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/>
<a href="<%= config.edit_account_base_url %>/<%= users[userID]["username"] %>">Edit <%= users[userID]["username"] %></a><br/>
<% }; %>
<% }; %>
<!-- TODO add tags -->

View File

@@ -6,7 +6,7 @@
<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/>
<a href="/comment/<%= postID %>-<%= comment_index %>"><%= postID %>-<%= comment_index %></a><br/>
<% }; %>
<% }; %>
</body>

View File

@@ -13,7 +13,7 @@
<% if ( posts[index].deleted != true) { %>
<% posts[index].tags.forEach((current_tag, tag_index) => { %>
<% if (current_tag == tag) { %>
<%- include('../posts/tag', {post: posts[index], user: users[posts[index].userID], comments: comments[index]}); %>
<%- include('../posts/tag', {post: posts[index], postID: index, user: users[posts[index].userID], comments: comments[index]}); %>
<% } %>
<% }) %>
<% } %>