ghost 4.42.1 → 4.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/themes/casper/package.json +2 -3
- package/content/themes/casper/partials/post-card.hbs +1 -1
- package/core/built/assets/ghost-dark-470c1ef06b10e5c40ad05f3a642eaaea.css +1 -0
- package/core/built/assets/{ghost.min-20096eef632760c3a2906e243adbd24b.js → ghost.min-1e7dce606e92a03207d15ae7eb3d3c23.js} +411 -323
- package/core/built/assets/ghost.min-d0c17e8314b5583c0df5d05fab3c051c.css +1 -0
- package/core/built/assets/{vendor.min-21f79c68a284acb1b70039f3f63e5507.js → vendor.min-fe2c9b1235b4119b5406b788db2db434.js} +88 -82
- package/core/frontend/apps/amp/lib/helpers/amp_analytics.js +1 -1
- package/core/frontend/apps/amp/lib/helpers/amp_components.js +1 -1
- package/core/frontend/apps/amp/lib/helpers/amp_content.js +1 -1
- package/core/frontend/apps/amp/lib/helpers/amp_style.js +1 -1
- package/core/frontend/apps/amp/lib/router.js +6 -5
- package/core/frontend/apps/private-blogging/lib/helpers/input_password.js +1 -1
- package/core/frontend/apps/private-blogging/lib/router.js +2 -2
- package/core/frontend/helpers/asset.js +1 -1
- package/core/frontend/helpers/author.js +1 -1
- package/core/frontend/helpers/authors.js +1 -1
- package/core/frontend/helpers/body_class.js +1 -1
- package/core/frontend/helpers/cancel_link.js +1 -1
- package/core/frontend/helpers/concat.js +1 -1
- package/core/frontend/helpers/content.js +1 -1
- package/core/frontend/helpers/date.js +1 -1
- package/core/frontend/helpers/encode.js +1 -1
- package/core/frontend/helpers/excerpt.js +1 -1
- package/core/frontend/helpers/facebook_url.js +1 -1
- package/core/frontend/helpers/foreach.js +2 -2
- package/core/frontend/helpers/get.js +1 -1
- package/core/frontend/helpers/ghost_foot.js +1 -1
- package/core/frontend/helpers/ghost_head.js +1 -1
- package/core/frontend/helpers/lang.js +1 -1
- package/core/frontend/helpers/link.js +1 -1
- package/core/frontend/helpers/link_class.js +1 -1
- package/core/frontend/helpers/match.js +1 -1
- package/core/frontend/helpers/navigation.js +1 -1
- package/core/frontend/helpers/pagination.js +1 -1
- package/core/frontend/helpers/plural.js +1 -1
- package/core/frontend/helpers/post_class.js +1 -1
- package/core/frontend/helpers/prev_post.js +6 -5
- package/core/frontend/helpers/products.js +1 -1
- package/core/frontend/helpers/reading_time.js +2 -2
- package/core/frontend/helpers/t.js +1 -1
- package/core/frontend/helpers/tags.js +1 -1
- package/core/frontend/helpers/tiers.js +1 -1
- package/core/frontend/helpers/title.js +1 -1
- package/core/frontend/helpers/twitter_url.js +1 -1
- package/core/frontend/helpers/url.js +1 -1
- package/core/frontend/meta/url.js +4 -4
- package/core/{server/data/schema → frontend/services/data}/checks.js +4 -4
- package/core/frontend/services/{routing/helpers → data}/entry-lookup.js +3 -3
- package/core/frontend/services/{routing/helpers → data}/fetch-data.js +3 -3
- package/core/frontend/services/data/index.js +5 -0
- package/core/frontend/services/{rendering.js → handlebars.js} +2 -1
- package/core/frontend/services/helpers/handlebars.js +1 -1
- package/core/frontend/services/proxy.js +2 -4
- package/core/frontend/services/{routing/helpers → rendering}/context.js +0 -0
- package/core/frontend/services/{routing/helpers → rendering}/error.js +0 -0
- package/core/frontend/services/{routing/helpers → rendering}/format-response.js +1 -1
- package/core/frontend/services/{routing/helpers → rendering}/index.js +0 -8
- package/core/frontend/services/{routing/helpers → rendering}/render-entries.js +1 -1
- package/core/frontend/services/{routing/helpers → rendering}/render-entry.js +1 -1
- package/core/frontend/services/{routing/helpers → rendering}/renderer.js +1 -1
- package/core/frontend/services/{routing/helpers → rendering}/secure.js +0 -0
- package/core/frontend/services/{routing/helpers → rendering}/templates.js +2 -2
- package/core/frontend/services/routing/CollectionRouter.js +1 -1
- package/core/frontend/services/routing/controllers/channel.js +9 -9
- package/core/frontend/services/routing/controllers/collection.js +9 -9
- package/core/frontend/services/routing/controllers/email-post.js +5 -6
- package/core/frontend/services/routing/controllers/entry.js +6 -6
- package/core/frontend/services/routing/controllers/preview.js +5 -6
- package/core/frontend/services/routing/controllers/rss.js +4 -3
- package/core/frontend/services/routing/controllers/static.js +5 -5
- package/core/frontend/services/routing/controllers/unsubscribe.js +2 -2
- package/core/frontend/services/routing/index.js +0 -4
- package/core/frontend/web/middleware/error-handler.js +2 -2
- package/core/server/api/canary/authentication.js +2 -2
- package/core/server/api/canary/posts.js +1 -0
- package/core/server/api/canary/stats.js +9 -0
- package/core/server/api/canary/utils/serializers/output/members.js +8 -0
- package/core/server/api/canary/utils/validators/input/index.js +6 -0
- package/core/server/api/shared/http.js +52 -51
- package/core/server/data/exporter/table-lists.js +1 -0
- package/core/server/data/migrations/utils.js +33 -1
- package/core/server/data/migrations/versions/4.42/2022-03-21-17-17-add.js +5 -0
- package/core/server/data/migrations/versions/4.43/2022-03-28-19-26-recreate-newsletter-table.js +29 -0
- package/core/server/data/migrations/versions/4.43/2022-03-29-14-45-add-members-newsletters-table.js +7 -0
- package/core/server/data/migrations/versions/4.43/2022-04-01-10-13-add-post-newsletter-relation.js +108 -0
- package/core/server/data/migrations/versions/4.43/2022-04-06-09-47-add-type-column-to-paid-subscription-events.js +7 -0
- package/core/server/data/migrations/versions/4.43/2022-04-06-14-56-add-email-newsletter-relation.js +8 -0
- package/core/server/data/migrations/versions/4.43/2022-04-08-10-45-add-subscription-id-to-mrr-events.js +7 -0
- package/core/server/data/migrations/versions/4.44/2022-04-06-15-22-populate-type-column-for-paid-subscription-events.js +21 -0
- package/core/server/data/migrations/versions/4.44/2022-04-08-11-54-add-cancelled-events.js +51 -0
- package/core/server/data/migrations/versions/4.44/2022-04-11-08-24-add-newsletter-permissions.js +33 -0
- package/core/server/data/migrations/versions/4.44/2022-04-11-10-54-add-mrr-to-subscriptions.js +8 -0
- package/core/server/data/migrations/versions/4.44/2022-04-12-07-33-fill-mrr.js +29 -0
- package/core/server/data/migrations/versions/4.44/2022-04-13-12-00-remove-newsletter-sender-name-not-null-constraint.js +33 -0
- package/core/server/data/migrations/versions/4.44/2022-04-15-07-53-add-offer-id-to-subscriptions.js +9 -0
- package/core/server/data/schema/commands.js +6 -1
- package/core/server/data/schema/fixtures/fixtures.json +26 -1
- package/core/server/data/schema/index.js +0 -1
- package/core/server/data/schema/schema.js +36 -16
- package/core/server/models/base/bookshelf.js +1 -1
- package/core/server/models/base/plugins/crud.js +8 -0
- package/core/server/models/member.js +21 -1
- package/core/server/models/newsletter.js +42 -1
- package/core/server/models/post.js +12 -2
- package/core/server/models/stripe-customer-subscription.js +4 -0
- package/core/server/services/auth/setup.js +21 -8
- package/core/server/services/mega/mega.js +3 -1
- package/core/server/services/members/api.js +3 -1
- package/core/server/services/members/middleware.js +13 -3
- package/core/server/services/members/service.js +3 -11
- package/core/server/services/members/utils.js +13 -1
- package/core/server/services/newsletters/index.js +10 -0
- package/core/server/services/newsletters/service.js +24 -0
- package/core/server/services/posts/posts-service.js +20 -1
- package/core/server/services/slack.js +11 -3
- package/core/server/services/stats/lib/members-stats-service.js +30 -34
- package/core/server/services/stats/lib/mrr-stats-service.js +154 -0
- package/core/server/services/stats/service.js +3 -1
- package/core/server/services/stripe/service.js +1 -0
- package/core/server/web/admin/views/default-prod.html +4 -4
- package/core/server/web/admin/views/default.html +4 -4
- package/core/server/web/api/canary/admin/routes.js +1 -0
- package/core/shared/config/defaults.json +2 -2
- package/package.json +39 -39
- package/yarn.lock +410 -369
- package/content/themes/casper/assets/css/csscomb.json +0 -240
- package/core/built/assets/ghost-dark-a93afb20027060d760ac6d78f115a76f.css +0 -1
- package/core/built/assets/ghost.min-ce35ef1b76d9a943ab912c076773b132.css +0 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Outputs inline scripts used for analytics
|
|
5
5
|
const {settingsCache} = require('../../../../services/proxy');
|
|
6
|
-
const {SafeString} = require('../../../../services/
|
|
6
|
+
const {SafeString} = require('../../../../services/handlebars');
|
|
7
7
|
|
|
8
8
|
function ampComponents() {
|
|
9
9
|
let components = [];
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// amp-img, amp-ad, amp-embed, amp-video and amp-pixel.
|
|
10
10
|
// (less) dirty requires
|
|
11
11
|
const {settingsCache} = require('../../../../services/proxy');
|
|
12
|
-
const {SafeString} = require('../../../../services/
|
|
12
|
+
const {SafeString} = require('../../../../services/handlebars');
|
|
13
13
|
|
|
14
14
|
function ampComponents() {
|
|
15
15
|
let components = [];
|
|
@@ -12,7 +12,7 @@ const {DateTime, Interval} = require('luxon');
|
|
|
12
12
|
const errors = require('@tryghost/errors');
|
|
13
13
|
const logging = require('@tryghost/logging');
|
|
14
14
|
|
|
15
|
-
const {SafeString} = require('../../../../services/
|
|
15
|
+
const {SafeString} = require('../../../../services/handlebars');
|
|
16
16
|
|
|
17
17
|
const amperizeCache = {};
|
|
18
18
|
let allowedAMPTags = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {SafeString, escapeExpression} = require('../../../../services/
|
|
1
|
+
const {SafeString, escapeExpression} = require('../../../../services/handlebars');
|
|
2
2
|
|
|
3
3
|
module.exports = function amp_style(options) { // eslint-disable-line camelcase
|
|
4
4
|
if (options.data.site.accent_color) {
|
|
@@ -7,7 +7,8 @@ const errors = require('@tryghost/errors');
|
|
|
7
7
|
|
|
8
8
|
// Dirty requires
|
|
9
9
|
const urlService = require('../../../../server/services/url');
|
|
10
|
-
const
|
|
10
|
+
const dataService = require('../../../services/data');
|
|
11
|
+
const renderer = require('../../../services/rendering');
|
|
11
12
|
const templateName = 'amp';
|
|
12
13
|
|
|
13
14
|
const messages = {
|
|
@@ -23,15 +24,15 @@ function _renderer(req, res, next) {
|
|
|
23
24
|
|
|
24
25
|
// Renderer begin
|
|
25
26
|
// Format data
|
|
26
|
-
let
|
|
27
|
+
let body = req.body || {};
|
|
27
28
|
|
|
28
29
|
// CASE: we only support amp pages for posts that are not static pages
|
|
29
|
-
if (!
|
|
30
|
+
if (!body.post || body.post.page) {
|
|
30
31
|
return next(new errors.NotFoundError({message: tpl(messages.pageNotFound)}));
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
// Render Call
|
|
34
|
-
return
|
|
35
|
+
return renderer.renderer(req, res, body);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
// This here is a controller.
|
|
@@ -71,7 +72,7 @@ function getPostData(req, res, next) {
|
|
|
71
72
|
|
|
72
73
|
// @NOTE: amp is not supported for static pages
|
|
73
74
|
// @TODO: https://github.com/TryGhost/Ghost/issues/10548
|
|
74
|
-
|
|
75
|
+
dataService.entryLookup(urlWithoutSubdirectoryWithoutAmp, {permalinks, query: {controller: 'postsPublic', resource: 'posts'}}, res.locals)
|
|
75
76
|
.then((result) => {
|
|
76
77
|
if (result && result.entry) {
|
|
77
78
|
req.body.post = result.entry;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// Password input used on private.hbs for password-protected blogs
|
|
5
5
|
|
|
6
6
|
// (less) dirty requires
|
|
7
|
-
const {SafeString, templates} = require('../../../../services/
|
|
7
|
+
const {SafeString, templates} = require('../../../../services/handlebars');
|
|
8
8
|
|
|
9
9
|
// We use the name input_password to match the helper for consistency:
|
|
10
10
|
module.exports = function input_password(options) { // eslint-disable-line camelcase
|
|
@@ -2,7 +2,7 @@ const path = require('path');
|
|
|
2
2
|
const express = require('../../../../shared/express');
|
|
3
3
|
const middleware = require('./middleware');
|
|
4
4
|
const bodyParser = require('body-parser');
|
|
5
|
-
const
|
|
5
|
+
const renderer = require('../../../services/rendering');
|
|
6
6
|
const web = require('../../../../server/web');
|
|
7
7
|
const templateName = 'private';
|
|
8
8
|
const privateRouter = express.Router(templateName);
|
|
@@ -23,7 +23,7 @@ function _renderer(req, res) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// Render Call
|
|
26
|
-
return
|
|
26
|
+
return renderer.renderer(req, res, data);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// password-protected frontend route
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Returns the path to the specified asset.
|
|
5
5
|
const {metaData, urlUtils} = require('../services/proxy');
|
|
6
|
-
const {SafeString} = require('../services/
|
|
6
|
+
const {SafeString} = require('../services/handlebars');
|
|
7
7
|
|
|
8
8
|
const errors = require('@tryghost/errors');
|
|
9
9
|
const tpl = require('@tryghost/tpl');
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// Block helper: `{{#author}}{{/author}}`
|
|
11
11
|
// This is the default handlebars behaviour of dropping into the author object scope
|
|
12
12
|
const {urlService} = require('../services/proxy');
|
|
13
|
-
const {SafeString, escapeExpression, hbs, templates} = require('../services/
|
|
13
|
+
const {SafeString, escapeExpression, hbs, templates} = require('../services/handlebars');
|
|
14
14
|
const isString = require('lodash/isString');
|
|
15
15
|
|
|
16
16
|
const builtInHelpers = hbs.handlebars.helpers;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
//
|
|
8
8
|
// Note that the standard {{#each authors}} implementation is unaffected by this helper.
|
|
9
9
|
const {urlService} = require('../services/proxy');
|
|
10
|
-
const {SafeString, escapeExpression, templates} = require('../services/
|
|
10
|
+
const {SafeString, escapeExpression, templates} = require('../services/handlebars');
|
|
11
11
|
const isString = require('lodash/isString');
|
|
12
12
|
const {utils} = require('@tryghost/helpers');
|
|
13
13
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Usage: `{{body_class}}`
|
|
3
3
|
//
|
|
4
4
|
// Output classes for the body element
|
|
5
|
-
const {SafeString} = require('../services/
|
|
5
|
+
const {SafeString} = require('../services/handlebars');
|
|
6
6
|
|
|
7
7
|
// We use the name body_class to match the helper for consistency
|
|
8
8
|
module.exports = function body_class(options) { // eslint-disable-line camelcase
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
//
|
|
7
7
|
// Defaults to class="cancel-subscription-link" errorClass="cancel-subscription-error" cancelLabel="Cancel subscription" continueLabel="Continue subscription"
|
|
8
8
|
const {labs} = require('../services/proxy');
|
|
9
|
-
const {templates} = require('../services/
|
|
9
|
+
const {templates} = require('../services/handlebars');
|
|
10
10
|
|
|
11
11
|
const errors = require('@tryghost/errors');
|
|
12
12
|
const tpl = require('@tryghost/tpl');
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
//
|
|
11
11
|
// Dev flag feature: In case of restricted content access for member-only posts, shows CTA box
|
|
12
12
|
|
|
13
|
-
const {templates, hbs, SafeString} = require('../services/
|
|
13
|
+
const {templates, hbs, SafeString} = require('../services/handlebars');
|
|
14
14
|
const downsize = require('downsize');
|
|
15
15
|
const _ = require('lodash');
|
|
16
16
|
const createFrame = hbs.handlebars.createFrame;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Formats a date using moment-timezone.js. Formats published_at by default but will also take a date as a parameter
|
|
5
5
|
|
|
6
|
-
const {SafeString} = require('../services/
|
|
6
|
+
const {SafeString} = require('../services/handlebars');
|
|
7
7
|
const moment = require('moment-timezone');
|
|
8
8
|
const _ = require('lodash');
|
|
9
9
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
//
|
|
6
6
|
// Defaults to words="50"
|
|
7
7
|
|
|
8
|
-
const {SafeString} = require('../services/
|
|
8
|
+
const {SafeString} = require('../services/handlebars');
|
|
9
9
|
const {metaData} = require('../services/proxy');
|
|
10
10
|
const _ = require('lodash');
|
|
11
11
|
const getMetaDataExcerpt = metaData.getMetaDataExcerpt;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Output a url for a facebook username
|
|
5
5
|
const {socialUrls} = require('../services/proxy');
|
|
6
|
-
const {localUtils} = require('../services/
|
|
6
|
+
const {localUtils} = require('../services/handlebars');
|
|
7
7
|
|
|
8
8
|
// We use the name facebook_url to match the helper for consistency:
|
|
9
9
|
module.exports = function facebook_url(username, options) { // eslint-disable-line camelcase
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Usage: `{{#foreach data}}{{/foreach}}`
|
|
3
3
|
//
|
|
4
4
|
// Block helper designed for looping through posts
|
|
5
|
-
const {checks} = require('../services/
|
|
6
|
-
const {hbs} = require('../services/
|
|
5
|
+
const {checks} = require('../services/data');
|
|
6
|
+
const {hbs} = require('../services/handlebars');
|
|
7
7
|
|
|
8
8
|
const _ = require('lodash');
|
|
9
9
|
const logging = require('@tryghost/logging');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Usage: `{{#get "posts" limit="5"}}`, `{{#get "tags" limit="all"}}`
|
|
3
3
|
// Fetches data from the API
|
|
4
4
|
const {config, api, prepareContextResource} = require('../services/proxy');
|
|
5
|
-
const {hbs} = require('../services/
|
|
5
|
+
const {hbs} = require('../services/handlebars');
|
|
6
6
|
|
|
7
7
|
const logging = require('@tryghost/logging');
|
|
8
8
|
const errors = require('@tryghost/errors');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Outputs scripts and other assets at the bottom of a Ghost theme
|
|
5
5
|
const {settingsCache} = require('../services/proxy');
|
|
6
|
-
const {SafeString} = require('../services/
|
|
6
|
+
const {SafeString} = require('../services/handlebars');
|
|
7
7
|
const _ = require('lodash');
|
|
8
8
|
|
|
9
9
|
// We use the name ghost_foot to match the helper for consistency:
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Outputs scripts and other assets at the top of a Ghost theme
|
|
5
5
|
const {metaData, settingsCache, config, blogIcon, urlUtils, labs} = require('../services/proxy');
|
|
6
|
-
const {escapeExpression, SafeString} = require('../services/
|
|
6
|
+
const {escapeExpression, SafeString} = require('../services/handlebars');
|
|
7
7
|
|
|
8
8
|
// BAD REQUIRE
|
|
9
9
|
// @TODO fix this require
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// Language tags in HTML and XML
|
|
13
13
|
// https://www.w3.org/International/articles/language-tags/
|
|
14
14
|
|
|
15
|
-
const {SafeString} = require('../services/
|
|
15
|
+
const {SafeString} = require('../services/handlebars');
|
|
16
16
|
|
|
17
17
|
module.exports = function lang(options) {
|
|
18
18
|
const locale = options.data.site.locale;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// # link helper
|
|
2
2
|
const {config} = require('../services/proxy');
|
|
3
|
-
const {SafeString, localUtils} = require('../services/
|
|
3
|
+
const {SafeString, localUtils} = require('../services/handlebars');
|
|
4
4
|
|
|
5
5
|
const _ = require('lodash');
|
|
6
6
|
const errors = require('@tryghost/errors');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// # link_class helper
|
|
2
2
|
const {config} = require('../services/proxy');
|
|
3
|
-
const {SafeString, localUtils} = require('../services/
|
|
3
|
+
const {SafeString, localUtils} = require('../services/handlebars');
|
|
4
4
|
|
|
5
5
|
const _ = require('lodash');
|
|
6
6
|
const errors = require('@tryghost/errors');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// ### Navigation Helper
|
|
2
2
|
// `{{navigation}}`
|
|
3
3
|
// Outputs navigation menu of static urls
|
|
4
|
-
const {SafeString, templates, hbs} = require('../services/
|
|
4
|
+
const {SafeString, templates, hbs} = require('../services/handlebars');
|
|
5
5
|
|
|
6
6
|
const errors = require('@tryghost/errors');
|
|
7
7
|
const tpl = require('@tryghost/tpl');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// ### Pagination Helper
|
|
2
2
|
// `{{pagination}}`
|
|
3
3
|
// Outputs previous and next buttons, along with info about the current page
|
|
4
|
-
const {templates, hbs} = require('../services/
|
|
4
|
+
const {templates, hbs} = require('../services/handlebars');
|
|
5
5
|
|
|
6
6
|
const errors = require('@tryghost/errors');
|
|
7
7
|
const tpl = require('@tryghost/tpl');
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// The 2nd argument is the string that will be output if the variable's value is 0
|
|
10
10
|
// The 3rd argument is the string that will be output if the variable's value is 1
|
|
11
11
|
// The 4th argument is the string that will be output if the variable's value is 2+
|
|
12
|
-
const {SafeString} = require('../services/
|
|
12
|
+
const {SafeString} = require('../services/handlebars');
|
|
13
13
|
|
|
14
14
|
const errors = require('@tryghost/errors');
|
|
15
15
|
const tpl = require('@tryghost/tpl');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Usage: `{{post_class}}`
|
|
3
3
|
//
|
|
4
4
|
// Output classes for the body element
|
|
5
|
-
const {SafeString} = require('../services/
|
|
5
|
+
const {SafeString} = require('../services/handlebars');
|
|
6
6
|
|
|
7
7
|
// We use the name post_class to match the helper for consistency:
|
|
8
8
|
module.exports = function post_class() { // eslint-disable-line camelcase
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// Example usages
|
|
3
3
|
// `{{#prev_post}}<a href ="{{url}}>previous post</a>{{/prev_post}}'
|
|
4
4
|
// `{{#next_post}}<a href ="{{url absolute="true">next post</a>{{/next_post}}'
|
|
5
|
-
const {api
|
|
6
|
-
const {hbs} = require('../services/
|
|
5
|
+
const {api} = require('../services/proxy');
|
|
6
|
+
const {hbs} = require('../services/handlebars');
|
|
7
|
+
const {checks} = require('../services/data');
|
|
7
8
|
|
|
8
9
|
const logging = require('@tryghost/logging');
|
|
9
10
|
const tpl = require('@tryghost/tpl');
|
|
@@ -50,8 +51,8 @@ const buildApiOptions = function buildApiOptions(options, post) {
|
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
/**
|
|
53
|
-
* @param {*} options
|
|
54
|
-
* @param {*} data
|
|
54
|
+
* @param {*} options
|
|
55
|
+
* @param {*} data
|
|
55
56
|
* @returns {Promise<any>}
|
|
56
57
|
*/
|
|
57
58
|
const fetch = function fetch(options, data) {
|
|
@@ -84,7 +85,7 @@ const fetch = function fetch(options, data) {
|
|
|
84
85
|
// then the promise is handled in the api call.
|
|
85
86
|
|
|
86
87
|
/**
|
|
87
|
-
* @param {*} options
|
|
88
|
+
* @param {*} options
|
|
88
89
|
* @returns {Promise<any>}
|
|
89
90
|
*/
|
|
90
91
|
module.exports = function prevNext(options) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// Returns a string of the products with access to the post.
|
|
5
5
|
// By default, products are separated by commas.
|
|
6
6
|
const {labs} = require('../services/proxy');
|
|
7
|
-
const {SafeString} = require('../services/
|
|
7
|
+
const {SafeString} = require('../services/handlebars');
|
|
8
8
|
|
|
9
9
|
const isString = require('lodash/isString');
|
|
10
10
|
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
//
|
|
11
11
|
// Returns estimated reading time for post
|
|
12
12
|
|
|
13
|
-
const {checks} = require('../services/
|
|
14
|
-
const {SafeString} = require('../services/
|
|
13
|
+
const {checks} = require('../services/data');
|
|
14
|
+
const {SafeString} = require('../services/handlebars');
|
|
15
15
|
|
|
16
16
|
const {readingTime: calculateReadingTime} = require('@tryghost/helpers');
|
|
17
17
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// because often other helpers need that (t) returns a string to be able to work as subexpression; e.g.:
|
|
11
11
|
// {{tags prefix=(t " on ")}}
|
|
12
12
|
|
|
13
|
-
const {themeI18n} = require('../services/
|
|
13
|
+
const {themeI18n} = require('../services/handlebars');
|
|
14
14
|
|
|
15
15
|
module.exports = function t(text, options) {
|
|
16
16
|
const bindings = {};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
//
|
|
7
7
|
// Note that the standard {{#each tags}} implementation is unaffected by this helper
|
|
8
8
|
const {urlService} = require('../services/proxy');
|
|
9
|
-
const {SafeString, escapeExpression, templates} = require('../services/
|
|
9
|
+
const {SafeString, escapeExpression, templates} = require('../services/handlebars');
|
|
10
10
|
|
|
11
11
|
const isString = require('lodash/isString');
|
|
12
12
|
const ghostHelperUtils = require('@tryghost/helpers').utils;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// Returns a string of the tiers with access to the post.
|
|
5
5
|
// By default, tiers are separated by commas.
|
|
6
6
|
const {labs} = require('../services/proxy');
|
|
7
|
-
const {SafeString, escapeExpression} = require('../services/
|
|
7
|
+
const {SafeString, escapeExpression} = require('../services/handlebars');
|
|
8
8
|
|
|
9
9
|
const isString = require('lodash/isString');
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Overrides the standard behaviour of `{[title}}` to ensure the content is correctly escaped
|
|
5
5
|
|
|
6
|
-
const {SafeString, escapeExpression} = require('../services/
|
|
6
|
+
const {SafeString, escapeExpression} = require('../services/handlebars');
|
|
7
7
|
|
|
8
8
|
module.exports = function title() {
|
|
9
9
|
return new SafeString(escapeExpression(this.title || ''));
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// Output a url for a twitter username
|
|
5
5
|
const {socialUrls} = require('../services/proxy');
|
|
6
|
-
const {localUtils} = require('../services/
|
|
6
|
+
const {localUtils} = require('../services/handlebars');
|
|
7
7
|
|
|
8
8
|
// We use the name twitter_url to match the helper for consistency:
|
|
9
9
|
module.exports = function twitter_url(username, options) { // eslint-disable-line camelcase
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// `absolute` flag outputs absolute URL, else URL is relative
|
|
6
6
|
|
|
7
7
|
const {metaData} = require('../services/proxy');
|
|
8
|
-
const {SafeString} = require('../services/
|
|
8
|
+
const {SafeString} = require('../services/handlebars');
|
|
9
9
|
const logging = require('@tryghost/logging');
|
|
10
10
|
const sentry = require('../../shared/sentry');
|
|
11
11
|
const errors = require('@tryghost/errors');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const schema = require('../../server/data/schema').checks;
|
|
2
1
|
const urlUtils = require('../../shared/url-utils');
|
|
3
2
|
const urlService = require('../../server/services/url');
|
|
3
|
+
const {checks} = require('../services/data');
|
|
4
4
|
|
|
5
5
|
// This cleans the url from any `/amp` postfixes, so we'll never
|
|
6
6
|
// output a url with `/amp` in the end, except for the needed `amphtml`
|
|
@@ -13,7 +13,7 @@ function sanitizeAmpUrl(url) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function getUrl(data, absolute) {
|
|
16
|
-
if (
|
|
16
|
+
if (checks.isPost(data)) {
|
|
17
17
|
/**
|
|
18
18
|
* @NOTE
|
|
19
19
|
*
|
|
@@ -33,11 +33,11 @@ function getUrl(data, absolute) {
|
|
|
33
33
|
return urlService.getUrlByResourceId(data.id, {secure: data.secure, absolute: absolute, withSubdirectory: true});
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
if (
|
|
36
|
+
if (checks.isTag(data) || checks.isUser(data)) {
|
|
37
37
|
return urlService.getUrlByResourceId(data.id, {secure: data.secure, absolute: absolute, withSubdirectory: true});
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
if (
|
|
40
|
+
if (checks.isNav(data)) {
|
|
41
41
|
return urlUtils.urlFor('nav', {nav: data, secure: data.secure}, absolute);
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const _ = require('lodash');
|
|
2
2
|
const Promise = require('bluebird');
|
|
3
3
|
const url = require('url');
|
|
4
|
-
const debug = require('@tryghost/debug')('services:
|
|
4
|
+
const debug = require('@tryghost/debug')('services:data:entry-lookup');
|
|
5
5
|
const routeMatch = require('path-match')();
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Query API for a single entry/resource.
|
|
9
9
|
* @param {String} postUrl
|
|
10
10
|
* @param {Object} routerOptions
|
|
11
11
|
* @param {Object} locals
|
|
@@ -14,7 +14,7 @@ const routeMatch = require('path-match')();
|
|
|
14
14
|
function entryLookup(postUrl, routerOptions, locals) {
|
|
15
15
|
debug(postUrl);
|
|
16
16
|
|
|
17
|
-
const api = require('
|
|
17
|
+
const api = require('../proxy').api[locals.apiVersion];
|
|
18
18
|
const targetPath = url.parse(postUrl).path;
|
|
19
19
|
const permalinks = routerOptions.permalinks;
|
|
20
20
|
let isEditURL = false;
|
|
@@ -34,7 +34,7 @@ const defaultPostQuery = _.cloneDeep(queryDefaults);
|
|
|
34
34
|
defaultPostQuery.options = defaultQueryOptions.options;
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Process query request.
|
|
38
38
|
*
|
|
39
39
|
* Takes a 'query' object, ensures that type, resource and options are set
|
|
40
40
|
* Replaces occurrences of `%s` in options with slugParam
|
|
@@ -45,7 +45,7 @@ defaultPostQuery.options = defaultQueryOptions.options;
|
|
|
45
45
|
* @returns {Promise}
|
|
46
46
|
*/
|
|
47
47
|
function processQuery(query, slugParam, locals) {
|
|
48
|
-
const api = require('
|
|
48
|
+
const api = require('../proxy').api[locals.apiVersion];
|
|
49
49
|
|
|
50
50
|
query = _.cloneDeep(query);
|
|
51
51
|
|
|
@@ -62,7 +62,7 @@ function processQuery(query, slugParam, locals) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* Fetch data from API helper for controllers.
|
|
66
66
|
*
|
|
67
67
|
* Calls out to get posts per page, builds the final posts query & builds any additional queries
|
|
68
68
|
* Wraps the queries using Promise.props to ensure it gets named responses
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This is a loose concept of a frontend
|
|
2
|
+
* This is a loose concept of a frontend handlebars toolkit
|
|
3
3
|
* Note: everything here gets deep-required from the theme-engine
|
|
4
4
|
* This indicates that the theme engine is a set of services, rather than a single service
|
|
5
5
|
* and could do with a further refactor.
|
|
@@ -17,6 +17,7 @@ module.exports = {
|
|
|
17
17
|
templates: require('./theme-engine/handlebars/template'),
|
|
18
18
|
|
|
19
19
|
// Theme i18n
|
|
20
|
+
// @TODO: this should live somewhere else...
|
|
20
21
|
themeI18n: require('./theme-engine/i18n'),
|
|
21
22
|
|
|
22
23
|
// TODO: these need a more sensible home
|
|
@@ -2,7 +2,7 @@ const Promise = require('bluebird');
|
|
|
2
2
|
const errors = require('@tryghost/errors');
|
|
3
3
|
const logging = require('@tryghost/logging');
|
|
4
4
|
|
|
5
|
-
const {hbs} = require('../
|
|
5
|
+
const {hbs} = require('../handlebars');
|
|
6
6
|
|
|
7
7
|
// Register an async handlebars helper for a given handlebars instance
|
|
8
8
|
function asyncHelperWrapper(hbsInstance, name, fn) {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
const settingsCache = require('../../shared/settings-cache');
|
|
3
3
|
const config = require('../../shared/config');
|
|
4
4
|
|
|
5
|
-
// Require from the
|
|
6
|
-
const {SafeString} = require('./
|
|
5
|
+
// Require from the handlebars framework
|
|
6
|
+
const {SafeString} = require('./handlebars');
|
|
7
7
|
|
|
8
8
|
module.exports = {
|
|
9
9
|
/**
|
|
@@ -22,8 +22,6 @@ module.exports = {
|
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
},
|
|
25
|
-
// This is used to decide e.g. if a JSON object is a Post, Page, Tag etc
|
|
26
|
-
checks: require('../../server/data/schema').checks,
|
|
27
25
|
|
|
28
26
|
/**
|
|
29
27
|
* Section three: Core API
|
|
File without changes
|
|
File without changes
|