Browse Source

Got the photos post to have their write up display above the photos.

pull/77/head
jrtechs 5 years ago
parent
commit
ce3cc285c0
6 changed files with 69 additions and 33 deletions
  1. +17
    -9
      blog/renderBlogPost.js
  2. +1
    -1
      blogContent/photos/2019/june/mohawk-river-trail/post.md
  3. +3
    -4
      package.json
  4. +1
    -1
      previewer.js
  5. +34
    -14
      routes/photos/index.js
  6. +13
    -4
      templates/photos/photosEntry.html

+ 17
- 9
blog/renderBlogPost.js View File

@ -174,7 +174,21 @@ module.exports=
*/ */
convertToHTML: function(markdownContents, type) 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 // Set your callback function
callback = function (err, html) callback = function (err, html)
@ -189,15 +203,9 @@ module.exports=
resolve(html); resolve(html);
}; };
if(type == -1)
{
pandoc(markdownContents, argsFull, callback);
}
else
{
pandoc(markdownContents, argsPreview, callback);
}
pandoc(markdownContents, pandocArgs, callback);
}); });
}, },

+ 1
- 1
blogContent/photos/2019/june/mohawk-river-trail/post.md View File

@ -1,3 +1,3 @@
# Mohawk River Trail # Mohawk River Trail
General description goes here.
Testing the macro functionality of the vintage cannon FD lens that I bought on Craigslist.

+ 3
- 4
package.json View File

@ -10,18 +10,17 @@
"express-session": "^1.15.6", "express-session": "^1.15.6",
"highlight": "^0.2.4", "highlight": "^0.2.4",
"highlight.js": "^9.12.0", "highlight.js": "^9.12.0",
"markdown": "^0.5.0",
"memory-cache": "^0.2.0", "memory-cache": "^0.2.0",
"mysql": "^2.16.0", "mysql": "^2.16.0",
"node-pandoc": "^0.3.0", "node-pandoc": "^0.3.0",
"nodemailer": "^4.6.8", "nodemailer": "^4.6.8",
"nodemailer-smtp-transport": "^2.7.4", "nodemailer-smtp-transport": "^2.7.4",
"promise": "^8.0.1", "promise": "^8.0.1",
"remarkable": "^1.7.1",
"request": "^2.88.0", "request": "^2.88.0",
"routes": "^2.1.0", "routes": "^2.1.0",
"sanitizer": "^0.1.3", "sanitizer": "^0.1.3",
"sendmail": "^1.4.1"
"sendmail": "^1.4.1",
"whiskers": "^0.4.0"
}, },
"devDependencies": {}, "devDependencies": {},
"scripts": { "scripts": {
@ -36,7 +35,7 @@
"nodejs" "nodejs"
], ],
"author": "Jeffery Russell", "author": "Jeffery Russell",
"license": "ISC",
"license": "",
"bugs": { "bugs": {
"url": "https://github.com/jrtechs/NodeJSBlog/issues" "url": "https://github.com/jrtechs/NodeJSBlog/issues"
}, },

+ 1
- 1
previewer.js View File

@ -35,7 +35,7 @@ app.use(function(request, result)
{ {
result.writeHead(200, {'Content-Type': 'text/html'}); result.writeHead(200, {'Content-Type': 'text/html'});
Promise.all([includes.printHeader(), 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) includes.printFooter()]).then(function (content)
{ {
result.write(content.join('')); result.write(content.join(''));

+ 34
- 14
routes/photos/index.js View File

@ -2,6 +2,8 @@ const routes = require('express').Router();
const pageBuilder = require('../../utils/pageBuilder'); const pageBuilder = require('../../utils/pageBuilder');
const renderBlogPost = require('../../blog/renderBlogPost');
const utils = require('../../utils/utils'); const utils = require('../../utils/utils');
const whiskers = require('whiskers'); const whiskers = require('whiskers');
@ -20,23 +22,41 @@ routes.get('/', (request, result) =>
const photosBaseDir = "blogContent/photos"; const photosBaseDir = "blogContent/photos";
photoPageBuilder = function(filename, request, templateContext) 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) => routes.get('*', (request, result) =>

+ 13
- 4
templates/photos/photosEntry.html View File

@ -6,20 +6,29 @@
<div class="container"> <div class="container">
<br><br><br><br> <br><br><br><br>
<div id="lightgallery" class="row p-4">
<div class="p-2">
{mainPost}
</div>
<div id="lightgallery" class="row p-2 align-content-center">
{for img in images} {for img in images}
<div class="col-lg-3 col-md-4 col-xs-6 thumb p-1" data-src='{img.full}'>
<div class="col-lg-4 col-md-6 col-xs-12 thumb p-12 text-center" data-src='{img.full}'>
<div class="span4"></div>
<div class="span4">
<a href="{img.full}"> <a href="{img.full}">
<img src="{img.preview}" />
<img class="img-thumbnail img-responsive center-block" width="100%" src="{img.full}" />
</a> </a>
</div>
<div class="span4"></div>
</div> </div>
{/for} {/for}
{if error} {if error}
<div class="row p-lg-0"> <div class="row p-lg-0">
<h1 class="align-content-center">Page Not Found</h1> <h1 class="align-content-center">Page Not Found</h1>
<div class="align-content-center">
<div class="align-content-center center-block">
<img src="/includes/img/404.jpg" alt="Page not found" width="70%" /> <img src="/includes/img/404.jpg" alt="Page not found" width="70%" />
</div> </div>
</div> </div>

Loading…
Cancel
Save