changed how data is read from the database and consolodated syndation feeds into just 2 files.

This commit is contained in:
2026-06-01 13:53:58 +01:00
parent 1a0b16feb2
commit 5a14b125d2
7 changed files with 82 additions and 41 deletions
+7 -6
View File
@@ -33,16 +33,17 @@ router.get(config.site_path, (req,res) => {
// Users
router.get(`${config.site_path}/user/:username`, (req, res) => {
const userID = func.get_userID(req.params.username)
let user = data.getdata('users', 'id', userID)
let posts = data.getdata('posts', 'userID', userID);
let user = data.getdata('users', 'id', userID)[0];
if (userID != -1) {
res.render("pages/user",
{
config,
locale,
posts: data.getdata('posts'),
posts,
user,
userID: userID,
comments: data.getdata('comments'),
comments: data.getdata('comments', 'postID'),
fromUnixTime,
format,
getUnixTime,
@@ -61,7 +62,7 @@ router.get(`${config.site_path}/user/:username`, (req, res) => {
// Posts
router.get(`${config.site_path}/post/:post_index`, (req, res) => {
const postID = parseInt(req.params.post_index)
let post = data.getdata('posts','id', postID)
let post = data.getdata('posts','id', postID)[0]
if (post == 1) { // data.getdata returns error code 1 if nothing is available
res.render("partials/message", {
message: locale.post_doesnt_exist,
@@ -78,8 +79,8 @@ router.get(`${config.site_path}/post/:post_index`, (req, res) => {
locale,
post,
postID,
user: data.getdata('users','id', post.userID),
comments: data.getdata('comments','id', postID),
user: data.getdata('users','id', post.userID)[0],
comments: data.getdata('comments','id', postID)[0]["comments"],
fromUnixTime,
format,
getUnixTime,