|
|
|
@ -7,22 +7,53 @@ var settings = [];
|
|
|
|
|
// SETTINGS
|
|
|
|
|
//--------------------------
|
|
|
|
|
router.get('/', function(req, res) {
|
|
|
|
|
fs.readJson('config/site-settings.json')
|
|
|
|
|
fs.readJson('site/settings.json')
|
|
|
|
|
.then(obj => {
|
|
|
|
|
settings = obj;
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
//console.error(err)
|
|
|
|
|
});
|
|
|
|
|
let themes = [];
|
|
|
|
|
|
|
|
|
|
loadThemes().then(themes => {
|
|
|
|
|
if (req.session.user) {
|
|
|
|
|
let memberInfo = [];
|
|
|
|
|
let user = req.session.user;
|
|
|
|
|
memberInfo.push({
|
|
|
|
|
handle: user.handle,
|
|
|
|
|
email: user.email,
|
|
|
|
|
avi: user.avi
|
|
|
|
|
});
|
|
|
|
|
themes.sort(function(a, b) {
|
|
|
|
|
var textA = a.theme.name.toUpperCase();
|
|
|
|
|
var textB = b.theme.name.toUpperCase();
|
|
|
|
|
return textA < textB ? -1 : textA > textB ? 1 : 0;
|
|
|
|
|
});
|
|
|
|
|
res.render('settings', {
|
|
|
|
|
title: 'Dashboard | Settings',
|
|
|
|
|
welcome: 'Your Settings',
|
|
|
|
|
status: true,
|
|
|
|
|
themes: themes,
|
|
|
|
|
settings: settings,
|
|
|
|
|
member: memberInfo[0]
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
res.redirect('/@/dashboard');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
module.exports = router;
|
|
|
|
|
|
|
|
|
|
function loadThemes() {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
FileHound.create()
|
|
|
|
|
.paths('themes')
|
|
|
|
|
.paths('content/themes')
|
|
|
|
|
.ext('json')
|
|
|
|
|
.find()
|
|
|
|
|
.then(files => {
|
|
|
|
|
files.forEach(file => {
|
|
|
|
|
fs.readJson(file)
|
|
|
|
|
.then(theme => {
|
|
|
|
|
let themes = [];
|
|
|
|
|
for (let index = 0; index < files.length; index++) {
|
|
|
|
|
fs.readJSON(files[index], (err, theme) => {
|
|
|
|
|
if (theme.name == settings.theme) {
|
|
|
|
|
themes.push({
|
|
|
|
|
theme: theme,
|
|
|
|
@ -34,16 +65,14 @@ router.get('/', function(req, res) {
|
|
|
|
|
current: 'false'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
//console.error(err)
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
if (req.session.user) {
|
|
|
|
|
let memberInfo = [];
|
|
|
|
|
} else {
|
|
|
|
|
res.redirect('/@/dashboard');
|
|
|
|
|
}
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
resolve(themes);
|
|
|
|
|
}, 200);
|
|
|
|
|
})
|
|
|
|
|
.catch(err => {
|
|
|
|
|
reject(err);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
module.exports = router;
|
|
|
|
|
}
|
|
|
|
|