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-05-03 19:29:44 +03:00
|
|
|
const i18n = require('../../shared/i18n');
|
2021-06-15 17:36:27 +03:00
|
|
|
const logging = require('@tryghost/logging');
|
2021-06-30 16:56:57 +03:00
|
|
|
const settingsCache = require('../../shared/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
|
2021-07-08 09:09:13 +03:00
|
|
|
labs: require('../../server/services/labs'),
|
2017-04-04 19:07:35 +03:00
|
|
|
|
|
|
|
// Things required from data/meta
|
2021-07-01 13:58:40 +03:00
|
|
|
metaData: require('../meta'),
|
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-07-01 19:55:44 +03:00
|
|
|
localUtils: require('./theme-engine/handlebars/utils'),
|
|
|
|
|
|
|
|
// 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 hbs.SafeString(resource.feature_image_caption);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2017-04-04 19:07:35 +03:00
|
|
|
};
|