From ddddb356181baefbb03cbf710c9b6210b4d8de52 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Sat, 8 Feb 2020 22:09:35 -0600 Subject: Remove client side markdown, add single posts to all feeds --- src/html/blog-single.html | 61 ----------------------------------------------- src/html/blog.html | 27 ++++++++++----------- src/html/feed.html | 4 ++-- src/html/index.html | 9 +++---- src/html/post-single.html | 41 +++++++++++++++++++++++++++++++ src/html/projects.html | 1 + src/html/tags.html | 2 +- src/server.js | 21 ++++++++++++++-- 8 files changed, 82 insertions(+), 84 deletions(-) delete mode 100644 src/html/blog-single.html create mode 100644 src/html/post-single.html (limited to 'src') diff --git a/src/html/blog-single.html b/src/html/blog-single.html deleted file mode 100644 index 75cbf92..0000000 --- a/src/html/blog-single.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - Mark's Kitchen - Blog - - - - - - - - - - -
-

- < - < - Blog -

-
-
-

-
- - - -
-

- {{ post.createdAt.substring(0,10) }} - - {{tag}} - -

-
-
-
- - - \ No newline at end of file diff --git a/src/html/blog.html b/src/html/blog.html index c034711..c0662f7 100644 --- a/src/html/blog.html +++ b/src/html/blog.html @@ -6,11 +6,12 @@ - - - + + + + + @@ -35,7 +33,7 @@ < Blog -
+ +
diff --git a/src/html/feed.html b/src/html/feed.html index 15a364d..7128174 100644 --- a/src/html/feed.html +++ b/src/html/feed.html @@ -3,11 +3,11 @@

- +

- {{ post.createdAt.substring(0,10) }} + {{ post.createdAt.substring(0,10) }} {{tag}} diff --git a/src/html/index.html b/src/html/index.html index ce67842..f51122b 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -36,11 +36,12 @@ Misc -

+
+
- + \ No newline at end of file diff --git a/src/html/post-single.html b/src/html/post-single.html new file mode 100644 index 0000000..221ade4 --- /dev/null +++ b/src/html/post-single.html @@ -0,0 +1,41 @@ + + + + + Mark's Kitchen - Blog + + + + + + + + + + + +
+

+ < +

+
+
+ + + \ No newline at end of file diff --git a/src/html/projects.html b/src/html/projects.html index 16d3f25..f71c833 100644 --- a/src/html/projects.html +++ b/src/html/projects.html @@ -33,6 +33,7 @@

< + < Projects

A collection of my projects, mostly programming

diff --git a/src/html/tags.html b/src/html/tags.html index 7f2cb16..c6e4022 100644 --- a/src/html/tags.html +++ b/src/html/tags.html @@ -32,7 +32,7 @@
-

Viewing: {{tag}}

+

<{{tag}}

diff --git a/src/server.js b/src/server.js index 72cc417..b92d7d4 100644 --- a/src/server.js +++ b/src/server.js @@ -143,8 +143,8 @@ function setUpRoutes(models, jwtFunctions, database) { res.status(400).send(e.message); } }) - server.get('/blog/:id', async (req, res, next) => { - res.sendFile(__dirname + "/html/blog-single.html"); + server.get('/post/:type/:id', async (req, res, next) => { + res.sendFile(__dirname + "/html/post-single.html"); }) server.get('/tags/:name', async (req, res, next) => { console.log("TAGS/NAME"); @@ -181,6 +181,23 @@ function setUpRoutes(models, jwtFunctions, database) { res.status(400).send(e.message); } }) + server.get('/posts/:type/:id', async (req, res, next) => { + try { + const { type, id } = req.params; + var posts = await models.posts.findAll({ + where: { + type: type, + id: id + }, order: [['createdAt', 'DESC']] + }); + posts = posts.map(x => x.get({ plain: true })); + await addImagesAndTagsToPosts(models, posts) + res.status(200).send(posts); + next(); + } catch (e) { + res.status(400).send(e.message); + } + }) server.post('/posts', upload.array('images'), async (req, res, next) => { try { const type = req.body.type -- cgit v1.2.3