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