mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
d294177966
refs TryGhost/Ghost#8140 refs TryGhost/Ghost-Admin#593 - now that the admin index page is just html, we don't need handlebars anymore - as we can use res.sendFile to send the static HTML file, don't need to "render" it anymore - remove the view engine, hbs and the use of helpers - it's all unneeded - change the filenames to .html to reflect this
46 lines
1.7 KiB
JavaScript
46 lines
1.7 KiB
JavaScript
var debug = require('debug')('ghost:admin:controller'),
|
|
_ = require('lodash'),
|
|
path = require('path'),
|
|
config = require('../config'),
|
|
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() {
|
|
var defaultTemplate = config.get('env') === 'production' ? 'default-prod.html' : 'default.html',
|
|
templatePath = path.resolve(config.get('paths').adminViews, defaultTemplate);
|
|
|
|
res.sendFile(templatePath);
|
|
}).catch(function (err) {
|
|
logging.error(err);
|
|
});
|
|
};
|