2018-11-11 21:22:01 +01:00
|
|
|
import DateUtils from '../../tools/utilities/DateUtils';
|
|
|
|
var express = require('express');
|
|
|
|
var router = express.Router();
|
|
|
|
var hljs = require('highlight.js/lib/highlight');
|
|
|
|
var hljs_md = require('highlight.js/lib/languages/markdown');
|
|
|
|
hljs.registerLanguage('markdown', hljs_md);
|
2018-11-22 02:08:53 +01:00
|
|
|
var Sequelize = require('sequelize');
|
2018-11-11 21:22:01 +01:00
|
|
|
const dateUtils = new DateUtils();
|
|
|
|
//--------------------------
|
|
|
|
// POSTS
|
|
|
|
//--------------------------
|
2019-03-02 03:51:35 +01:00
|
|
|
router.get('/list/:filter?/:page?', function(req, res) {
|
2019-02-27 17:17:51 +01:00
|
|
|
var pageNum = req.params.page;
|
2019-03-01 23:48:05 +01:00
|
|
|
var filter = req.params.filter;
|
2019-02-27 17:17:51 +01:00
|
|
|
if (pageNum == '' || pageNum == null) pageNum = 1;
|
2019-03-01 23:48:05 +01:00
|
|
|
if (filter == '' || filter == null) filter = 'all';
|
2019-02-27 17:17:51 +01:00
|
|
|
if (req.session.user) {
|
2019-11-10 21:07:29 +01:00
|
|
|
|
2019-02-27 17:17:51 +01:00
|
|
|
.then(() => {
|
|
|
|
//console.log(value);
|
|
|
|
})
|
|
|
|
.catch(() => {
|
|
|
|
//next(err);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
res.redirect('/@/dashboard');
|
|
|
|
}
|
2018-11-11 21:22:01 +01:00
|
|
|
});
|
|
|
|
//--------------------------
|
|
|
|
// BLOG POST ADD DISPLAY
|
|
|
|
//--------------------------
|
2019-02-27 17:17:51 +01:00
|
|
|
router.get('/add/new', function(req, res) {
|
|
|
|
if (req.session.user) {
|
|
|
|
res.render('dash/post-edit', {
|
2019-02-27 22:09:39 +01:00
|
|
|
title: 'Dashboard New Post',
|
|
|
|
user_status: true,
|
|
|
|
welcome: 'New Post',
|
2019-02-27 17:17:51 +01:00
|
|
|
mode: 'admin',
|
|
|
|
date:
|
|
|
|
dateUtils.getDate('year', new Date()) +
|
|
|
|
'-' +
|
|
|
|
dateUtils.getDate('month', new Date()) +
|
|
|
|
'-' +
|
|
|
|
dateUtils.getDate('day', new Date()),
|
|
|
|
status: ['false', 'false', 'false'],
|
|
|
|
edit: false
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
res.redirect('/@/dashboard');
|
|
|
|
}
|
2018-11-11 21:22:01 +01:00
|
|
|
});
|
|
|
|
//--------------------------
|
|
|
|
// BLOG POST EDIT DISPLAY
|
|
|
|
//--------------------------
|
2019-02-27 17:17:51 +01:00
|
|
|
router.get('/edit/:id', function(req, res) {
|
|
|
|
if (req.session.user) {
|
2019-11-10 21:07:29 +01:00
|
|
|
} else {
|
2019-02-27 17:17:51 +01:00
|
|
|
res.redirect('/@/dashboard');
|
|
|
|
}
|
2018-11-11 21:22:01 +01:00
|
|
|
});
|
2019-02-27 17:17:51 +01:00
|
|
|
module.exports = router;
|