diff --git a/posts/category.js b/posts/category.js index 28778a2..d30e7b2 100644 --- a/posts/category.js +++ b/posts/category.js @@ -1,12 +1,9 @@ -//DB query +/** DB query */ const sql = require('../utils/sql'); -//file IO -const utils = require('../utils/utils.js'); - +/** Object used to render blog post previews */ const batchPreview = require('../posts/renderBatchOfPreviewes'); - /** * Renders all posts in a single category * @@ -40,8 +37,9 @@ module.exports= /** * Calls posts and sidebar modules to render blog contents in order * - * @param res - * @param fileName request url + * @param requestURL + * @param request + * @returns {Promise} */ main: function(requestURL, request) { diff --git a/posts/posts.js b/posts/posts.js index 3f32e38..9a2da59 100644 --- a/posts/posts.js +++ b/posts/posts.js @@ -1,7 +1,4 @@ -//file io -const utils = require('../utils/utils.js'); - -//DB queries +/** DB queries */ const sql = require('../utils/sql'); @@ -9,7 +6,6 @@ const sql = require('../utils/sql'); * Function responsible for calling the appropriate sql requests to query * database and serve correct blog post * - * @param res the result sent to the client * @param requestURL url requested from client * @return {*|Promise} returns a resolved promise to preserve execution order */ @@ -59,7 +55,8 @@ module.exports= { return new Promise(function(resolve, reject) { - Promise.all([renderPost(requestURL), require("../sidebar/sidebar.js").main()]).then(function(content) + Promise.all([renderPost(requestURL), + require("../sidebar/sidebar.js").main()]).then(function(content) { resolve(content.join('')); }).catch(function(error) diff --git a/posts/renderBatchOfPreviewes.js b/posts/renderBatchOfPreviewes.js index bcdd1e3..6c69419 100644 --- a/posts/renderBatchOfPreviewes.js +++ b/posts/renderBatchOfPreviewes.js @@ -1,11 +1,13 @@ - module.exports= { /** - * Calls posts and sidebar modules to render blog contents in order + * Renders a bunch of blog post previews to the user * - * @param res - * @param fileName request url + * @param baseURL-- url of the page + * @param posts -- sql data about the posts to render + * @param currentPage -- the current page to render + * @param numOfPosts -- number of posts to render + * @returns {Promise} renders the html of the posts */ main: function(baseURL, posts, currentPage, numOfPosts) { diff --git a/posts/renderNextBar.js b/posts/renderNextBar.js index 7b96d3b..ff232b2 100644 --- a/posts/renderNextBar.js +++ b/posts/renderNextBar.js @@ -1,3 +1,11 @@ +/** + * Determines if the requested page is out of bounds + * + * @param page current page + * @param postsPerPage - number of posts rendered on each page + * @param totalPosts - total posts in this category/total + * @returns {boolean} if this is a valid page + */ const isValidPage = function(page, postsPerPage, totalPosts) { return !(page === 0 || page -1 >= totalPosts/postsPerPage); @@ -5,6 +13,17 @@ const isValidPage = function(page, postsPerPage, totalPosts) module.exports= { + /** + * Renders two buttons on the bottom of the page to + * go to the left or right + * + * Used by the home page and categories pages + * @param baseURL -- base url of page being rendered + * @param currentPage -- current page being rendered + * @param postsPerPage -- number of posts on each page + * @param totalPosts -- total amount of posts in the category + * @returns {Promise} promise which renders the buttons + */ main: function(baseURL, currentPage, postsPerPage, totalPosts) { return new Promise(function(resolve, reject)