|
@ -9,6 +9,10 @@ const whiskers = require('whiskers'); |
|
|
const TEMPLATE_FILE="blog/blogMain.html"; |
|
|
const TEMPLATE_FILE="blog/blogMain.html"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const PAGINATION_TEMPLATE_KEY = "paginationTemplate"; |
|
|
|
|
|
const PAGINATION_TEMPLATE_FILE = "blog/paginationBar.html"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//caching program to make the application run faster
|
|
|
//caching program to make the application run faster
|
|
|
const cache = require('memory-cache'); |
|
|
const cache = require('memory-cache'); |
|
|
|
|
|
|
|
@ -74,15 +78,17 @@ module.exports= |
|
|
// cache is not tricked into storing same blog post a ton of times
|
|
|
// cache is not tricked into storing same blog post a ton of times
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var templateContext = Object(); |
|
|
var templateContext = Object(); |
|
|
Promise.all([includes.fetchTemplate(TEMPLATE_FILE), |
|
|
Promise.all([includes.fetchTemplate(TEMPLATE_FILE), |
|
|
|
|
|
utils.includeInObject(PAGINATION_TEMPLATE_KEY, templateContext, "templates/" + PAGINATION_TEMPLATE_FILE), |
|
|
includes.printHeader(templateContext), |
|
|
includes.printHeader(templateContext), |
|
|
includes.printFooter(templateContext), |
|
|
includes.printFooter(templateContext), |
|
|
require(file).main(filename, request, templateContext), |
|
|
require(file).main(filename, request, templateContext), |
|
|
require("../blog/sidebar.js").main(templateContext)]) |
|
|
require("../blog/sidebar.js").main(templateContext)]) |
|
|
.then(function (content) |
|
|
.then(function (content) |
|
|
{ |
|
|
{ |
|
|
var html = whiskers.render(content[0], templateContext); |
|
|
|
|
|
|
|
|
const html = whiskers.render(content[0], templateContext); |
|
|
result.write(html); |
|
|
result.write(html); |
|
|
result.end(); |
|
|
result.end(); |
|
|
cache.put(filename + "?page=" + page, html); |
|
|
cache.put(filename + "?page=" + page, html); |
|
|