From b9fc68b1b444fa5a23d157d0ac1619c234de879a Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Fri, 23 Apr 2021 15:16:59 +0100 Subject: [PATCH] Moved theme middleware to new theme engine service refs: https://github.com/TryGhost/Ghost/commit/bf0823c9a2ddbc93ad0ddcec36eed130c8c5a203 - continuing the work of splitting up the theme service into logical components --- core/frontend/services/theme-engine/index.js | 3 ++- .../services/{themes => theme-engine}/middleware.js | 6 +++--- core/frontend/services/themes/index.js | 1 - core/server/web/site/app.js | 3 +-- .../services/{themes => theme-engine}/middleware_spec.js | 3 +-- 5 files changed, 7 insertions(+), 9 deletions(-) rename core/frontend/services/{themes => theme-engine}/middleware.js (97%) rename test/unit/services/{themes => theme-engine}/middleware_spec.js (98%) diff --git a/core/frontend/services/theme-engine/index.js b/core/frontend/services/theme-engine/index.js index 8d5503fc7c..ef99cd0506 100644 --- a/core/frontend/services/theme-engine/index.js +++ b/core/frontend/services/theme-engine/index.js @@ -1,4 +1,5 @@ module.exports = { loadCoreHelpers: require('./handlebars/helpers').loadCoreHelpers, - getActive: require('./active').get + getActive: require('./active').get, + middleware: require('./middleware') }; diff --git a/core/frontend/services/themes/middleware.js b/core/frontend/services/theme-engine/middleware.js similarity index 97% rename from core/frontend/services/themes/middleware.js rename to core/frontend/services/theme-engine/middleware.js index 51fa1a2650..6bff5bef60 100644 --- a/core/frontend/services/themes/middleware.js +++ b/core/frontend/services/theme-engine/middleware.js @@ -1,13 +1,13 @@ const _ = require('lodash'); -const hbs = require('../theme-engine/engine'); +const hbs = require('./engine'); const urlUtils = require('../../../shared/url-utils'); const config = require('../../../shared/config'); const {i18n} = require('../proxy'); const errors = require('@tryghost/errors'); const settingsCache = require('../../../server/services/settings/cache'); const labs = require('../../../server/services/labs'); -const activeTheme = require('../theme-engine/active'); -const preview = require('../theme-engine/preview'); +const activeTheme = require('./active'); +const preview = require('./preview'); // ### Ensure Active Theme // Ensure there's a properly set & mounted active theme before attempting to serve a site request diff --git a/core/frontend/services/themes/index.js b/core/frontend/services/themes/index.js index 86de9c6cfe..5e92f3926c 100644 --- a/core/frontend/services/themes/index.js +++ b/core/frontend/services/themes/index.js @@ -91,7 +91,6 @@ module.exports = { }); }, storage: require('./storage'), - middleware: require('./middleware'), /** * Load all inactive themes */ diff --git a/core/server/web/site/app.js b/core/server/web/site/app.js index 078f955f8b..e6489530a3 100644 --- a/core/server/web/site/app.js +++ b/core/server/web/site/app.js @@ -15,8 +15,7 @@ const urlUtils = require('../../../shared/url-utils'); const sitemapHandler = require('../../../frontend/services/sitemap/handler'); const appService = require('../../../frontend/services/apps'); const themeEngine = require('../../../frontend/services/theme-engine'); -const themeService = require('../../../frontend/services/themes'); -const themeMiddleware = themeService.middleware; +const themeMiddleware = themeEngine.middleware; const membersMiddleware = require('../../services/members').middleware; const siteRoutes = require('./routes'); const shared = require('../shared'); diff --git a/test/unit/services/themes/middleware_spec.js b/test/unit/services/theme-engine/middleware_spec.js similarity index 98% rename from test/unit/services/themes/middleware_spec.js rename to test/unit/services/theme-engine/middleware_spec.js index da73ac4e06..0737799652 100644 --- a/test/unit/services/themes/middleware_spec.js +++ b/test/unit/services/theme-engine/middleware_spec.js @@ -1,11 +1,10 @@ const should = require('should'); const sinon = require('sinon'); const hbs = require('../../../../core/frontend/services/theme-engine/engine'); -const themeService = require('../../../../core/frontend/services/themes'); +const middleware = require('../../../../core/frontend/services/theme-engine').middleware; // is only exposed via themeEngine.getActive() const activeTheme = require('../../../../core/frontend/services/theme-engine/active'); const settingsCache = require('../../../../core/server/services/settings/cache'); -const middleware = themeService.middleware; const sandbox = sinon.createSandbox();