|
@ -2,6 +2,8 @@ var Promise = require('promise'); |
|
|
const sql = require('../utils/sql'); |
|
|
const sql = require('../utils/sql'); |
|
|
const utils = require('../utils/utils.js'); |
|
|
const utils = require('../utils/utils.js'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var renderPosts = function(result, resultURL) |
|
|
var renderPosts = function(result, resultURL) |
|
|
{ |
|
|
{ |
|
|
var splitURL = resultURL.split("/"); |
|
|
var splitURL = resultURL.split("/"); |
|
@ -13,15 +15,29 @@ var renderPosts = function(result, resultURL) |
|
|
{ |
|
|
{ |
|
|
sql.getPostsFromCategory(splitURL[2]).then(function(posts) |
|
|
sql.getPostsFromCategory(splitURL[2]).then(function(posts) |
|
|
{ |
|
|
{ |
|
|
|
|
|
var promises = []; |
|
|
|
|
|
console.log(posts); |
|
|
|
|
|
console.log("^^^^"); |
|
|
posts.forEach(function(p) |
|
|
posts.forEach(function(p) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
require("../posts/singlePost.js").renderPost(result, p); |
|
|
|
|
|
|
|
|
promises.push(new Promise(function(res, rej) |
|
|
|
|
|
{ |
|
|
|
|
|
require("../posts/singlePost.js") |
|
|
|
|
|
.renderPost(result, p) |
|
|
|
|
|
.then(function() |
|
|
|
|
|
{ |
|
|
|
|
|
res(); |
|
|
|
|
|
}); |
|
|
|
|
|
})); |
|
|
}); |
|
|
}); |
|
|
|
|
|
return Promise.all(promises); |
|
|
}).then(function() |
|
|
}).then(function() |
|
|
{ |
|
|
{ |
|
|
result.write("</div>"); |
|
|
result.write("</div>"); |
|
|
resolve(); |
|
|
resolve(); |
|
|
|
|
|
}).catch(function(err) |
|
|
|
|
|
{ |
|
|
|
|
|
console.log(err); |
|
|
}) |
|
|
}) |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|