2014-07-21 22:00:54 +04:00
|
|
|
var _ = require('lodash'),
|
2014-07-09 08:17:30 +04:00
|
|
|
api = require('../api'),
|
2014-05-09 14:11:29 +04:00
|
|
|
errors = require('../errors'),
|
2014-01-03 19:50:03 +04:00
|
|
|
updateCheck = require('../update-check'),
|
2014-07-01 03:26:08 +04:00
|
|
|
adminControllers;
|
2013-05-29 04:10:39 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
adminControllers = {
|
2014-07-01 03:26:08 +04:00
|
|
|
// Route: index
|
|
|
|
// Path: /ghost/
|
|
|
|
// Method: GET
|
2014-08-17 10:17:23 +04:00
|
|
|
index: function (req, res) {
|
2014-02-27 03:15:31 +04:00
|
|
|
/*jslint unparam:true*/
|
2014-05-09 09:00:10 +04:00
|
|
|
|
2014-02-25 14:51:12 +04:00
|
|
|
function renderIndex() {
|
2014-07-21 22:00:54 +04:00
|
|
|
res.render('default');
|
2014-02-25 14:51:12 +04:00
|
|
|
}
|
|
|
|
|
2014-07-09 08:17:30 +04:00
|
|
|
updateCheck().then(function () {
|
|
|
|
return updateCheck.showUpdateNotification();
|
2014-08-06 03:48:44 +04:00
|
|
|
}).then(function (updateVersion) {
|
|
|
|
if (!updateVersion) {
|
2014-08-17 10:17:23 +04:00
|
|
|
return;
|
2014-07-09 08:17:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
var notification = {
|
|
|
|
type: 'success',
|
|
|
|
location: 'top',
|
|
|
|
dismissible: false,
|
|
|
|
status: 'persistent',
|
2014-08-06 03:48:44 +04:00
|
|
|
message: '<a href="https://ghost.org/download">Ghost ' + updateVersion +
|
2014-08-15 18:46:24 +04:00
|
|
|
'</a> is available! Hot Damn. Please <a href="http://support.ghost.org/how-to-upgrade/" target="_blank">upgrade</a> now'
|
2014-07-09 08:17:30 +04:00
|
|
|
};
|
|
|
|
|
2014-08-06 03:48:44 +04:00
|
|
|
return api.notifications.browse({context: {internal: true}}).then(function (results) {
|
2014-07-09 08:17:30 +04:00
|
|
|
if (!_.some(results.notifications, { message: notification.message })) {
|
2014-07-17 12:48:39 +04:00
|
|
|
return api.notifications.add({ notifications: [notification] }, {context: {internal: true}});
|
2014-07-09 08:17:30 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}).finally(function () {
|
|
|
|
renderIndex();
|
|
|
|
}).catch(errors.logError);
|
2013-06-25 15:43:15 +04:00
|
|
|
}
|
|
|
|
};
|
2013-05-11 20:44:25 +04:00
|
|
|
|
2013-08-09 05:22:49 +04:00
|
|
|
module.exports = adminControllers;
|