From 35e3e0708ccd51e238f01c6917e0f8c3f51253d9 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Wed, 8 Apr 2020 16:56:37 +0100 Subject: [PATCH] Moved helper proxy into a service - The proxy is not a helper, we want the helpers folder to only include helpers - The proxy is also meant to be the interface to Ghost for the helpers, and we want to enforce that - This is a small step on the way --- core/frontend/apps/amp/lib/helpers/amp_components.js | 2 +- core/frontend/apps/amp/lib/helpers/amp_content.js | 2 +- .../private-blogging/lib/helpers/input_password.js | 2 +- core/frontend/helpers/asset.js | 2 +- core/frontend/helpers/author.js | 2 +- core/frontend/helpers/authors.js | 2 +- core/frontend/helpers/body_class.js | 3 +-- core/frontend/helpers/cancel_link.js | 2 +- core/frontend/helpers/concat.js | 2 +- core/frontend/helpers/content.js | 2 +- core/frontend/helpers/date.js | 2 +- core/frontend/helpers/encode.js | 2 +- core/frontend/helpers/excerpt.js | 2 +- core/frontend/helpers/facebook_url.js | 2 +- core/frontend/helpers/foreach.js | 2 +- core/frontend/helpers/get.js | 2 +- core/frontend/helpers/ghost_foot.js | 2 +- core/frontend/helpers/ghost_head.js | 2 +- core/frontend/helpers/has.js | 2 +- core/frontend/helpers/img_url.js | 2 +- core/frontend/helpers/index.js | 2 +- core/frontend/helpers/is.js | 2 +- core/frontend/helpers/lang.js | 2 +- core/frontend/helpers/link.js | 2 +- core/frontend/helpers/link_class.js | 2 +- core/frontend/helpers/meta_description.js | 2 +- core/frontend/helpers/meta_title.js | 2 +- core/frontend/helpers/navigation.js | 2 +- core/frontend/helpers/page_url.js | 2 +- core/frontend/helpers/pagination.js | 2 +- core/frontend/helpers/plural.js | 2 +- core/frontend/helpers/post_class.js | 2 +- core/frontend/helpers/prev_next.js | 2 +- core/frontend/helpers/price.js | 2 +- core/frontend/helpers/reading_time.js | 2 +- core/frontend/helpers/register.js | 2 +- core/frontend/helpers/t.js | 2 +- core/frontend/helpers/tags.js | 2 +- core/frontend/helpers/title.js | 2 +- core/frontend/helpers/twitter_url.js | 2 +- core/frontend/helpers/url.js | 2 +- core/frontend/{helpers => services}/proxy.js | 10 +++++----- test/unit/helpers/ghost_foot_spec.js | 2 +- test/unit/helpers/ghost_head_spec.js | 2 +- test/unit/helpers/lang_spec.js | 2 +- 45 files changed, 49 insertions(+), 50 deletions(-) rename core/frontend/{helpers => services}/proxy.js (90%) diff --git a/core/frontend/apps/amp/lib/helpers/amp_components.js b/core/frontend/apps/amp/lib/helpers/amp_components.js index ec9fa2504f..335c69c138 100644 --- a/core/frontend/apps/amp/lib/helpers/amp_components.js +++ b/core/frontend/apps/amp/lib/helpers/amp_components.js @@ -8,7 +8,7 @@ // By default supported AMP HTML tags (no additional script tag necessary): // amp-img, amp-ad, amp-embed, amp-video and amp-pixel. // (less) dirty requires -const proxy = require('../../../../helpers/proxy'), +const proxy = require('../../../../services/proxy'), SafeString = proxy.SafeString; function ampComponents() { diff --git a/core/frontend/apps/amp/lib/helpers/amp_content.js b/core/frontend/apps/amp/lib/helpers/amp_content.js index 6a883828f9..fbad616522 100644 --- a/core/frontend/apps/amp/lib/helpers/amp_content.js +++ b/core/frontend/apps/amp/lib/helpers/amp_content.js @@ -8,7 +8,7 @@ // there if available. The cacheId is a combination of `updated_at` and the `slug`. const Promise = require('bluebird'), moment = require('moment'), - proxy = require('../../../../helpers/proxy'), + proxy = require('../../../../services/proxy'), SafeString = proxy.SafeString, logging = proxy.logging, i18n = proxy.i18n, diff --git a/core/frontend/apps/private-blogging/lib/helpers/input_password.js b/core/frontend/apps/private-blogging/lib/helpers/input_password.js index fea5802e23..99a6626189 100644 --- a/core/frontend/apps/private-blogging/lib/helpers/input_password.js +++ b/core/frontend/apps/private-blogging/lib/helpers/input_password.js @@ -4,7 +4,7 @@ // Password input used on private.hbs for password-protected blogs // (less) dirty requires -const proxy = require('../../../../helpers/proxy'), +const proxy = require('../../../../services/proxy'), SafeString = proxy.SafeString, templates = proxy.templates; diff --git a/core/frontend/helpers/asset.js b/core/frontend/helpers/asset.js index a33eaa5224..461ad29235 100644 --- a/core/frontend/helpers/asset.js +++ b/core/frontend/helpers/asset.js @@ -2,7 +2,7 @@ // Usage: `{{asset "css/screen.css"}}` // // Returns the path to the specified asset. -const {SafeString, metaData, errors, i18n} = require('./proxy'); +const {SafeString, metaData, errors, i18n} = require('../services/proxy'); const get = require('lodash/get'); const {getAssetUrl} = metaData; diff --git a/core/frontend/helpers/author.js b/core/frontend/helpers/author.js index afab87bdeb..824297bf2f 100644 --- a/core/frontend/helpers/author.js +++ b/core/frontend/helpers/author.js @@ -9,7 +9,7 @@ // // Block helper: `{{#author}}{{/author}}` // This is the default handlebars behaviour of dropping into the author object scope -const {urlService, SafeString, hbs, templates} = require('./proxy'); +const {urlService, SafeString, hbs, templates} = require('../services/proxy'); const buildInHelpers = hbs.handlebars.helpers; const _ = require('lodash'); diff --git a/core/frontend/helpers/authors.js b/core/frontend/helpers/authors.js index 5735922543..0dd4ee8a8d 100644 --- a/core/frontend/helpers/authors.js +++ b/core/frontend/helpers/authors.js @@ -7,7 +7,7 @@ // // Note that the standard {{#each authors}} implementation is unaffected by this helper. const _ = require('lodash'); -const {SafeString, templates, urlService} = require('./proxy'); +const {SafeString, templates, urlService} = require('../services/proxy'); const ghostHelperUtils = require('@tryghost/helpers').utils; module.exports = function authors(options = {}) { diff --git a/core/frontend/helpers/body_class.js b/core/frontend/helpers/body_class.js index 6538ef6473..950588222b 100644 --- a/core/frontend/helpers/body_class.js +++ b/core/frontend/helpers/body_class.js @@ -2,7 +2,7 @@ // Usage: `{{body_class}}` // // Output classes for the body element -const {SafeString} = require('./proxy'); +const {SafeString} = require('../services/proxy'); // We use the name body_class to match the helper for consistency module.exports = function body_class(options) { // eslint-disable-line camelcase @@ -43,4 +43,3 @@ module.exports = function body_class(options) { // eslint-disable-line camelcase return new SafeString(classes); }; - diff --git a/core/frontend/helpers/cancel_link.js b/core/frontend/helpers/cancel_link.js index a6a06a9447..98d81e2e9e 100644 --- a/core/frontend/helpers/cancel_link.js +++ b/core/frontend/helpers/cancel_link.js @@ -6,7 +6,7 @@ // // Defaults to class="cancel-subscription-link" errorClass="cancel-subscription-error" cancelLabel="Cancel subscription" continueLabel="Continue subscription" -const {templates, errors, i18n} = require('./proxy'); +const {templates, errors, i18n} = require('../services/proxy'); module.exports = function excerpt(options) { let truncateOptions = (options || {}).hash || {}; diff --git a/core/frontend/helpers/concat.js b/core/frontend/helpers/concat.js index 8d6b27e769..86c847db0c 100644 --- a/core/frontend/helpers/concat.js +++ b/core/frontend/helpers/concat.js @@ -1,4 +1,4 @@ -const {SafeString} = require('./proxy'); +const {SafeString} = require('../services/proxy'); module.exports = function concat(...args) { const options = args.pop(); diff --git a/core/frontend/helpers/content.js b/core/frontend/helpers/content.js index 535d83c771..673f00e7e9 100644 --- a/core/frontend/helpers/content.js +++ b/core/frontend/helpers/content.js @@ -6,7 +6,7 @@ // // Enables tag-safe truncation of content by characters or words. -const {SafeString} = require('./proxy'); +const {SafeString} = require('../services/proxy'); const downsize = require('downsize'); module.exports = function content(options = {}) { diff --git a/core/frontend/helpers/date.js b/core/frontend/helpers/date.js index d5cfc27c99..4201fbf63a 100644 --- a/core/frontend/helpers/date.js +++ b/core/frontend/helpers/date.js @@ -3,7 +3,7 @@ // // Formats a date using moment-timezone.js. Formats published_at by default but will also take a date as a parameter -const {SafeString, themeI18n} = require('./proxy'); +const {SafeString, themeI18n} = require('../services/proxy'); const moment = require('moment-timezone'); module.exports = function (date, options) { diff --git a/core/frontend/helpers/encode.js b/core/frontend/helpers/encode.js index 3f03bf6101..39363d07b0 100644 --- a/core/frontend/helpers/encode.js +++ b/core/frontend/helpers/encode.js @@ -4,7 +4,7 @@ // // Returns URI encoded string -const {SafeString} = require('./proxy'); +const {SafeString} = require('../services/proxy'); module.exports = function encode(string, options) { const uri = string || options; diff --git a/core/frontend/helpers/excerpt.js b/core/frontend/helpers/excerpt.js index 32e94f8c17..8f6a2c58d1 100644 --- a/core/frontend/helpers/excerpt.js +++ b/core/frontend/helpers/excerpt.js @@ -5,7 +5,7 @@ // // Defaults to words="50" -const {SafeString, metaData} = require('./proxy'); +const {SafeString, metaData} = require('../services/proxy'); const _ = require('lodash'); const getMetaDataExcerpt = metaData.getMetaDataExcerpt; diff --git a/core/frontend/helpers/facebook_url.js b/core/frontend/helpers/facebook_url.js index 24c831e4c6..26d751c22d 100644 --- a/core/frontend/helpers/facebook_url.js +++ b/core/frontend/helpers/facebook_url.js @@ -2,7 +2,7 @@ // Usage: `{{facebook_url}}` or `{{facebook_url author.facebook}}` // // Output a url for a facebook username -const {socialUrls, localUtils} = require('./proxy'); +const {socialUrls, localUtils} = require('../services/proxy'); // We use the name facebook_url to match the helper for consistency: module.exports = function facebook_url(username, options) { // eslint-disable-line camelcase diff --git a/core/frontend/helpers/foreach.js b/core/frontend/helpers/foreach.js index 69e94f3e3a..9bb4ed76d3 100644 --- a/core/frontend/helpers/foreach.js +++ b/core/frontend/helpers/foreach.js @@ -3,7 +3,7 @@ // // Block helper designed for looping through posts const _ = require('lodash'); -const {logging, i18n, hbs} = require('./proxy'); +const {logging, i18n, hbs} = require('../services/proxy'); const {Utils: hbsUtils, handlebars: {createFrame}} = hbs; const ghostHelperUtils = require('@tryghost/helpers').utils; diff --git a/core/frontend/helpers/get.js b/core/frontend/helpers/get.js index 5d1bef2722..3f1ae72106 100644 --- a/core/frontend/helpers/get.js +++ b/core/frontend/helpers/get.js @@ -1,7 +1,7 @@ // # Get Helper // Usage: `{{#get "posts" limit="5"}}`, `{{#get "tags" limit="all"}}` // Fetches data from the API -const {config, logging, errors, i18n, hbs, api} = require('./proxy'); +const {config, logging, errors, i18n, hbs, api} = require('../services/proxy'); const _ = require('lodash'); const Promise = require('bluebird'); const jsonpath = require('jsonpath'); diff --git a/core/frontend/helpers/ghost_foot.js b/core/frontend/helpers/ghost_foot.js index 2f6a9a92a1..832a2bd037 100644 --- a/core/frontend/helpers/ghost_foot.js +++ b/core/frontend/helpers/ghost_foot.js @@ -2,7 +2,7 @@ // Usage: `{{ghost_foot}}` // // Outputs scripts and other assets at the bottom of a Ghost theme -const {SafeString, settingsCache} = require('./proxy'); +const {SafeString, settingsCache} = require('../services/proxy'); const _ = require('lodash'); // We use the name ghost_foot to match the helper for consistency: diff --git a/core/frontend/helpers/ghost_head.js b/core/frontend/helpers/ghost_head.js index 09bacf8c65..770a1ba912 100644 --- a/core/frontend/helpers/ghost_head.js +++ b/core/frontend/helpers/ghost_head.js @@ -2,7 +2,7 @@ // Usage: `{{ghost_head}}` // // Outputs scripts and other assets at the top of a Ghost theme -const {metaData, escapeExpression, SafeString, logging, settingsCache, config, blogIcon, labs} = require('./proxy'); +const {metaData, escapeExpression, SafeString, logging, settingsCache, config, blogIcon, labs} = require('../services/proxy'); const _ = require('lodash'); const debug = require('ghost-ignition').debug('ghost_head'); diff --git a/core/frontend/helpers/has.js b/core/frontend/helpers/has.js index 60b8305b68..01739258b7 100644 --- a/core/frontend/helpers/has.js +++ b/core/frontend/helpers/has.js @@ -4,7 +4,7 @@ // // Checks if a post has a particular property -const {logging, i18n} = require('./proxy'); +const {logging, i18n} = require('../services/proxy'); const _ = require('lodash'); const validAttrs = ['tag', 'author', 'slug','visibility', 'id', 'number', 'index', 'any', 'all']; diff --git a/core/frontend/helpers/img_url.js b/core/frontend/helpers/img_url.js index ab6033603a..736b31a3d3 100644 --- a/core/frontend/helpers/img_url.js +++ b/core/frontend/helpers/img_url.js @@ -9,7 +9,7 @@ const url = require('url'); const _ = require('lodash'); -const {urlUtils, logging, i18n} = require('./proxy'); +const {urlUtils, logging, i18n} = require('../services/proxy'); const STATIC_IMAGE_URL_PREFIX = `${urlUtils.STATIC_IMAGE_URL_PREFIX}`; diff --git a/core/frontend/helpers/index.js b/core/frontend/helpers/index.js index e96633df3f..ffb71c50e7 100644 --- a/core/frontend/helpers/index.js +++ b/core/frontend/helpers/index.js @@ -1,4 +1,4 @@ -const proxy = require('./proxy'); +const proxy = require('../services/proxy'); const register = require('./register'); const coreHelpers = {}; diff --git a/core/frontend/helpers/is.js b/core/frontend/helpers/is.js index f508170b72..819db46b26 100644 --- a/core/frontend/helpers/is.js +++ b/core/frontend/helpers/is.js @@ -1,7 +1,7 @@ // # Is Helper // Usage: `{{#is "paged"}}`, `{{#is "index, paged"}}` // Checks whether we're in a given context. -const {logging, i18n} = require('./proxy'); +const {logging, i18n} = require('../services/proxy'); const _ = require('lodash'); module.exports = function is(context, options) { diff --git a/core/frontend/helpers/lang.js b/core/frontend/helpers/lang.js index f1e550e81c..976e8d910f 100644 --- a/core/frontend/helpers/lang.js +++ b/core/frontend/helpers/lang.js @@ -12,7 +12,7 @@ // Language tags in HTML and XML // https://www.w3.org/International/articles/language-tags/ -const {SafeString, themeI18n} = require('./proxy'); +const {SafeString, themeI18n} = require('../services/proxy'); module.exports = function lang() { return new SafeString(themeI18n.locale()); diff --git a/core/frontend/helpers/link.js b/core/frontend/helpers/link.js index 33c2fe7626..54a2fcd684 100644 --- a/core/frontend/helpers/link.js +++ b/core/frontend/helpers/link.js @@ -1,6 +1,6 @@ // # link helper const _ = require('lodash'); -const {config, SafeString, errors, i18n} = require('./proxy'); +const {config, SafeString, errors, i18n} = require('../services/proxy'); const {buildLinkClasses} = require('./utils'); const managedAttributes = ['href', 'class', 'activeClass', 'parentActiveClass']; diff --git a/core/frontend/helpers/link_class.js b/core/frontend/helpers/link_class.js index bbe8fb7c2f..2ba6d2aedf 100644 --- a/core/frontend/helpers/link_class.js +++ b/core/frontend/helpers/link_class.js @@ -1,6 +1,6 @@ // # link_class helper const _ = require('lodash'); -const {config, SafeString, errors, i18n} = require('./proxy'); +const {config, SafeString, errors, i18n} = require('../services/proxy'); const {buildLinkClasses} = require('./utils'); module.exports = function link_class(options) { // eslint-disable-line camelcase diff --git a/core/frontend/helpers/meta_description.js b/core/frontend/helpers/meta_description.js index 4a88a51148..975657b97d 100644 --- a/core/frontend/helpers/meta_description.js +++ b/core/frontend/helpers/meta_description.js @@ -2,7 +2,7 @@ // Usage: `{{meta_description}}` // // Page description used for sharing and SEO -const {metaData} = require('./proxy'); +const {metaData} = require('../services/proxy'); const {getMetaDataDescription} = metaData; // We use the name meta_description to match the helper for consistency: diff --git a/core/frontend/helpers/meta_title.js b/core/frontend/helpers/meta_title.js index 3b897cfcfd..593db030d9 100644 --- a/core/frontend/helpers/meta_title.js +++ b/core/frontend/helpers/meta_title.js @@ -2,7 +2,7 @@ // Usage: `{{meta_title}}` // // Page title used for sharing and SEO -const {metaData} = require('./proxy'); +const {metaData} = require('../services/proxy'); const {getMetaDataTitle} = metaData; // We use the name meta_title to match the helper for consistency: diff --git a/core/frontend/helpers/navigation.js b/core/frontend/helpers/navigation.js index b5eca716bb..ababd9b266 100644 --- a/core/frontend/helpers/navigation.js +++ b/core/frontend/helpers/navigation.js @@ -2,7 +2,7 @@ // `{{navigation}}` // Outputs navigation menu of static urls -const {SafeString, i18n, errors, templates, hbs} = require('./proxy'); +const {SafeString, i18n, errors, templates, hbs} = require('../services/proxy'); const {slugify} = require('@tryghost/string'); const _ = require('lodash'); const createFrame = hbs.handlebars.createFrame; diff --git a/core/frontend/helpers/page_url.js b/core/frontend/helpers/page_url.js index 8a3b854ec1..68d50e85eb 100644 --- a/core/frontend/helpers/page_url.js +++ b/core/frontend/helpers/page_url.js @@ -4,7 +4,7 @@ // `{{page_url 2}}` // // Returns the URL for the page specified in the current object context. -const {metaData} = require('./proxy'); +const {metaData} = require('../services/proxy'); const getPaginatedUrl = metaData.getPaginatedUrl; // We use the name page_url to match the helper for consistency: diff --git a/core/frontend/helpers/pagination.js b/core/frontend/helpers/pagination.js index a7b6e1b9d1..c7f9e055b1 100644 --- a/core/frontend/helpers/pagination.js +++ b/core/frontend/helpers/pagination.js @@ -2,7 +2,7 @@ // `{{pagination}}` // Outputs previous and next buttons, along with info about the current page -const {errors, i18n, templates, hbs} = require('./proxy'); +const {errors, i18n, templates, hbs} = require('../services/proxy'); const _ = require('lodash'); const createFrame = hbs.handlebars.createFrame; diff --git a/core/frontend/helpers/plural.js b/core/frontend/helpers/plural.js index f95a337096..ae741d9ada 100644 --- a/core/frontend/helpers/plural.js +++ b/core/frontend/helpers/plural.js @@ -10,7 +10,7 @@ // 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 {errors, i18n, SafeString} = require('./proxy'); +const {errors, i18n, SafeString} = require('../services/proxy'); const isUndefined = require('lodash/isUndefined'); module.exports = function plural(number, options) { diff --git a/core/frontend/helpers/post_class.js b/core/frontend/helpers/post_class.js index f5aff15661..251e74e373 100644 --- a/core/frontend/helpers/post_class.js +++ b/core/frontend/helpers/post_class.js @@ -2,7 +2,7 @@ // Usage: `{{post_class}}` // // Output classes for the body element -const {SafeString} = require('./proxy'); +const {SafeString} = require('../services/proxy'); // We use the name post_class to match the helper for consistency: module.exports = function post_class() { // eslint-disable-line camelcase diff --git a/core/frontend/helpers/prev_next.js b/core/frontend/helpers/prev_next.js index 450a17f607..ededfd6647 100644 --- a/core/frontend/helpers/prev_next.js +++ b/core/frontend/helpers/prev_next.js @@ -3,7 +3,7 @@ // `{{#prev_post}}next post{{/next_post}}' -const {logging, i18n, api, hbs, checks} = require('./proxy'); +const {logging, i18n, api, hbs, checks} = require('../services/proxy'); const get = require('lodash/get'); const Promise = require('bluebird'); const moment = require('moment'); diff --git a/core/frontend/helpers/price.js b/core/frontend/helpers/price.js index abe44c42a6..335d2fd3e2 100644 --- a/core/frontend/helpers/price.js +++ b/core/frontend/helpers/price.js @@ -5,7 +5,7 @@ // 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, i18n} = require('./proxy'); +const {errors, i18n} = require('../services/proxy'); module.exports = function price(amount) { // CASE: if no amount is passed, e.g. `{{price}}` we throw an error diff --git a/core/frontend/helpers/reading_time.js b/core/frontend/helpers/reading_time.js index b5c326d8f7..3e906f7e58 100644 --- a/core/frontend/helpers/reading_time.js +++ b/core/frontend/helpers/reading_time.js @@ -10,7 +10,7 @@ // // Returns estimated reading time for post -const {SafeString, checks} = require('./proxy'); +const {SafeString, checks} = require('../services/proxy'); const calculateReadingTime = require('@tryghost/helpers').readingTime; module.exports = function reading_time(options) {// eslint-disable-line camelcase diff --git a/core/frontend/helpers/register.js b/core/frontend/helpers/register.js index 230544664d..b401caf835 100644 --- a/core/frontend/helpers/register.js +++ b/core/frontend/helpers/register.js @@ -1,5 +1,5 @@ const Promise = require('bluebird'); -const {config, hbs, errors, logging} = require('./proxy'); +const {config, hbs, errors, logging} = require('../services/proxy'); // Register an async handlebars helper for a given handlebars instance function asyncHelperWrapper(hbs, name, fn) { diff --git a/core/frontend/helpers/t.js b/core/frontend/helpers/t.js index 9c6832398d..de94e44458 100644 --- a/core/frontend/helpers/t.js +++ b/core/frontend/helpers/t.js @@ -10,7 +10,7 @@ // because often other helpers need that (t) returns a string to be able to work as subexpression; e.g.: // {{tags prefix=(t " on ")}} -const {themeI18n} = require('./proxy'); +const {themeI18n} = require('../services/proxy'); module.exports = function t(text, options) { var bindings = {}, diff --git a/core/frontend/helpers/tags.js b/core/frontend/helpers/tags.js index 7f2dd3c7e2..85f510eee3 100644 --- a/core/frontend/helpers/tags.js +++ b/core/frontend/helpers/tags.js @@ -5,7 +5,7 @@ // By default, tags are separated by commas. // // Note that the standard {{#each tags}} implementation is unaffected by this helper -const {urlService, SafeString, templates} = require('./proxy'); +const {urlService, SafeString, templates} = require('../services/proxy'); const _ = require('lodash'); const ghostHelperUtils = require('@tryghost/helpers').utils; diff --git a/core/frontend/helpers/title.js b/core/frontend/helpers/title.js index b40a0d5200..2c1d887d60 100644 --- a/core/frontend/helpers/title.js +++ b/core/frontend/helpers/title.js @@ -3,7 +3,7 @@ // // Overrides the standard behaviour of `{[title}}` to ensure the content is correctly escaped -const {SafeString, escapeExpression} = require('./proxy'); +const {SafeString, escapeExpression} = require('../services/proxy'); module.exports = function title() { return new SafeString(escapeExpression(this.title || '')); diff --git a/core/frontend/helpers/twitter_url.js b/core/frontend/helpers/twitter_url.js index 4f16377381..60aac814aa 100644 --- a/core/frontend/helpers/twitter_url.js +++ b/core/frontend/helpers/twitter_url.js @@ -2,7 +2,7 @@ // Usage: `{{twitter_url}}` or `{{twitter_url author.twitter}}` // // Output a url for a twitter username -const {socialUrls, localUtils} = require('./proxy'); +const {socialUrls, localUtils} = require('../services/proxy'); // We use the name twitter_url to match the helper for consistency: module.exports = function twitter_url(username, options) { // eslint-disable-line camelcase diff --git a/core/frontend/helpers/url.js b/core/frontend/helpers/url.js index ba84b2efc3..becd5efbbe 100644 --- a/core/frontend/helpers/url.js +++ b/core/frontend/helpers/url.js @@ -4,7 +4,7 @@ // Returns the URL for the current object scope i.e. If inside a post scope will return post permalink // `absolute` flag outputs absolute URL, else URL is relative -const {SafeString, metaData} = require('./proxy'); +const {SafeString, metaData} = require('../services/proxy'); const {getMetaDataUrl} = metaData; module.exports = function url(options) { diff --git a/core/frontend/helpers/proxy.js b/core/frontend/services/proxy.js similarity index 90% rename from core/frontend/helpers/proxy.js rename to core/frontend/services/proxy.js index 9d0f387e1e..f6cff22527 100644 --- a/core/frontend/helpers/proxy.js +++ b/core/frontend/services/proxy.js @@ -1,7 +1,7 @@ // 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 -var hbs = require('../services/themes/engine'), +var hbs = require('./themes/engine'), settingsCache = require('../../server/services/settings/cache'), config = require('../../server/config'); @@ -29,7 +29,7 @@ module.exports = { logging: require('../../server/lib/common/logging'), // Theme i18n is separate to common i18n - themeI18n: require('../services/themes/i18n'), + themeI18n: require('./themes/i18n'), // This is used to detect if "isPost" is true in prevNext. checks: require('../../server/data/schema').checks, @@ -57,12 +57,12 @@ module.exports = { }, // The local template thing, should this be merged with the channels one? - templates: require('./template'), + templates: require('../helpers/template'), // Various utils, needs cleaning up / simplifying socialUrls: require('@tryghost/social-urls'), blogIcon: require('../../server/lib/image/blog-icon'), - urlService: require('../services/url'), + urlService: require('./url'), urlUtils: require('../../server/lib/url-utils'), - localUtils: require('./utils') + localUtils: require('../helpers/utils') }; diff --git a/test/unit/helpers/ghost_foot_spec.js b/test/unit/helpers/ghost_foot_spec.js index 9025faa0e3..7f7423d4d1 100644 --- a/test/unit/helpers/ghost_foot_spec.js +++ b/test/unit/helpers/ghost_foot_spec.js @@ -1,7 +1,7 @@ var should = require('should'), sinon = require('sinon'), helpers = require('../../../core/frontend/helpers'), - proxy = require('../../../core/frontend/helpers/proxy'), + proxy = require('../../../core/frontend/services/proxy'), settingsCache = proxy.settingsCache; describe('{{ghost_foot}} helper', function () { diff --git a/test/unit/helpers/ghost_head_spec.js b/test/unit/helpers/ghost_head_spec.js index 3eed18094a..f00d44033a 100644 --- a/test/unit/helpers/ghost_head_spec.js +++ b/test/unit/helpers/ghost_head_spec.js @@ -12,7 +12,7 @@ const should = require('should'), routing = require('../../../core/frontend/services/routing'), urlService = require('../../../core/frontend/services/url'), helpers = require('../../../core/frontend/helpers'), - proxy = require('../../../core/frontend/helpers/proxy'), + proxy = require('../../../core/frontend/services/proxy'), settingsCache = proxy.settingsCache; describe('{{ghost_head}} helper', function () { diff --git a/test/unit/helpers/lang_spec.js b/test/unit/helpers/lang_spec.js index b6e41ba907..49f3d8e5ee 100644 --- a/test/unit/helpers/lang_spec.js +++ b/test/unit/helpers/lang_spec.js @@ -1,7 +1,7 @@ const should = require('should'); const settingsCache = require('../../../core/server/services/settings/cache'); const helpers = require('../../../core/frontend/helpers'); -const proxy = require('../../../core/frontend/helpers/proxy'); +const proxy = require('../../../core/frontend/services/proxy'); describe('{{lang}} helper', function () { beforeEach(function () {