0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00
ghost/core/server/admin/controller.js
Katharina Irrgang ea0f696c4d 🐛 fix usages of logError (#8138)
no issue
2017-03-13 19:47:09 +00:00

40 lines
1.4 KiB
JavaScript

var debug = require('debug')('ghost:admin:controller'),
_ = require('lodash'),
api = require('../api'),
updateCheck = require('../update-check'),
logging = require('../logging'),
i18n = require('../i18n');
// Route: index
// Path: /ghost/
// Method: GET
module.exports = function adminController(req, res) {
/*jslint unparam:true*/
debug('index called');
updateCheck().then(function then() {
return updateCheck.showUpdateNotification();
}).then(function then(updateVersion) {
if (!updateVersion) {
return;
}
var notification = {
status: 'alert',
type: 'info',
location: 'upgrade.new-version-available',
dismissible: false,
message: i18n.t('notices.controllers.newVersionAvailable',
{version: updateVersion, link: '<a href="http://support.ghost.org/how-to-upgrade/" target="_blank">Click here</a>'})};
return api.notifications.browse({context: {internal: true}}).then(function then(results) {
if (!_.some(results.notifications, {message: notification.message})) {
return api.notifications.add({notifications: [notification]}, {context: {internal: true}});
}
});
}).finally(function noMatterWhat() {
res.render('default');
}).catch(function (err) {
logging.error(err);
});
};