Used themeService as var name everywhere

This commit is contained in:
Hannah Wolfe 2021-04-16 19:48:05 +01:00
parent 5c41c67ffc
commit 08fbcf1d90
8 changed files with 21 additions and 20 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);
});
}

View File

@ -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}`);
}

View File

@ -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);
}

View File

@ -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();

View File

@ -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();

View File

@ -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();
});
},