2013-12-06 12:51:35 +04:00
|
|
|
var config = require('../config'),
|
2014-07-09 08:17:30 +04:00
|
|
|
_ = require('lodash'),
|
2013-11-22 07:17:38 +04:00
|
|
|
when = require('when'),
|
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-02-27 03:15:31 +04:00
|
|
|
'index': function (req, res) {
|
|
|
|
/*jslint unparam:true*/
|
2014-06-23 20:01:43 +04:00
|
|
|
var userData,
|
2014-07-01 03:26:08 +04:00
|
|
|
// config we need on the frontend
|
2014-06-23 20:01:43 +04:00
|
|
|
frontConfig = {
|
2014-06-24 03:24:13 +04:00
|
|
|
apps: config().apps,
|
|
|
|
fileStorage: config().fileStorage
|
2014-06-23 20:01:43 +04:00
|
|
|
};
|
2014-05-09 09:00:10 +04:00
|
|
|
|
2014-02-25 14:51:12 +04:00
|
|
|
function renderIndex() {
|
2014-07-01 03:26:08 +04:00
|
|
|
res.render('default', {
|
|
|
|
user: userData,
|
|
|
|
config: JSON.stringify(frontConfig)
|
2014-02-25 14:51:12 +04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-07-09 08:17:30 +04: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 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;
|