refactored 'lib/image' imports to use destructuring (#11847)

* refactored 'lib/image' imports to use destructuring
* trigger all-tests
This commit is contained in:
Vikas Potluri 2020-05-26 13:11:23 -05:00 committed by GitHub
parent c86933f44f
commit aeee302c9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 28 deletions

View File

@ -1,6 +1,6 @@
const crypto = require('crypto');
const config = require('../../server/config');
const imageLib = require('../../server/lib/image');
const {blogIcon} = require('../../server/lib/image');
const urlUtils = require('../../server/lib/url-utils');
/**
@ -8,7 +8,7 @@ const urlUtils = require('../../server/lib/url-utils');
* @return {string}
*/
function getFaviconUrl() {
return imageLib.blogIcon.getIconUrl();
return blogIcon.getIconUrl();
}
function getAssetUrl(path, hasMinFile) {

View File

@ -1,6 +1,6 @@
const urlUtils = require('../../server/lib/url-utils');
const settingsCache = require('../../server/services/settings/cache');
const imageLib = require('../../server/lib/image');
const {blogIcon} = require('../../server/lib/image');
function getBlogLogo() {
const logo = {};
@ -11,7 +11,7 @@ function getBlogLogo() {
// CASE: no publication logo is updated. We can try to use either an uploaded publication icon
// or use the default one to make
// Google happy with it. See https://github.com/TryGhost/Ghost/issues/7558
logo.url = imageLib.blogIcon.getIconUrl(true);
logo.url = blogIcon.getIconUrl(true);
}
return logo;

View File

@ -1,6 +1,6 @@
const Promise = require('bluebird');
const _ = require('lodash');
const imageLib = require('../../server/lib/image');
const {imageSizeCache} = require('../../server/lib/image');
/**
* Get Image dimensions
@ -11,10 +11,10 @@ const imageLib = require('../../server/lib/image');
*/
function getImageDimensions(metaData) {
const fetch = {
coverImage: imageLib.imageSizeCache(metaData.coverImage.url),
authorImage: imageLib.imageSizeCache(metaData.authorImage.url),
ogImage: imageLib.imageSizeCache(metaData.ogImage.url),
logo: imageLib.imageSizeCache(metaData.site.logo.url)
coverImage: imageSizeCache(metaData.coverImage.url),
authorImage: imageSizeCache(metaData.authorImage.url),
ogImage: imageSizeCache(metaData.ogImage.url),
logo: imageSizeCache(metaData.site.logo.url)
};
return Promise

View File

@ -2,10 +2,10 @@ const jsonSchema = require('../utils/json-schema');
const config = require('../../../../../config');
const {i18n} = require('../../../../../lib/common');
const errors = require('@tryghost/errors');
const imageLib = require('../../../../../lib/image');
const {imageSize, blogIcon} = require('../../../../../lib/image');
const profileImage = (frame) => {
return imageLib.imageSize.getImageSizeFromPath(frame.file.path).then((response) => {
return imageSize.getImageSizeFromPath(frame.file.path).then((response) => {
// save the image dimensions in new property for file
frame.file.dimensions = response;
@ -32,7 +32,7 @@ const icon = (frame) => {
}));
}
return imageLib.blogIcon.getIconDimensions(frame.file.path).then((response) => {
return blogIcon.getIconDimensions(frame.file.path).then((response) => {
// save the image dimensions in new property for file
frame.file.dimensions = response;

View File

@ -2,10 +2,10 @@ const jsonSchema = require('../utils/json-schema');
const config = require('../../../../../config');
const {i18n} = require('../../../../../lib/common');
const errors = require('@tryghost/errors');
const imageLib = require('../../../../../lib/image');
const {imageSize, blogIcon} = require('../../../../../lib/image');
const profileImage = (frame) => {
return imageLib.imageSize.getImageSizeFromPath(frame.file.path).then((response) => {
return imageSize.getImageSizeFromPath(frame.file.path).then((response) => {
// save the image dimensions in new property for file
frame.file.dimensions = response;
@ -32,7 +32,7 @@ const icon = (frame) => {
}));
}
return imageLib.blogIcon.getIconDimensions(frame.file.path).then((response) => {
return blogIcon.getIconDimensions(frame.file.path).then((response) => {
// save the image dimensions in new property for file
frame.file.dimensions = response;

View File

@ -7,7 +7,7 @@ const baseUtils = require('./base/utils');
const {i18n} = require('../lib/common');
const errors = require('@tryghost/errors');
const security = require('../lib/security');
const imageLib = require('../lib/image');
const {gravatar} = require('../lib/image');
const pipeline = require('../lib/promise/pipeline');
const validation = require('../data/validation');
const permissions = require('../services/permissions');
@ -134,7 +134,7 @@ User = ghostBookshelf.Model.extend({
// If the user's email is set & has changed & we are not importing
if (self.hasChanged('email') && self.get('email') && !options.importing) {
tasks.gravatar = (function lookUpGravatar() {
return imageLib.gravatar.lookup({
return gravatar.lookup({
email: self.get('email')
}).then(function (response) {
if (response && response.image) {

View File

@ -1,7 +1,7 @@
const errors = require('@tryghost/errors');
const {events, i18n, logging} = require('../lib/common');
const request = require('../lib/request');
const imageLib = require('../lib/image');
const {blogIcon} = require('../lib/image');
const urlUtils = require('../lib/url-utils');
const urlService = require('../../frontend/services/url');
const settingsCache = require('./settings/cache');
@ -73,7 +73,7 @@ function ping(post) {
// if it is a post or a test message to check webhook working.
text: `Notification from *${blogTitle}* :ghost:`,
unfurl_links: true,
icon_url: imageLib.blogIcon.getIconUrl(true),
icon_url: blogIcon.getIconUrl(true),
username: slackSettings.username,
// We don't want to send attachment if it is a test notification.
attachments: [
@ -104,7 +104,7 @@ function ping(post) {
}
],
footer: blogTitle,
footer_icon: imageLib.blogIcon.getIconUrl(true),
footer_icon: blogIcon.getIconUrl(true),
ts: moment().unix()
}
]
@ -113,7 +113,7 @@ function ping(post) {
slackData = {
text: message,
unfurl_links: true,
icon_url: imageLib.blogIcon.getIconUrl(true),
icon_url: blogIcon.getIconUrl(true),
username: slackSettings.username
};
}

View File

@ -2,7 +2,7 @@ const fs = require('fs-extra');
const path = require('path');
const crypto = require('crypto');
const config = require('../../../config');
const imageLib = require('../../../lib/image');
const {blogIcon} = require('../../../lib/image');
const storage = require('../../../adapters/storage');
const urlUtils = require('../../../lib/url-utils');
const settingsCache = require('../../../services/settings/cache');
@ -37,7 +37,7 @@ function serveFavicon() {
// we are using an express route to skip /content/images and the result is a image path
// based on config.getContentPath('images') + req.path
// in this case we don't use path rewrite, that's why we have to make it manually
filePath = imageLib.blogIcon.getIconPath();
filePath = blogIcon.getIconPath();
let originalExtension = path.extname(filePath).toLowerCase();
const requestedExtension = path.extname(req.path).toLowerCase();
@ -52,7 +52,7 @@ function serveFavicon() {
storage.getStorage()
.read({path: filePath})
.then((buf) => {
iconType = imageLib.blogIcon.getIconType();
iconType = blogIcon.getIconType();
content = buildContentResponse(iconType, buf);
res.writeHead(200, content.headers);

View File

@ -38,7 +38,7 @@ describe('getImageDimensions', function () {
type: 'jpg'
});
getImageDimensions.__set__('imageLib', {imageSizeCache: sizeOfStub});
getImageDimensions.__set__('imageSizeCache', sizeOfStub);
getImageDimensions(metaData).then(function (result) {
should.exist(result);
@ -89,7 +89,7 @@ describe('getImageDimensions', function () {
sizeOfStub.returns({});
getImageDimensions.__set__('imageLib', {imageSizeCache: sizeOfStub});
getImageDimensions.__set__('imageSizeCache', sizeOfStub);
getImageDimensions(metaData).then(function (result) {
should.exist(result);
@ -133,7 +133,7 @@ describe('getImageDimensions', function () {
type: 'jpg'
});
getImageDimensions.__set__('imageLib', {imageSizeCache: sizeOfStub});
getImageDimensions.__set__('imageSizeCache', sizeOfStub);
getImageDimensions(metaData).then(function (result) {
should.exist(result);
@ -185,7 +185,7 @@ describe('getImageDimensions', function () {
type: 'jpg'
});
getImageDimensions.__set__('imageLib', {imageSizeCache: sizeOfStub});
getImageDimensions.__set__('imageSizeCache', sizeOfStub);
getImageDimensions(metaData).then(function (result) {
should.exist(result);