2017-04-04 19:07:35 +03:00
|
|
|
// This file defines everything that helpers "require"
|
|
|
|
// With the exception of modules like lodash, Bluebird
|
2020-03-19 18:23:10 +03:00
|
|
|
// We can later refactor to enforce this something like we did in apps
|
2021-04-19 17:09:35 +03:00
|
|
|
const hbs = require('./theme-engine/engine');
|
2020-05-26 21:10:29 +03:00
|
|
|
const errors = require('@tryghost/errors');
|
2020-04-29 18:44:27 +03:00
|
|
|
|
2021-04-27 16:18:04 +03:00
|
|
|
const i18n = require('../../server/lib/common/i18n');
|
2020-05-28 21:30:23 +03:00
|
|
|
const logging = require('../../shared/logging');
|
2020-04-29 18:44:27 +03:00
|
|
|
const settingsCache = require('../../server/services/settings/cache');
|
2020-05-27 20:47:53 +03:00
|
|
|
const config = require('../../shared/config');
|
2017-04-04 19:07:35 +03:00
|
|
|
|
|
|
|
// Direct requires:
|
|
|
|
// - lodash
|
|
|
|
// - bluebird
|
|
|
|
// - downsize
|
|
|
|
// - moment-timezone
|
|
|
|
// - jsonpath
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
hbs: hbs,
|
|
|
|
SafeString: hbs.SafeString,
|
|
|
|
escapeExpression: hbs.escapeExpression,
|
|
|
|
|
|
|
|
// TODO: Expose less of the API to make this safe
|
2019-06-19 12:30:28 +03:00
|
|
|
api: require('../../server/api'),
|
2017-12-13 15:19:51 +03:00
|
|
|
|
2017-04-04 19:07:35 +03:00
|
|
|
// TODO: Only expose "get"
|
|
|
|
settingsCache: settingsCache,
|
|
|
|
|
|
|
|
// These 3 are kind of core and required all the time
|
2020-05-26 21:10:29 +03:00
|
|
|
errors,
|
|
|
|
i18n,
|
|
|
|
logging,
|
2017-04-04 19:07:35 +03:00
|
|
|
|
2020-03-19 17:07:20 +03:00
|
|
|
// Theme i18n is separate to common i18n
|
2021-04-26 13:53:15 +03:00
|
|
|
themeI18n: require('./theme-engine/i18n'),
|
2020-03-19 17:07:20 +03:00
|
|
|
|
2017-04-04 19:07:35 +03:00
|
|
|
// This is used to detect if "isPost" is true in prevNext.
|
2019-06-19 12:30:28 +03:00
|
|
|
checks: require('../../server/data/schema').checks,
|
2017-04-04 19:07:35 +03:00
|
|
|
|
|
|
|
// 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
|
2019-06-19 12:30:28 +03:00
|
|
|
labs: require('../../server/services/labs'),
|
2017-04-04 19:07:35 +03:00
|
|
|
|
|
|
|
// Things required from data/meta
|
|
|
|
metaData: {
|
2019-06-19 12:30:28 +03:00
|
|
|
get: require('../meta'), // ghost_head
|
|
|
|
getAssetUrl: require('../meta/asset_url'), // asset
|
|
|
|
getMetaDataExcerpt: require('../meta/excerpt'), // excerpt
|
|
|
|
getMetaDataDescription: require('../meta/description'), // meta_desc
|
|
|
|
getMetaDataTitle: require('../meta/title'), // meta_title
|
|
|
|
getPaginatedUrl: require('../meta/paginated_url'), // page_url
|
|
|
|
getMetaDataUrl: require('../meta/url') // url
|
2017-04-04 19:07:35 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
// The local template thing, should this be merged with the channels one?
|
2021-04-19 17:41:18 +03:00
|
|
|
templates: require('./theme-engine/handlebars/template'),
|
2017-04-04 19:07:35 +03:00
|
|
|
|
|
|
|
// Various utils, needs cleaning up / simplifying
|
2019-06-06 18:01:03 +03:00
|
|
|
socialUrls: require('@tryghost/social-urls'),
|
2020-12-09 15:19:22 +03:00
|
|
|
blogIcon: require('../../server/lib/image').blogIcon,
|
2020-04-08 18:56:37 +03:00
|
|
|
urlService: require('./url'),
|
2020-05-28 13:57:02 +03:00
|
|
|
urlUtils: require('../../shared/url-utils'),
|
2021-04-19 17:41:18 +03:00
|
|
|
localUtils: require('./theme-engine/handlebars/utils')
|
2017-04-04 19:07:35 +03:00
|
|
|
};
|