cleaned up config file read for making new pages
This commit is contained in:
parent
6c24660bbb
commit
f3ae41cd2a
1 changed files with 4 additions and 13 deletions
|
@ -92,14 +92,8 @@ 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) {
|
||||||
//need to grab a few copy of settings for the lastest index
|
//need to grab a few copy of settings for the lastest index
|
||||||
fs.readFile('site/settings.json', 'utf8', (err, json) => {
|
fs.readJSON('site/settings.json')
|
||||||
if (err) {
|
.then(config => {
|
||||||
// TODO: add error page
|
|
||||||
//console.log('Error reading file from disk:', err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
let config = JSON.parse(json);
|
|
||||||
res.render('page-edit', {
|
res.render('page-edit', {
|
||||||
id: config.library_stats.current_index,
|
id: config.library_stats.current_index,
|
||||||
uuid: uuidv4(),
|
uuid: uuidv4(),
|
||||||
|
@ -112,11 +106,8 @@ router.get('/add/new', function (req, res) {
|
||||||
status: ['false', 'false', 'false'],
|
status: ['false', 'false', 'false'],
|
||||||
edit: false
|
edit: false
|
||||||
});
|
});
|
||||||
} catch (err) {
|
})
|
||||||
//add error page
|
.catch(err => {});
|
||||||
console.log('ERROR', err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
res.redirect('/@/dashboard');
|
res.redirect('/@/dashboard');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue