|
|
|
@ -11,9 +11,11 @@ const dateUtils = new DateUtils();
|
|
|
|
|
//--------------------------
|
|
|
|
|
// POSTS
|
|
|
|
|
//--------------------------
|
|
|
|
|
router.get('/:page?', function(req, res) {
|
|
|
|
|
router.get('/:filter?/:page?', function(req, res) {
|
|
|
|
|
var pageNum = req.params.page;
|
|
|
|
|
var filter = req.params.filter;
|
|
|
|
|
if (pageNum == '' || pageNum == null) pageNum = 1;
|
|
|
|
|
if (filter == '' || filter == null) filter = 'all';
|
|
|
|
|
if (req.session.user) {
|
|
|
|
|
Models.FreshPost.findAll({
|
|
|
|
|
order: [['id', 'DESC']]
|
|
|
|
@ -35,14 +37,26 @@ router.get('/:page?', function(req, res) {
|
|
|
|
|
deleted.push(posts[index]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var count = Math.round(all.length / 6);
|
|
|
|
|
var filtered;
|
|
|
|
|
switch (filter) {
|
|
|
|
|
case 'published':
|
|
|
|
|
filtered = published;
|
|
|
|
|
break;
|
|
|
|
|
case 'deleted':
|
|
|
|
|
filtered = deleted;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
filtered = all;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
var count = Math.round(filtered.length / 6);
|
|
|
|
|
var pageItems = [];
|
|
|
|
|
var itemLimit = 6;
|
|
|
|
|
var rangeStart = pageNum * itemLimit - itemLimit;
|
|
|
|
|
for (var i = 0; i < itemLimit; i++) {
|
|
|
|
|
try {
|
|
|
|
|
if (all[i + rangeStart].id != null) {
|
|
|
|
|
pageItems.push(all[i + rangeStart]);
|
|
|
|
|
if (filtered[i + rangeStart].id != null) {
|
|
|
|
|
pageItems.push(filtered[i + rangeStart]);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
//console.log("NO POST", e)
|
|
|
|
@ -62,6 +76,7 @@ router.get('/:page?', function(req, res) {
|
|
|
|
|
},
|
|
|
|
|
page_index: pageNum,
|
|
|
|
|
page_count: count,
|
|
|
|
|
postFilter: filter,
|
|
|
|
|
user_status: true
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|