2013-12-06 03:51:35 -05:00
|
|
|
var config = require('../config'),
|
2014-07-08 23:17:30 -05:00
|
|
|
_ = require('lodash'),
|
2013-11-21 22:17:38 -05:00
|
|
|
when = require('when'),
|
2014-07-08 23:17:30 -05:00
|
|
|
api = require('../api'),
|
2014-05-09 05:11:29 -05:00
|
|
|
errors = require('../errors'),
|
2014-01-03 10:50:03 -05:00
|
|
|
updateCheck = require('../update-check'),
|
2014-06-30 18:26:08 -05:00
|
|
|
adminControllers;
|
2013-05-28 19:10:39 -05:00
|
|
|
|
2013-06-25 06:43:15 -05:00
|
|
|
adminControllers = {
|
2014-06-30 18:26:08 -05:00
|
|
|
// Route: index
|
|
|
|
// Path: /ghost/
|
|
|
|
// Method: GET
|
2014-02-26 18:15:31 -05:00
|
|
|
'index': function (req, res) {
|
|
|
|
/*jslint unparam:true*/
|
2014-06-23 11:01:43 -05:00
|
|
|
var userData,
|
2014-06-30 18:26:08 -05:00
|
|
|
// config we need on the frontend
|
2014-06-23 11:01:43 -05:00
|
|
|
frontConfig = {
|
2014-06-23 18:24:13 -05:00
|
|
|
apps: config().apps,
|
|
|
|
fileStorage: config().fileStorage
|
2014-06-23 11:01:43 -05:00
|
|
|
};
|
2014-05-09 00:00:10 -05:00
|
|
|
|
2014-02-25 05:51:12 -05:00
|
|
|
function renderIndex() {
|
2014-06-30 18:26:08 -05:00
|
|
|
res.render('default', {
|
|
|
|
user: userData,
|
|
|
|
config: JSON.stringify(frontConfig)
|
2014-02-25 05:51:12 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-07-08 23:17:30 -05:00
|
|
|
updateCheck().then(function () {
|
|
|
|
return updateCheck.showUpdateNotification();
|
|
|
|
}).then(function (updateAvailable) {
|
|
|
|
if (!updateAvailable) {
|
|
|
|
return when.resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
var notification = {
|
|
|
|
type: 'success',
|
|
|
|
location: 'top',
|
|
|
|
dismissible: false,
|
|
|
|
status: 'persistent',
|
|
|
|
message: 'A new version of Ghost is available! Hot Damn. <a href="https://ghost.org/download">Upgrade now</a>'
|
|
|
|
};
|
|
|
|
|
|
|
|
return api.notifications.browse().then(function (results) {
|
|
|
|
if (!_.some(results.notifications, { message: notification.message })) {
|
|
|
|
return api.notifications.add({ notifications: [notification] });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}).finally(function () {
|
|
|
|
renderIndex();
|
|
|
|
}).catch(errors.logError);
|
2013-06-25 06:43:15 -05:00
|
|
|
}
|
|
|
|
};
|
2013-05-11 11:44:25 -05:00
|
|
|
|
2013-08-08 20:22:49 -05:00
|
|
|
module.exports = adminControllers;
|