From 8cdf12a4d9f9ab4d133b1d3e11fc6b33b7f02b7d Mon Sep 17 00:00:00 2001 From: jrtechs Date: Fri, 3 Jan 2020 21:49:45 -0500 Subject: [PATCH] Updated timeline so that the blog post will render once you click on it in the time line. --- includes/html/footer.html | 8 ++- includes/html/header.html | 3 ++ routes/api/index.js | 20 +++++++- templates/blog/posts.html | 100 ++++++++++++++++++++++++++++++++++++-- utils/sql.js | 15 ++++-- 5 files changed, 134 insertions(+), 12 deletions(-) diff --git a/includes/html/footer.html b/includes/html/footer.html index 22c86fe..b97435b 100644 --- a/includes/html/footer.html +++ b/includes/html/footer.html @@ -59,7 +59,9 @@ diff --git a/includes/html/header.html b/includes/html/header.html index a3d27d5..0602309 100644 --- a/includes/html/header.html +++ b/includes/html/header.html @@ -65,6 +65,9 @@ + diff --git a/routes/api/index.js b/routes/api/index.js index 32508cc..559368b 100644 --- a/routes/api/index.js +++ b/routes/api/index.js @@ -1,19 +1,35 @@ const routes = require('express').Router(); const sql = require('../../utils/sql'); - +const renderPost = require('../../blog/renderBlogPost'); routes.get('/posts', (request, result) => { sql.getAllPosts().then((data)=> { - result.json(data).end();result + result.json(data).end(); }).catch((err)=> { result.status(500).json([]).end(); }); }); + +routes.get('/render/:postID', (request, result) => +{ + sql.getPostById(request.params.postID).then((sqlData)=> + { + renderPost.generateBlogPost(sqlData, -1).then((rendered)=> + { + result.json(rendered).end(); + }); + }).catch((err)=> + { + result.status(404).json({error: 404}).end(); + }) + +}); + routes.get('*', (request, result) => { result.json([]).end(); diff --git a/templates/blog/posts.html b/templates/blog/posts.html index db81b34..565847b 100644 --- a/templates/blog/posts.html +++ b/templates/blog/posts.html @@ -78,9 +78,19 @@
-
-
+
+
+
+ +
+

+
+
+
+
+
+


@@ -95,7 +105,9 @@