diff --git a/core/frontend/services/routing/controllers/channel.js b/core/frontend/services/routing/controllers/channel.js index 06dfe85154..75833a2169 100644 --- a/core/frontend/services/routing/controllers/channel.js +++ b/core/frontend/services/routing/controllers/channel.js @@ -3,7 +3,7 @@ const debug = require('ghost-ignition').debug('services:routing:controllers:chan const {i18n} = require('../../../../server/lib/common'); const errors = require('@tryghost/errors'); const security = require('@tryghost/security'); -const themes = require('../../themes'); +const themeService = require('../../themes'); const helpers = require('../helpers'); /** @@ -28,7 +28,7 @@ module.exports = function channelController(req, res, next) { // CASE 1: routes.yaml `limit` is stronger than theme definition // CASE 2: use `posts_per_page` config from theme as `limit` value if (res.routerOptions.limit) { - themes.getActive().updateTemplateOptions({ + themeService.getActive().updateTemplateOptions({ data: { config: { posts_per_page: res.routerOptions.limit @@ -38,7 +38,7 @@ module.exports = function channelController(req, res, next) { pathOptions.limit = res.routerOptions.limit; } else { - const postsPerPage = parseInt(themes.getActive().config('posts_per_page')); + const postsPerPage = parseInt(themeService.getActive().config('posts_per_page')); if (!isNaN(postsPerPage) && postsPerPage > 0) { pathOptions.limit = postsPerPage; diff --git a/core/frontend/services/routing/controllers/collection.js b/core/frontend/services/routing/controllers/collection.js index d4064b871c..603c2133d5 100644 --- a/core/frontend/services/routing/controllers/collection.js +++ b/core/frontend/services/routing/controllers/collection.js @@ -4,7 +4,7 @@ const {i18n} = require('../../proxy'); const errors = require('@tryghost/errors'); const security = require('@tryghost/security'); const urlService = require('../../url'); -const themes = require('../../themes'); +const themeService = require('../../themes'); const helpers = require('../helpers'); /** @@ -26,7 +26,7 @@ module.exports = function collectionController(req, res, next) { // CASE 1: routes.yaml `limit` is stronger than theme definition // CASE 2: use `posts_per_page` config from theme as `limit` value if (res.routerOptions.limit) { - themes.getActive().updateTemplateOptions({ + themeService.getActive().updateTemplateOptions({ data: { config: { posts_per_page: res.routerOptions.limit @@ -36,7 +36,7 @@ module.exports = function collectionController(req, res, next) { pathOptions.limit = res.routerOptions.limit; } else { - const postsPerPage = parseInt(themes.getActive().config('posts_per_page')); + const postsPerPage = parseInt(themeService.getActive().config('posts_per_page')); if (!isNaN(postsPerPage) && postsPerPage > 0) { pathOptions.limit = postsPerPage; diff --git a/core/frontend/services/routing/helpers/templates.js b/core/frontend/services/routing/helpers/templates.js index 2edefbcd42..a36e0a6e52 100644 --- a/core/frontend/services/routing/helpers/templates.js +++ b/core/frontend/services/routing/helpers/templates.js @@ -7,7 +7,7 @@ const _ = require('lodash'); const path = require('path'); const url = require('url'); const config = require('../../../../shared/config'); -const themes = require('../../themes'); +const themeService = require('../../themes'); const _private = {}; /** @@ -116,7 +116,7 @@ _private.pickTemplate = function pickTemplate(templateList, fallback) { templateList = [templateList]; } - if (!themes.getActive()) { + if (!themeService.getActive()) { template = fallback; } else { template = _.find(templateList, function (templateName) { @@ -124,7 +124,7 @@ _private.pickTemplate = function pickTemplate(templateList, fallback) { return; } - return themes.getActive().hasTemplate(templateName); + return themeService.getActive().hasTemplate(templateName); }); } diff --git a/core/frontend/services/url/Resources.js b/core/frontend/services/url/Resources.js index b625447ed8..f762e6fab4 100644 --- a/core/frontend/services/url/Resources.js +++ b/core/frontend/services/url/Resources.js @@ -52,7 +52,8 @@ class Resources { return this.resourceConfig; } - this.resourcesAPIVersion = require('../themes').getApiVersion(); + const themeService = require('../themes'); + this.resourcesAPIVersion = themeService.getApiVersion(); this.resourcesConfig = require(`./configs/${this.resourcesAPIVersion}`); } diff --git a/core/server/web/site/middleware/static-theme.js b/core/server/web/site/middleware/static-theme.js index f7de8ef0d9..a97b851eb3 100644 --- a/core/server/web/site/middleware/static-theme.js +++ b/core/server/web/site/middleware/static-theme.js @@ -1,7 +1,7 @@ const path = require('path'); const config = require('../../../../shared/config'); const constants = require('@tryghost/constants'); -const themeUtils = require('../../../../frontend/services/themes'); +const themeService = require('../../../../frontend/services/themes'); const express = require('../../../../shared/express'); function isBlackListedFileType(file) { @@ -19,13 +19,13 @@ function isWhiteListedFile(file) { } function forwardToExpressStatic(req, res, next) { - if (!themeUtils.getActive()) { + if (!themeService.getActive()) { return next(); } const configMaxAge = config.get('caching:theme:maxAge'); - express.static(themeUtils.getActive().path, + express.static(themeService.getActive().path, {maxAge: (configMaxAge || configMaxAge === 0) ? configMaxAge : constants.ONE_YEAR_MS} )(req, res, next); } diff --git a/test/utils/fixture-utils.js b/test/utils/fixture-utils.js index 24a4885d8e..e58dcb861a 100644 --- a/test/utils/fixture-utils.js +++ b/test/utils/fixture-utils.js @@ -15,7 +15,7 @@ const emailAnalyticsService = require('../../core/server/services/email-analytic const permissions = require('../../core/server/services/permissions'); const settingsService = require('../../core/server/services/settings'); const settingsCache = require('../../core/server/services/settings/cache'); -const themes = require('../../core/frontend/services/themes'); +const themeService = require('../../core/frontend/services/themes'); // Other Test Utilities const context = require('./fixtures/context'); @@ -584,7 +584,7 @@ const toDoList = { return fixtures.insertInvites(); }, themes: function loadThemes() { - return themes.loadAll(); + return themeService.loadAll(); }, webhooks: function insertWebhooks() { return fixtures.insertWebhooks(); diff --git a/test/utils/index.js b/test/utils/index.js index e60a974b36..f63b52a440 100644 --- a/test/utils/index.js +++ b/test/utils/index.js @@ -23,7 +23,7 @@ const settingsService = require('../../core/server/services/settings'); const frontendSettingsService = require('../../core/frontend/services/settings'); const settingsCache = require('../../core/server/services/settings/cache'); const web = require('../../core/server/web'); -const themes = require('../../core/frontend/services/themes'); +const themeService = require('../../core/frontend/services/themes'); const limits = require('../../core/server/services/limits'); // Other Test Utilities @@ -194,7 +194,7 @@ const restartModeGhostStart = async () => { // Reload the frontend await frontendSettingsService.init(); - await themes.init(); + await themeService.init(); // Reload the URL service & wait for it to be ready again // @TODO: Prob B: why/how is this different to urlService.resetGenerators? @@ -205,7 +205,7 @@ const restartModeGhostStart = async () => { web.shared.middlewares.customRedirects.reload(); // Trigger themes to load again - themes.loadInactiveThemes(); + themeService.loadInactiveThemes(); // Reload limits service limits.init(); diff --git a/test/utils/old-integration-utils.js b/test/utils/old-integration-utils.js index 1f16972ee6..aa36eb8b4c 100644 --- a/test/utils/old-integration-utils.js +++ b/test/utils/old-integration-utils.js @@ -7,7 +7,7 @@ const routingService = require('../../core/frontend/services/routing'); const settingsService = require('../../core/server/services/settings'); const settingsCache = require('../../core/server/services/settings/cache'); const imageLib = require('../../core/server/lib/image'); -const themes = require('../../core/frontend/services/themes'); +const themeServices = require('../../core/frontend/services/themes'); // Other Test Utilities const configUtils = require('./configUtils'); @@ -46,7 +46,7 @@ module.exports = { return settingsService.init() .then(() => { - return themes.init(); + return themeServices.init(); }); },