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