|
|
|
@ -4,7 +4,7 @@ const router = express.Router();
|
|
|
|
|
const moment = require('moment');
|
|
|
|
|
const book = new Book();
|
|
|
|
|
const uuidv4 = require('uuid/v4');
|
|
|
|
|
const settings = require('../../../site/settings.json');
|
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
|
//--------------------------
|
|
|
|
|
// POSTS
|
|
|
|
|
//--------------------------
|
|
|
|
@ -91,8 +91,17 @@ router.get('/list/:filter?/:page?', function (req, res) {
|
|
|
|
|
//--------------------------
|
|
|
|
|
router.get('/add/new', function (req, res) {
|
|
|
|
|
if (req.session.user) {
|
|
|
|
|
//need to grab a few copy of settings for the lastest index
|
|
|
|
|
fs.readFile('site/settings.json', 'utf8', (err, json) => {
|
|
|
|
|
if (err) {
|
|
|
|
|
// TODO: add error page
|
|
|
|
|
//console.log('Error reading file from disk:', err);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
let config = JSON.parse(json);
|
|
|
|
|
res.render('page-edit', {
|
|
|
|
|
id: settings.library_stats.current_index,
|
|
|
|
|
id: config.library_stats.current_index,
|
|
|
|
|
uuid: uuidv4(),
|
|
|
|
|
title: 'Add New Page',
|
|
|
|
|
user_status: true,
|
|
|
|
@ -103,6 +112,11 @@ router.get('/add/new', function (req, res) {
|
|
|
|
|
status: ['false', 'false', 'false'],
|
|
|
|
|
edit: false
|
|
|
|
|
});
|
|
|
|
|
} catch (err) {
|
|
|
|
|
//add error page
|
|
|
|
|
console.log('ERROR', err);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
res.redirect('/@/dashboard');
|
|
|
|
|
}
|
|
|
|
|