cleaded up settings display. ignoring json in prettier

pull/20/head
Ro 5 years ago
parent 477533ceb5
commit 4175bb631e

@ -2,4 +2,5 @@
README.md
*.pug
*.styl
*.json

@ -44,7 +44,7 @@ app.use(flash());
//var front = require('./routes/front/index')(session);
var dash = require('./routes/dash/index');
var page = require('./routes/dash/pages');
//var settingsDashboard = require('./routes/dash/settings');
var settings = require('./routes/dash/settings');
//var navDashboard = require('./routes/dash/nav');
//api
var pages = require('./api/v1/pages');
@ -61,7 +61,7 @@ app.use('/api/v1/auth', auth);
//app.use('/', front);
app.use('/@/dashboard', dash);
app.use('/@/dashboard/page', page);
//app.use('/@/dashboard/settings', settingsDashboard);
app.use('/@/dashboard/settings', settings);
//app.use('/@/dashboard/navigation', navDashboard);
//app.use('/mailer', mailer);
// catch 404 and forward to error handler

@ -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;
});
}

@ -19,7 +19,7 @@ block main-content
#member-info
input(type='text', name='handle' id='settings-handle', placeholder='handle', value=member.handle, autofocus)
input(type='text', name='email' id='settings-email', placeholder='email', value=member.email, autofocus)
input(type='text', name='base-url' id='settings-url', placeholder='url', value=settings.url, autofocus)
input(type='text', name='base-url' id='settings-url', placeholder='url', value=settings.base_url, autofocus)
input(type='text', name='base-title' id='settings-title', placeholder='site title', value=settings.title, autofocus)
textarea(id="settings-desc" type='text', name='settings_desc' class='settings-dec', placeholder='description stuff', autofocus)
=settings.description

@ -39,7 +39,7 @@
border-radius 5px 0 5px 0
label
font-family 'Apercu-Mono'
font-family $monoType
color $white
input
@ -111,7 +111,7 @@
a.mail-option
float right
font-family 'Apercu-Mono'
font-family $monoType
font-size 0.9em
border-radius 3px
text-decoration none

Loading…
Cancel
Save