|
|
|
@ -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,17 +91,31 @@ router.get('/list/:filter?/:page?', function (req, res) {
|
|
|
|
|
//--------------------------
|
|
|
|
|
router.get('/add/new', function (req, res) {
|
|
|
|
|
if (req.session.user) {
|
|
|
|
|
res.render('page-edit', {
|
|
|
|
|
id: settings.library_stats.current_index,
|
|
|
|
|
uuid: uuidv4(),
|
|
|
|
|
title: 'Add New Page',
|
|
|
|
|
user_status: true,
|
|
|
|
|
welcome: 'Add New Page',
|
|
|
|
|
date: moment(Date.now()).format('YYYY MMM DD'),
|
|
|
|
|
page: [],
|
|
|
|
|
rawDate: moment(Date.now()).format(),
|
|
|
|
|
status: ['false', 'false', 'false'],
|
|
|
|
|
edit: false
|
|
|
|
|
//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: config.library_stats.current_index,
|
|
|
|
|
uuid: uuidv4(),
|
|
|
|
|
title: 'Add New Page',
|
|
|
|
|
user_status: true,
|
|
|
|
|
welcome: 'Add New Page',
|
|
|
|
|
date: moment(Date.now()).format('YYYY MMM DD'),
|
|
|
|
|
page: [],
|
|
|
|
|
rawDate: moment(Date.now()).format(),
|
|
|
|
|
status: ['false', 'false', 'false'],
|
|
|
|
|
edit: false
|
|
|
|
|
});
|
|
|
|
|
} catch (err) {
|
|
|
|
|
//add error page
|
|
|
|
|
console.log('ERROR', err);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
res.redirect('/@/dashboard');
|
|
|
|
|