cleaded up settings display. ignoring json in prettier
This commit is contained in:
parent
477533ceb5
commit
4175bb631e
5 changed files with 56 additions and 26 deletions
|
@ -2,4 +2,5 @@
|
||||||
README.md
|
README.md
|
||||||
*.pug
|
*.pug
|
||||||
*.styl
|
*.styl
|
||||||
|
*.json
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ app.use(flash());
|
||||||
//var front = require('./routes/front/index')(session);
|
//var front = require('./routes/front/index')(session);
|
||||||
var dash = require('./routes/dash/index');
|
var dash = require('./routes/dash/index');
|
||||||
var page = require('./routes/dash/pages');
|
var page = require('./routes/dash/pages');
|
||||||
//var settingsDashboard = require('./routes/dash/settings');
|
var settings = require('./routes/dash/settings');
|
||||||
//var navDashboard = require('./routes/dash/nav');
|
//var navDashboard = require('./routes/dash/nav');
|
||||||
//api
|
//api
|
||||||
var pages = require('./api/v1/pages');
|
var pages = require('./api/v1/pages');
|
||||||
|
@ -61,7 +61,7 @@ app.use('/api/v1/auth', auth);
|
||||||
//app.use('/', front);
|
//app.use('/', front);
|
||||||
app.use('/@/dashboard', dash);
|
app.use('/@/dashboard', dash);
|
||||||
app.use('/@/dashboard/page', page);
|
app.use('/@/dashboard/page', page);
|
||||||
//app.use('/@/dashboard/settings', settingsDashboard);
|
app.use('/@/dashboard/settings', settings);
|
||||||
//app.use('/@/dashboard/navigation', navDashboard);
|
//app.use('/@/dashboard/navigation', navDashboard);
|
||||||
//app.use('/mailer', mailer);
|
//app.use('/mailer', mailer);
|
||||||
// catch 404 and forward to error handler
|
// catch 404 and forward to error handler
|
||||||
|
|
|
@ -7,22 +7,53 @@ var settings = [];
|
||||||
// SETTINGS
|
// SETTINGS
|
||||||
//--------------------------
|
//--------------------------
|
||||||
router.get('/', function(req, res) {
|
router.get('/', function(req, res) {
|
||||||
fs.readJson('config/site-settings.json')
|
fs.readJson('site/settings.json')
|
||||||
.then(obj => {
|
.then(obj => {
|
||||||
settings = obj;
|
settings = obj;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
//console.error(err)
|
//console.error(err)
|
||||||
});
|
});
|
||||||
let themes = [];
|
|
||||||
FileHound.create()
|
loadThemes().then(themes => {
|
||||||
.paths('themes')
|
if (req.session.user) {
|
||||||
.ext('json')
|
let memberInfo = [];
|
||||||
.find()
|
let user = req.session.user;
|
||||||
.then(files => {
|
memberInfo.push({
|
||||||
files.forEach(file => {
|
handle: user.handle,
|
||||||
fs.readJson(file)
|
email: user.email,
|
||||||
.then(theme => {
|
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('content/themes')
|
||||||
|
.ext('json')
|
||||||
|
.find()
|
||||||
|
.then(files => {
|
||||||
|
let themes = [];
|
||||||
|
for (let index = 0; index < files.length; index++) {
|
||||||
|
fs.readJSON(files[index], (err, theme) => {
|
||||||
if (theme.name == settings.theme) {
|
if (theme.name == settings.theme) {
|
||||||
themes.push({
|
themes.push({
|
||||||
theme: theme,
|
theme: theme,
|
||||||
|
@ -34,16 +65,14 @@ router.get('/', function(req, res) {
|
||||||
current: 'false'
|
current: 'false'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
//console.error(err)
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve(themes);
|
||||||
|
}, 200);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
reject(err);
|
||||||
});
|
});
|
||||||
if (req.session.user) {
|
});
|
||||||
let memberInfo = [];
|
}
|
||||||
} else {
|
|
||||||
res.redirect('/@/dashboard');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
module.exports = router;
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ block main-content
|
||||||
#member-info
|
#member-info
|
||||||
input(type='text', name='handle' id='settings-handle', placeholder='handle', value=member.handle, autofocus)
|
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='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)
|
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)
|
textarea(id="settings-desc" type='text', name='settings_desc' class='settings-dec', placeholder='description stuff', autofocus)
|
||||||
=settings.description
|
=settings.description
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
border-radius 5px 0 5px 0
|
border-radius 5px 0 5px 0
|
||||||
|
|
||||||
label
|
label
|
||||||
font-family 'Apercu-Mono'
|
font-family $monoType
|
||||||
color $white
|
color $white
|
||||||
|
|
||||||
input
|
input
|
||||||
|
@ -111,7 +111,7 @@
|
||||||
|
|
||||||
a.mail-option
|
a.mail-option
|
||||||
float right
|
float right
|
||||||
font-family 'Apercu-Mono'
|
font-family $monoType
|
||||||
font-size 0.9em
|
font-size 0.9em
|
||||||
border-radius 3px
|
border-radius 3px
|
||||||
text-decoration none
|
text-decoration none
|
||||||
|
|
Loading…
Reference in a new issue