From d294177966b96306619404f6266cda99b4b69d2c Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Mon, 20 Mar 2017 12:00:18 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Remove=20handlebars=20from=20ser?= =?UTF-8?q?ving=20admin=20(#8184)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .gitignore | 2 +- Gruntfile.js | 2 +- core/server/admin/app.js | 10 ---------- core/server/admin/controller.js | 20 +++++++++++--------- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 171741400e..9132708bd1 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Gruntfile.js b/Gruntfile.js index a10d014dab..c59454f567 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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', diff --git a/core/server/admin/app.js b/core/server/admin/app.js index d8191c5b47..76e0473a98 100644 --- a/core/server/admin/app.js +++ b/core/server/admin/app.js @@ -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'); diff --git a/core/server/admin/controller.js b/core/server/admin/controller.js index a5b0947819..9e6d9c3f05 100644 --- a/core/server/admin/controller.js +++ b/core/server/admin/controller.js @@ -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); });