Skip to content

Commit

Permalink
🔥 Remove handlebars from serving admin (TryGhost#8184)
Browse files Browse the repository at this point in the history
refs TryGhost#8140
refs TryGhost/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
  • Loading branch information
ErisDS authored and kevinansfield committed Mar 20, 2017
1 parent 2419c0f commit d294177
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 0 additions & 10 deletions core/server/admin/app.js
Original file line number Diff line number Diff line change
@@ -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'),

Expand All @@ -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');
Expand Down
20 changes: 11 additions & 9 deletions core/server/admin/controller.js
Original file line number Diff line number Diff line change
@@ -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/
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit d294177

Please sign in to comment.