Ghost/core/server/controllers/admin.js
Sebastian Gierlinger 05b3606fd3 Remove inline script from default.hbs
no issue
- added config values as data attributes
- removed inline script
- removed current-user.js
2014-07-21 20:00:54 +02:00

46 lines
1.4 KiB
JavaScript

var _ = require('lodash'),
when = require('when'),
api = require('../api'),
errors = require('../errors'),
updateCheck = require('../update-check'),
adminControllers;
adminControllers = {
// Route: index
// Path: /ghost/
// Method: GET
'index': function (req, res) {
/*jslint unparam:true*/
function renderIndex() {
res.render('default');
}
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] }, {context: {internal: true}});
}
});
}).finally(function () {
renderIndex();
}).catch(errors.logError);
}
};
module.exports = adminControllers;