mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Removed core @tryghost pkg usage from f/e proxy
- The frontend proxy is meant to be a way to pass critical internal pieces of Ghost core into the frontend - These fundamental @tryghost packages are shared and can be required directly, hence there's no need to pass them via the proxy - Reducing the surface area of the proxy reduces the proxies API - This makes it easier to see what's left in terms of decoupling the frontend, and what will always need to be passed (e.g. api) Note on @tryghost/social-urls: - this is a small utility that helps create URLs for social profiles, it's a util for working with data on the frontend aka part of the sdk - I think there should be many of these small helpers and we'll probably want to bundle them for the frontend at some point - for now, I'm leaving these as part of the proxy, as need to figure out where they belong
This commit is contained in:
parent
0db7ef849c
commit
52b924638d
22 changed files with 67 additions and 32 deletions
|
@ -9,7 +9,11 @@
|
|||
const Promise = require('bluebird');
|
||||
|
||||
const moment = require('moment');
|
||||
const {SafeString, logging, errors} = require('../../../../services/proxy');
|
||||
const errors = require('@tryghost/errors');
|
||||
const logging = require('@tryghost/logging');
|
||||
|
||||
const {SafeString} = require('../../../../services/proxy');
|
||||
|
||||
const amperizeCache = {};
|
||||
let allowedAMPTags = [];
|
||||
let allowedAMPAttributes = {};
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
// Usage: `{{asset "css/screen.css"}}`
|
||||
//
|
||||
// Returns the path to the specified asset.
|
||||
const {SafeString, metaData, errors, tpl} = require('../services/proxy');
|
||||
const {SafeString, metaData} = require('../services/proxy');
|
||||
|
||||
const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const get = require('lodash/get');
|
||||
const {getAssetUrl} = metaData;
|
||||
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
// Outputs cancel/renew links to manage subscription renewal after the subscription period ends.
|
||||
//
|
||||
// Defaults to class="cancel-subscription-link" errorClass="cancel-subscription-error" cancelLabel="Cancel subscription" continueLabel="Continue subscription"
|
||||
const {templates, labs} = require('../services/proxy');
|
||||
|
||||
const {templates, errors, tpl, labs} = require('../services/proxy');
|
||||
const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
|
||||
const messages = {
|
||||
invalidData: 'The {{cancel_link}} helper was used outside of a subscription context. See https://ghost.org/docs/themes/members/#cancel-links.'
|
||||
|
|
|
@ -2,8 +2,12 @@
|
|||
// Usage: `{{#foreach data}}{{/foreach}}`
|
||||
//
|
||||
// Block helper designed for looping through posts
|
||||
const {hbs, checks} = require('../services/proxy');
|
||||
|
||||
const _ = require('lodash');
|
||||
const {logging, tpl, hbs, checks} = require('../services/proxy');
|
||||
const logging = require('@tryghost/logging');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
|
||||
const {Utils: hbsUtils, handlebars: {createFrame}} = hbs;
|
||||
const ghostHelperUtils = require('@tryghost/helpers').utils;
|
||||
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
// # Get Helper
|
||||
// Usage: `{{#get "posts" limit="5"}}`, `{{#get "tags" limit="all"}}`
|
||||
// Fetches data from the API
|
||||
const {config, logging, errors, tpl, hbs, api, prepareContextResource} = require('../services/proxy');
|
||||
const {config, hbs, api, prepareContextResource} = require('../services/proxy');
|
||||
|
||||
const logging = require('@tryghost/logging');
|
||||
const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
|
||||
const _ = require('lodash');
|
||||
const Promise = require('bluebird');
|
||||
const jsonpath = require('jsonpath');
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
// Usage: `{{ghost_head}}`
|
||||
//
|
||||
// Outputs scripts and other assets at the top of a Ghost theme
|
||||
const {metaData, escapeExpression, SafeString, logging, settingsCache, config, blogIcon, urlUtils, labs} = require('../services/proxy');
|
||||
const {metaData, escapeExpression, SafeString, settingsCache, config, blogIcon, urlUtils, labs} = require('../services/proxy');
|
||||
|
||||
const logging = require('@tryghost/logging');
|
||||
const _ = require('lodash');
|
||||
const debug = require('@tryghost/debug')('ghost_head');
|
||||
const templateStyles = require('./tpl/styles');
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
//
|
||||
// Checks if a post has a particular property
|
||||
|
||||
const {logging, tpl} = require('../services/proxy');
|
||||
const logging = require('@tryghost/logging');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const _ = require('lodash');
|
||||
const validAttrs = ['tag', 'author', 'slug', 'visibility', 'id', 'number', 'index', 'any', 'all'];
|
||||
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
//
|
||||
// Returns the URL for the current object scope i.e. If inside a post scope will return image permalink
|
||||
// `absolute` flag outputs absolute URL, else URL is relative.
|
||||
const {urlUtils} = require('../services/proxy');
|
||||
|
||||
const url = require('url');
|
||||
const _ = require('lodash');
|
||||
const {urlUtils, logging, tpl} = require('../services/proxy');
|
||||
const logging = require('@tryghost/logging');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
|
||||
const messages = {
|
||||
attrIsRequired: 'Attribute is required e.g. {{img_url feature_image}}'
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// # Is Helper
|
||||
// Usage: `{{#is "paged"}}`, `{{#is "index, paged"}}`
|
||||
// Checks whether we're in a given context.
|
||||
const {logging, tpl} = require('../services/proxy');
|
||||
const logging = require('@tryghost/logging');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const _ = require('lodash');
|
||||
|
||||
const messages = {
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
// # link helper
|
||||
const {config, SafeString, localUtils} = require('../services/proxy');
|
||||
|
||||
const _ = require('lodash');
|
||||
const {config, SafeString, errors, tpl, localUtils} = require('../services/proxy');
|
||||
const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
|
||||
const {buildLinkClasses} = localUtils;
|
||||
|
||||
const messages = {
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
// # link_class helper
|
||||
const {config, SafeString, localUtils} = require('../services/proxy');
|
||||
|
||||
const _ = require('lodash');
|
||||
const {config, SafeString, errors, tpl, localUtils} = require('../services/proxy');
|
||||
const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
|
||||
const {buildLinkClasses} = localUtils;
|
||||
|
||||
const messages = {
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
const {logging, tpl, SafeString, labs} = require('../services/proxy');
|
||||
const {SafeString, labs} = require('../services/proxy');
|
||||
|
||||
const logging = require('@tryghost/logging');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
const messages = {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
// ### Navigation Helper
|
||||
// `{{navigation}}`
|
||||
// Outputs navigation menu of static urls
|
||||
const {SafeString, templates, hbs} = require('../services/proxy');
|
||||
|
||||
const {SafeString, tpl, errors, templates, hbs} = require('../services/proxy');
|
||||
const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const {slugify} = require('@tryghost/string');
|
||||
const _ = require('lodash');
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
// ### Pagination Helper
|
||||
// `{{pagination}}`
|
||||
// Outputs previous and next buttons, along with info about the current page
|
||||
const {templates, hbs} = require('../services/proxy');
|
||||
|
||||
const {errors, tpl, templates, hbs} = require('../services/proxy');
|
||||
const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const _ = require('lodash');
|
||||
|
||||
const messages = {
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
// The 2nd argument is the string that will be output if the variable's value is 0
|
||||
// The 3rd argument is the string that will be output if the variable's value is 1
|
||||
// The 4th argument is the string that will be output if the variable's value is 2+
|
||||
const {SafeString} = require('../services/proxy');
|
||||
|
||||
const {errors, tpl, SafeString} = require('../services/proxy');
|
||||
const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const isUndefined = require('lodash/isUndefined');
|
||||
|
||||
const messages = {
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
// Example usages
|
||||
// `{{#prev_post}}<a href ="{{url}}>previous post</a>{{/prev_post}}'
|
||||
// `{{#next_post}}<a href ="{{url absolute="true">next post</a>{{/next_post}}'
|
||||
const {api, hbs, checks} = require('../services/proxy');
|
||||
|
||||
const {logging, tpl, api, hbs, checks} = require('../services/proxy');
|
||||
const logging = require('@tryghost/logging');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const get = require('lodash/get');
|
||||
const Promise = require('bluebird');
|
||||
const moment = require('moment');
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
//
|
||||
// Returns amount equal to the dominant denomintation of the currency.
|
||||
// For example, if 2100 is passed, it will return 21.
|
||||
const isNumber = require('lodash/isNumber');
|
||||
const {errors, tpl} = require('../services/proxy');
|
||||
const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
const _ = require('lodash');
|
||||
|
||||
const messages = {
|
||||
|
@ -93,7 +93,7 @@ module.exports = function price(planOrAmount, options) {
|
|||
});
|
||||
}
|
||||
|
||||
if (!isNumber(amount)) {
|
||||
if (!_.isNumber(amount)) {
|
||||
throw new errors.IncorrectUsageError({
|
||||
message: tpl(messages.attrMustBeNumeric)
|
||||
});
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
//
|
||||
// Returns a string of the products with access to the post.
|
||||
// By default, products are separated by commas.
|
||||
const {SafeString, labs} = require('../services/proxy');
|
||||
|
||||
const nql = require('@nexes/nql');
|
||||
const isString = require('lodash/isString');
|
||||
const {SafeString, labs} = require('../services/proxy');
|
||||
|
||||
function products(options = {}) {
|
||||
options = options || {};
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
// Returns estimated reading time for post
|
||||
|
||||
const {SafeString, checks} = require('../services/proxy');
|
||||
|
||||
const calculateReadingTime = require('@tryghost/helpers').readingTime;
|
||||
|
||||
module.exports = function reading_time(options) {// eslint-disable-line camelcase
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
// Note that the standard {{#each tags}} implementation is unaffected by this helper
|
||||
const {urlService, SafeString, escapeExpression, templates} = require('../services/proxy');
|
||||
|
||||
const isString = require('lodash/isString');
|
||||
const ghostHelperUtils = require('@tryghost/helpers').utils;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// `absolute` flag outputs absolute URL, else URL is relative
|
||||
|
||||
const {SafeString, metaData} = require('../services/proxy');
|
||||
|
||||
const {getMetaDataUrl} = metaData;
|
||||
|
||||
module.exports = function url(options) {
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
// With the exception of modules like lodash, Bluebird
|
||||
// We can later refactor to enforce this something like we did in apps
|
||||
const hbs = require('./theme-engine/engine');
|
||||
const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
|
||||
const i18n = require('../../shared/i18n');
|
||||
const logging = require('@tryghost/logging');
|
||||
const settingsCache = require('../../shared/settings-cache');
|
||||
const config = require('../../shared/config');
|
||||
|
||||
|
@ -28,13 +23,6 @@ module.exports = {
|
|||
// TODO: Only expose "get"
|
||||
settingsCache: settingsCache,
|
||||
|
||||
// These 3 are kind of core and required all the time
|
||||
errors,
|
||||
// @deprecated
|
||||
i18n,
|
||||
tpl,
|
||||
logging,
|
||||
|
||||
// Theme i18n is separate to common i18n
|
||||
themeI18n: require('./theme-engine/i18n'),
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue