0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

🔥 Remove handlebars from serving admin (#8184)

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
This commit is contained in:
Hannah Wolfe 2017-03-20 12:00:18 +00:00 committed by Kevin Ansfield
parent 2419c0ff2e
commit d294177966
4 changed files with 13 additions and 21 deletions

2
.gitignore vendored
View file

@ -65,7 +65,7 @@ config.*.json
# Built asset files
/core/built
/core/server/admin/views/default*.hbs
/core/server/admin/views/*
/core/shared/ghost-url.min.js
# Coverage reports

View file

@ -46,7 +46,7 @@ var overrides = require('./core/server/overrides'),
pkg: grunt.file.readJSON('package.json'),
clientFiles: [
'server/admin/views/default.hbs',
'server/admin/views/default.html',
'built/assets/ghost.js',
'built/assets/ghost.css',
'built/assets/vendor.js',

View file

@ -1,8 +1,6 @@
var debug = require('debug')('ghost:admin'),
config = require('../config'),
express = require('express'),
adminHbs = require('express-hbs').create(),
// Admin only middleware
adminMiddleware = require('./middleware'),
@ -27,14 +25,6 @@ module.exports = function setupAdminApp() {
next();
});
// @TODO replace all this with serving ember's index.html
// Create a hbs instance for admin and init view engine
adminApp.set('view engine', 'hbs');
adminApp.set('views', config.get('paths').adminViews);
adminApp.engine('hbs', adminHbs.express3({}));
// Register our `asset` helper
adminHbs.registerHelper('asset', require('../helpers/asset'));
// Admin assets
// @TODO ensure this gets a local 404 error handler
configMaxAge = config.get('caching:admin:maxAge');

View file

@ -1,10 +1,11 @@
var debug = require('debug')('ghost:admin:controller'),
_ = require('lodash'),
config = require('../config'),
api = require('../api'),
updateCheck = require('../update-check'),
logging = require('../logging'),
i18n = require('../i18n');
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/
@ -34,9 +35,10 @@ module.exports = function adminController(req, res) {
}
});
}).finally(function noMatterWhat() {
var defaultTemplate = config.get('env') === 'production' ? 'default-prod' : 'default';
var defaultTemplate = config.get('env') === 'production' ? 'default-prod.html' : 'default.html',
templatePath = path.resolve(config.get('paths').adminViews, defaultTemplate);
res.render(defaultTemplate);
res.sendFile(templatePath);
}).catch(function (err) {
logging.error(err);
});