0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Moved handle-image-sizes mw into site app

- Moved handle-image-sizes from shared to site as it is not shared
- This file is only used in one place, this updates the code structure to reflect this
- This is one of many similar changes needed to make it easier to refactor to the existing setup
This commit is contained in:
Hannah Wolfe 2020-04-21 15:42:22 +01:00
parent 9fe741c9b9
commit dbafaf7205
5 changed files with 5 additions and 7 deletions

View file

@ -1,8 +1,5 @@
module.exports = {
get normalize() {
return require('./normalize');
},
get handleImageSizes() {
return require('./handle-image-sizes');
}
};

View file

@ -125,7 +125,7 @@ module.exports = function setupSiteApp(options = {}) {
siteApp.use(shared.middlewares.servePublicFile('public/404-ghost.png', 'image/png', constants.ONE_HOUR_S));
// Serve blog images using the storage adapter
siteApp.use(STATIC_IMAGE_URL_PREFIX, shared.middlewares.image.handleImageSizes, storage.getStorage().serve());
siteApp.use(STATIC_IMAGE_URL_PREFIX, mw.handleImageSizes, storage.getStorage().serve());
// @TODO find this a better home
// We do this here, at the top level, because helpers require so much stuff.

View file

@ -1,7 +1,7 @@
const path = require('path');
const imageTransform = require('@tryghost/image-transform');
const storage = require('../../../../adapters/storage');
const activeTheme = require('../../../../../frontend/services/themes/active');
const storage = require('../../../adapters/storage');
const activeTheme = require('../../../../frontend/services/themes/active');
const SIZE_PATH_REGEX = /^\/size\/([^/]+)\//;
const TRAILING_SLASH_REGEX = /\/+$/;

View file

@ -1,5 +1,6 @@
module.exports = {
adminRedirects: require('./admin-redirects'),
handleImageSizes: require('./handle-image-sizes'),
serveFavicon: require('./serve-favicon'),
staticTheme: require('./static-theme')
};

View file

@ -1,5 +1,5 @@
const should = require('should');
const handleImageSizes = require('../../../../../core/server/web/shared/middlewares/image/handle-image-sizes.js');
const handleImageSizes = require('../../../../../core/server/web/site/middleware/handle-image-sizes.js');
// @TODO make these tests lovely and non specific to implementation
describe('handleImageSizes middleware', function () {