From 30236674def1ce21a055836dfca27b96520ad428 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Thu, 18 Jun 2020 19:56:31 -0400 Subject: [PATCH] Finished more posts load system --- blog/category.js | 1 + blog/homePage.js | 2 +- templates/blog/blogMain.html | 36 +++++++++++++++++++++++++----------- templates/blog/header.html | 1 - utils/sql.js | 29 +++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 13 deletions(-) diff --git a/blog/category.js b/blog/category.js index 8a2e5ab..67c4b2d 100644 --- a/blog/category.js +++ b/blog/category.js @@ -25,6 +25,7 @@ module.exports= templateContext["title"] = category; sql.getPostsFromCategory(category).then(function(posts) { + templateContext["categoryID"] = posts[0].category_id; Promise.all([blogBodyRenderer.renderBatchOfPosts(requestURL, posts, page, 5, templateContext), require('./renderNextBar').main("/category" + request.url, page, 5, posts.length, templateContext)]).then(function() { diff --git a/blog/homePage.js b/blog/homePage.js index 912b794..2736181 100644 --- a/blog/homePage.js +++ b/blog/homePage.js @@ -13,7 +13,7 @@ module.exports= main: function(requestURL, request, templateContext) { var page = request.query.page; - + templateContext["categoryID"] = 0; return new Promise(function(resolve, reject) { sql.getAllPosts().then(function(posts) diff --git a/templates/blog/blogMain.html b/templates/blog/blogMain.html index de4c18c..3367e4f 100644 --- a/templates/blog/blogMain.html +++ b/templates/blog/blogMain.html @@ -7,7 +7,7 @@




@@ -155,13 +171,11 @@
{if preview} -
-
-

- More Posts » -

-
+ {/if}
diff --git a/templates/blog/header.html b/templates/blog/header.html index 04caf1e..4cc77e6 100644 --- a/templates/blog/header.html +++ b/templates/blog/header.html @@ -2,7 +2,6 @@ - {if title} Jrtechs: {title} {else} diff --git a/utils/sql.js b/utils/sql.js index 05d17be..e4f80cf 100644 --- a/utils/sql.js +++ b/utils/sql.js @@ -178,6 +178,35 @@ module.exports= }); }, + getPostIds: function(categoryID) + { + return new Promise((resolve, reject)=> + { + if(categoryID == 0) + { + fetch("select post_id from posts order by published desc") + .then(function(ids) + { + resolve(ids); + }).catch((error)=> + { + reject(error); + }); + } + else + { + fetch("select post_id from posts where category_id='" + categoryID + "' order by published desc") + .then(function(ids) + { + resolve(ids); + }).catch((error)=> + { + reject(error); + }); + } + }); + }, + insert: function(sqlStatement) { return insert(sqlStatement);