diff --git a/blog/renderBlogPost.js b/blog/renderBlogPost.js index f0eff9e..0339d5e 100644 --- a/blog/renderBlogPost.js +++ b/blog/renderBlogPost.js @@ -174,7 +174,21 @@ module.exports= */ convertToHTML: function(markdownContents, type) { - return new Promise(function(resolve, reject) + if(type == -1) + { + return module.exports.pandocWrapper(markdownContents, argsFull); + } + else + { + return module.exports.pandocWrapper(markdownContents, argsFull); + } + }, + + + + pandocWrapper: function(markdownContents, pandocArgs) + { + return new Promise((resolve, reject)=> { // Set your callback function callback = function (err, html) @@ -189,15 +203,9 @@ module.exports= resolve(html); }; - if(type == -1) - { - pandoc(markdownContents, argsFull, callback); - } - else - { - pandoc(markdownContents, argsPreview, callback); - } + pandoc(markdownContents, pandocArgs, callback); }); + }, diff --git a/blogContent/photos/2019/june/mohawk-river-trail/post.md b/blogContent/photos/2019/june/mohawk-river-trail/post.md index fdbe570..f956890 100644 --- a/blogContent/photos/2019/june/mohawk-river-trail/post.md +++ b/blogContent/photos/2019/june/mohawk-river-trail/post.md @@ -1,3 +1,3 @@ # Mohawk River Trail -General description goes here. \ No newline at end of file +Testing the macro functionality of the vintage cannon FD lens that I bought on Craigslist. \ No newline at end of file diff --git a/package.json b/package.json index 32f89e7..9f552d7 100644 --- a/package.json +++ b/package.json @@ -10,18 +10,17 @@ "express-session": "^1.15.6", "highlight": "^0.2.4", "highlight.js": "^9.12.0", - "markdown": "^0.5.0", "memory-cache": "^0.2.0", "mysql": "^2.16.0", "node-pandoc": "^0.3.0", "nodemailer": "^4.6.8", "nodemailer-smtp-transport": "^2.7.4", "promise": "^8.0.1", - "remarkable": "^1.7.1", "request": "^2.88.0", "routes": "^2.1.0", "sanitizer": "^0.1.3", - "sendmail": "^1.4.1" + "sendmail": "^1.4.1", + "whiskers": "^0.4.0" }, "devDependencies": {}, "scripts": { @@ -36,7 +35,7 @@ "nodejs" ], "author": "Jeffery Russell", - "license": "ISC", + "license": "", "bugs": { "url": "https://github.com/jrtechs/NodeJSBlog/issues" }, diff --git a/previewer.js b/previewer.js index a727ddb..ab654d8 100644 --- a/previewer.js +++ b/previewer.js @@ -35,7 +35,7 @@ app.use(function(request, result) { result.writeHead(200, {'Content-Type': 'text/html'}); Promise.all([includes.printHeader(), - require('./utils/renderBlogPost.js').generateBlogPostComponent('/programming/', 'cs-theory-exam-2-review', -1), + require('./blog/renderBlogPost.js').generateBlogPostComponent('/programming/', 'cs-theory-exam-2-review', -1), includes.printFooter()]).then(function (content) { result.write(content.join('')); diff --git a/routes/photos/index.js b/routes/photos/index.js index 206a72b..0ec8cab 100644 --- a/routes/photos/index.js +++ b/routes/photos/index.js @@ -2,6 +2,8 @@ const routes = require('express').Router(); const pageBuilder = require('../../utils/pageBuilder'); +const renderBlogPost = require('../../blog/renderBlogPost'); + const utils = require('../../utils/utils'); const whiskers = require('whiskers'); @@ -20,23 +22,41 @@ routes.get('/', (request, result) => const photosBaseDir = "blogContent/photos"; photoPageBuilder = function(filename, request, templateContext) { - if(fs.existsSync(photosBaseDir + filename)) + return new Promise((resolve, reject)=> { - templateContext.images = []; - var imagePath = "/" + photosBaseDir + filename + "/"; - fs.readdirSync(photosBaseDir + filename).forEach(file=> + if(fs.existsSync(photosBaseDir + filename + "/post.md")) { - if(file.includes('.jpg')) //doesn't pick up mark down files + var markdownContent = utils.getFileContents( + photosBaseDir + filename + "/post.md"); + + renderBlogPost.pandocWrapper(markdownContent, "-t html5") + .then((html)=> { - templateContext.images.push({full:imagePath+ file, - preview:imagePath + "preview/" + file}); - } - }); - } - else - { - templateContext.error = true; - } + templateContext.images = []; + templateContext.mainPost = html; + var imagePath = "/" + photosBaseDir + filename + "/"; + fs.readdirSync(photosBaseDir + filename).forEach(file=> + { + if(file.includes('.jpg')) //doesn't pick up mark down files + { + templateContext.images.push({full:imagePath+ file, + preview:imagePath + "preview/" + file}); + } + }); + + resolve(); + }).catch((error)=> + { + reject(error); + }) + + } + else + { + templateContext.error = true; + resolve(); + } + }) }; routes.get('*', (request, result) => diff --git a/templates/photos/photosEntry.html b/templates/photos/photosEntry.html index bb15336..5e8eb1d 100644 --- a/templates/photos/photosEntry.html +++ b/templates/photos/photosEntry.html @@ -6,20 +6,29 @@