mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
7eacd2876d
refs #5091 - adds names to all middleware functions, for debugging purposes
55 lines
2.0 KiB
JavaScript
55 lines
2.0 KiB
JavaScript
var _ = require('lodash'),
|
|
api = require('../api'),
|
|
errors = require('../errors'),
|
|
updateCheck = require('../update-check'),
|
|
config = require('../config'),
|
|
adminControllers;
|
|
|
|
adminControllers = {
|
|
// Route: index
|
|
// Path: /ghost/
|
|
// Method: GET
|
|
index: function index(req, res) {
|
|
/*jslint unparam:true*/
|
|
|
|
function renderIndex() {
|
|
return api.configuration.browse().then(function then(data) {
|
|
var apiConfig = _.omit(data.configuration, function omit(value) {
|
|
return _.contains(['environment', 'database', 'mail', 'version'], value.key);
|
|
});
|
|
|
|
res.render('default', {
|
|
skip_google_fonts: config.isPrivacyDisabled('useGoogleFonts'),
|
|
configuration: apiConfig
|
|
});
|
|
});
|
|
}
|
|
|
|
updateCheck().then(function then() {
|
|
return updateCheck.showUpdateNotification();
|
|
}).then(function then(updateVersion) {
|
|
if (!updateVersion) {
|
|
return;
|
|
}
|
|
|
|
var notification = {
|
|
type: 'upgrade',
|
|
location: 'settings-about-upgrade',
|
|
dismissible: false,
|
|
status: 'persistent',
|
|
message: 'Ghost ' + updateVersion + ' is available! Hot Damn. <a href="http://support.ghost.org/how-to-upgrade/" target="_blank">Click here</a> to upgrade.'
|
|
};
|
|
|
|
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() {
|
|
renderIndex();
|
|
}).catch(errors.logError);
|
|
}
|
|
};
|
|
|
|
module.exports = adminControllers;
|