mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
fd20f90cca
- The original intention of the proxy was to collect up all the requires in our helpers into one place - This has since been expanded and used in more places, in more ways - In hindsight there are now multiple different types of requires in the proxy: - One: true frontend rendering framework requires (stuff from deep inside theme-engine) - Two: data manipulation/sdk stuff, belongs to the frontend, ways to process API data - Three: actual core stuff from Ghost, that we wish wasn't here / needs to be passed in a controlled way - This commit pulls out One into a new rendering service, so at least that stuff is managed independently - This draws the lines clearly between what's internal to the frontend and what isn't - It also highlights that the theme-engine needs to be divided up / refactored so that we don't have these deep requires
52 lines
1.8 KiB
JavaScript
52 lines
1.8 KiB
JavaScript
// This file contains everything that the helpers and frontend apps require from the core of Ghost
|
|
const settingsCache = require('../../shared/settings-cache');
|
|
const config = require('../../shared/config');
|
|
|
|
// Require from the rendering framework
|
|
const {SafeString} = require('./rendering');
|
|
|
|
module.exports = {
|
|
/**
|
|
* 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) => {
|
|
// feature_image_caption contains HTML, making it a SafeString spares theme devs from triple-curlies
|
|
if (resource.feature_image_caption) {
|
|
resource.feature_image_caption = new 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')
|
|
};
|