2014-07-21 20:00:54 +02:00
|
|
|
var _ = require('lodash'),
|
2013-11-21 21:17:38 -06:00
|
|
|
when = require('when'),
|
2014-07-09 04:17:30 +00:00
|
|
|
api = require('../api'),
|
2014-05-09 12:11:29 +02:00
|
|
|
errors = require('../errors'),
|
2014-01-03 15:50:03 +00:00
|
|
|
updateCheck = require('../update-check'),
|
2014-07-01 00:26:08 +01:00
|
|
|
adminControllers;
|
2013-05-29 01:10:39 +01:00
|
|
|
|
2013-06-25 12:43:15 +01:00
|
|
|
adminControllers = {
|
2014-07-01 00:26:08 +01:00
|
|
|
// Route: index
|
|
|
|
// Path: /ghost/
|
|
|
|
// Method: GET
|
2014-02-26 23:15:31 +00:00
|
|
|
'index': function (req, res) {
|
|
|
|
/*jslint unparam:true*/
|
2014-05-09 00:00:10 -05:00
|
|
|
|
2014-02-25 10:51:12 +00:00
|
|
|
function renderIndex() {
|
2014-07-21 20:00:54 +02:00
|
|
|
res.render('default');
|
2014-02-25 10:51:12 +00:00
|
|
|
}
|
|
|
|
|
2014-07-09 04:17:30 +00: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 })) {
|
2014-07-17 09:48:39 +01:00
|
|
|
return api.notifications.add({ notifications: [notification] }, {context: {internal: true}});
|
2014-07-09 04:17:30 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}).finally(function () {
|
|
|
|
renderIndex();
|
|
|
|
}).catch(errors.logError);
|
2013-06-25 12:43:15 +01:00
|
|
|
}
|
|
|
|
};
|
2013-05-11 17:44:25 +01:00
|
|
|
|
2013-08-09 02:22:49 +01:00
|
|
|
module.exports = adminControllers;
|