0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Reordered requires in proxy into logical groups

This commit is contained in:
Hannah Wolfe 2021-09-28 11:41:10 +01:00
parent b98b190097
commit b89a4c23a2
No known key found for this signature in database
GPG key ID: 9F8C7532D0A6BA55

View file

@ -1,58 +1,32 @@
// This file defines everything that helpers "require"
// With the exception of modules like lodash, Bluebird
// We can later refactor to enforce this something like we did in apps
// This file contains everything that the helpers and frontend apps require from the core of Ghost
const hbs = require('./theme-engine/engine');
const settingsCache = require('../../shared/settings-cache');
const config = require('../../shared/config');
// Direct requires:
// - lodash
// - bluebird
// - downsize
// - moment-timezone
// - jsonpath
module.exports = {
/**
* Section one: Frontend Framework
* These all belong to the frontend rendering layer
*/
hbs: hbs,
SafeString: hbs.SafeString,
escapeExpression: hbs.escapeExpression,
// TODO: Expose less of the API to make this safe
api: require('../../server/api'),
// TODO: Only expose "get"
settingsCache: settingsCache,
// The local template thing, should this be merged with the channels one?
templates: require('./theme-engine/handlebars/template'),
// Theme i18n is separate to common i18n
themeI18n: require('./theme-engine/i18n'),
// This is used to detect if "isPost" is true in prevNext.
checks: require('../../server/data/schema').checks,
// Config!
// Keys used:
// isPrivacyDisabled & referrerPolicy used in ghost_head
config: {
get: config.get.bind(config),
isPrivacyDisabled: config.isPrivacyDisabled.bind(config)
},
// Labs utils for enabling/disabling helpers
labs: require('../../shared/labs'),
// Things required from data/meta
metaData: require('../meta'),
// The local template thing, should this be merged with the channels one?
templates: require('./theme-engine/handlebars/template'),
// Various utils, needs cleaning up / simplifying
socialUrls: require('@tryghost/social-urls'),
blogIcon: require('../../server/lib/image').blogIcon,
urlService: require('./url'),
urlUtils: require('../../shared/url-utils'),
// TODO: these need a more sensible home
localUtils: require('./theme-engine/handlebars/utils'),
/**
* Section two: data manipulation
* Stuff that modifies API data (SDK layer)
*/
metaData: require('../meta'),
socialUrls: require('@tryghost/social-urls'),
blogIcon: require('../../server/lib/image').blogIcon,
// Used by router service and {{get}} helper to prepare data for optimal usage in themes
prepareContextResource(data) {
(Array.isArray(data) ? data : [data]).forEach((resource) => {
@ -61,5 +35,31 @@ module.exports = {
resource.feature_image_caption = new hbs.SafeString(resource.feature_image_caption);
}
});
}
},
// This is used to decide e.g. if a JSON object is a Post, Page, Tag etc
checks: require('../../server/data/schema').checks,
/**
* Section three: Core API
* Parts of Ghost core that the frontend currently needs
*/
// Config! Keys used:
// isPrivacyDisabled & referrerPolicy used in ghost_head
config: {
get: config.get.bind(config),
isPrivacyDisabled: config.isPrivacyDisabled.bind(config)
},
// TODO: Only expose "get"
settingsCache: settingsCache,
// TODO: Expose less of the API to make this safe
api: require('../../server/api'),
// Labs utils for enabling/disabling helpers
labs: require('../../shared/labs'),
// URGH... Yuk (unhelpful comment :D)
urlService: require('./url'),
urlUtils: require('../../shared/url-utils')
};