ghost 4.18.0 → 4.20.1
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/.eslintrc.js +9 -8
- package/Gruntfile.js +1 -1
- package/PRIVACY.md +3 -0
- package/content/adapters/README.md +2 -2
- package/core/boot.js +17 -12
- package/core/bridge.js +9 -1
- package/core/built/assets/{chunk.3.b80d3e1e6b8556aaff3c.js → chunk.3.777d43e2ce954ba8b2f5.js} +25 -25
- package/core/built/assets/codemirror/{codemirror-21a09582262987037db73b152fb35f7c.js → codemirror-d25c379b87ec8b33d54ac7149bc0b6ae.js} +14 -14
- package/core/built/assets/ghost-dark-20e2892d4f30d0d1183c9ac725ea37d0.css +1 -0
- package/core/built/assets/{ghost.min-88d647a008a5b1dd678a89ae1e55c038.js → ghost.min-26e427944e719b616b8dc7fbb3bbd2f9.js} +709 -422
- package/core/built/assets/ghost.min-57e46fd3b1145ecf2cbd185a13611f3b.css +1 -0
- package/core/built/assets/icons/arrow-left-small.svg +0 -4
- package/core/built/assets/icons/paintbrush.svg +10 -1
- package/core/built/assets/icons/post.svg +3 -1
- package/core/built/assets/img/footer-marketplace-bg-572b6c6486a7e26316954d599eaa9f30.png +0 -0
- package/core/built/assets/img/marketing/offers-1-f2e1b653c4d5bb90eea9d7a2862530f9.jpg +0 -0
- package/core/built/assets/img/marketing/offers-2-28a225d34cc39d133748431536961d00.jpg +0 -0
- package/core/built/assets/img/marketing/offers-3-2094c91ab21a16c37fbe6ec16c140160.jpg +0 -0
- package/core/built/assets/img/themes/Alto-f4db5af43ca9771c7ac1f754de3ddf2f.png +0 -0
- package/core/built/assets/img/themes/Bulletin-57d45b992ff0e26e0acdce7ed4cccd67.png +0 -0
- package/core/built/assets/img/themes/Casper-c7e784d7188cc5d7f097d9b6c97b0263.jpg +0 -0
- package/core/built/assets/img/themes/Dawn-be81aa8c8caae8fcfb5d5fbec823fdcc.png +0 -0
- package/core/built/assets/img/themes/Digest-d3467ac22a290e1ad3a543014758286e.png +0 -0
- package/core/built/assets/img/themes/Dope-6f8e0bbc199ce4af9a60859e9e6a74ad.png +0 -0
- package/core/built/assets/img/themes/Ease-9c279ea6cec3c0f1823f81c9dd24b116.png +0 -0
- package/core/built/assets/img/themes/Edge-0258906309e11fd075a1d9880aa09b20.png +0 -0
- package/core/built/assets/img/themes/Edition-d8f508e93bc24bdf2716ae6f8b3d44f8.png +0 -0
- package/core/built/assets/img/themes/Editorial-a25a4a34c04dedd858bd5e05ef388b1c.jpg +0 -0
- package/core/built/assets/img/themes/Journal-accf0031bbae0919900a049061e65a04.png +0 -0
- package/core/built/assets/img/themes/London-3f07efcee9e5bfb9a33827064eb77e70.jpg +0 -0
- package/core/built/assets/img/themes/Massively-06edf00108429f7fb8e65f190fba34fe.jpg +0 -0
- package/core/built/assets/img/themes/Ruby-11a53c62015612f4b3aca8f503121225.png +0 -0
- package/core/built/assets/img/themes/Wave-86e8044c2d76cb57a9030e4c24ac9520.png +0 -0
- package/core/built/assets/simplemde/{simplemde-232f69d126310434489071a1891e6d8b.js → simplemde-3ffc0ec9e9fecf29b9a499db678c9e65.js} +14 -14
- package/core/built/assets/{vendor.min-7dc7cf9c92175ebfb9cea95c120ee8a7.js → vendor.min-af502ac4142871500fc424f6a5a254ec.js} +2206 -1859
- package/core/frontend/apps/amp/lib/router.js +1 -1
- package/core/frontend/helpers/match.js +17 -23
- package/core/frontend/meta/author-url.js +1 -1
- package/core/frontend/meta/url.js +1 -1
- package/core/{server → frontend}/public/favicon.ico +0 -0
- package/core/{server → frontend}/public/ghost.css +0 -0
- package/core/{server → frontend}/public/ghost.min.css +0 -0
- package/core/{server → frontend}/public/robots.txt +0 -0
- package/core/{server → frontend}/public/sitemap.xsl +0 -0
- package/core/frontend/services/proxy.js +1 -1
- package/core/frontend/services/rendering.js +1 -1
- package/core/frontend/services/routing/CollectionRouter.js +3 -49
- package/core/frontend/services/routing/ParentRouter.js +1 -4
- package/core/frontend/services/routing/StaticPagesRouter.js +3 -5
- package/core/frontend/services/routing/StaticRoutesRouter.js +4 -6
- package/core/frontend/services/routing/TaxonomyRouter.js +4 -5
- package/core/frontend/services/routing/controllers/collection.js +2 -2
- package/core/frontend/services/routing/controllers/email-post.js +2 -2
- package/core/frontend/services/routing/controllers/entry.js +2 -2
- package/core/frontend/services/routing/controllers/preview.js +2 -2
- package/core/frontend/services/routing/index.js +6 -12
- package/core/frontend/services/routing/registry.js +13 -0
- package/core/frontend/services/routing/router-manager.js +185 -0
- package/core/frontend/services/rss/generate-feed.js +2 -2
- package/core/frontend/services/theme-engine/i18n/i18n.js +267 -28
- package/core/frontend/services/theme-engine/i18n/index.js +1 -1
- package/core/frontend/services/theme-engine/i18n/theme-i18n.js +73 -0
- package/core/frontend/web/index.js +1 -0
- package/core/{server/web/site → frontend/web}/middleware/handle-image-sizes.js +4 -4
- package/core/{server/web/site → frontend/web}/middleware/index.js +0 -0
- package/core/{server/web/site → frontend/web}/middleware/redirect-ghost-to-admin.js +3 -3
- package/core/{server/web/site → frontend/web}/middleware/serve-favicon.js +6 -6
- package/core/{server/web/site → frontend/web}/middleware/serve-public-file.js +2 -2
- package/core/{server/web/site → frontend/web}/middleware/static-theme.js +3 -3
- package/core/frontend/web/routes.js +13 -0
- package/core/{server/web/site/app.js → frontend/web/site.js} +12 -16
- package/core/server/adapters/storage/LocalFileStorage.js +35 -39
- package/core/server/adapters/storage/index.js +12 -2
- package/core/server/api/canary/custom-theme-settings.js +2 -2
- package/core/server/api/canary/images.js +1 -1
- package/core/server/api/canary/oembed.js +2 -2
- package/core/server/api/canary/offers.js +29 -1
- package/core/server/api/canary/posts-public.js +6 -2
- package/core/server/api/canary/products.js +6 -2
- package/core/server/api/canary/tags-public.js +6 -2
- package/core/server/api/canary/users.js +9 -4
- package/core/server/api/canary/utils/serializers/output/custom-theme-settings.js +2 -2
- package/core/server/api/canary/utils/serializers/output/notifications.js +1 -0
- package/core/server/api/canary/utils/serializers/output/settings.js +2 -3
- package/core/server/api/canary/utils/serializers/output/utils/url.js +1 -1
- package/core/server/api/canary/utils/validators/input/oembed.js +4 -1
- package/core/server/api/canary/utils/validators/input/passwordreset.js +8 -3
- package/core/server/api/canary/utils/validators/input/settings.js +5 -4
- package/core/server/api/canary/utils/validators/input/setup.js +6 -2
- package/core/server/api/canary/utils/validators/input/users.js +6 -2
- package/core/server/api/canary/utils/validators/input/webhooks.js +8 -3
- package/core/server/api/v2/images.js +1 -1
- package/core/server/api/v2/utils/serializers/output/authentication.js +9 -4
- package/core/server/api/v2/utils/serializers/output/notifications.js +1 -0
- package/core/server/api/v2/utils/serializers/output/users.js +5 -3
- package/core/server/api/v2/utils/serializers/output/utils/url.js +1 -1
- package/core/server/api/v2/utils/validators/input/images.js +11 -6
- package/core/server/api/v2/utils/validators/input/invitations.js +14 -6
- package/core/server/api/v2/utils/validators/input/invites.js +6 -2
- package/core/server/api/v2/utils/validators/input/oembed.js +6 -2
- package/core/server/api/v2/utils/validators/input/passwordreset.js +8 -3
- package/core/server/api/v2/utils/validators/input/settings.js +10 -4
- package/core/server/api/v2/utils/validators/input/setup.js +6 -2
- package/core/server/api/v2/utils/validators/input/users.js +5 -2
- package/core/server/api/v3/authentication.js +6 -2
- package/core/server/api/v3/authors-public.js +6 -2
- package/core/server/api/v3/email.js +9 -4
- package/core/server/api/v3/images.js +1 -1
- package/core/server/api/v3/integrations.js +7 -3
- package/core/server/api/v3/invites.js +6 -3
- package/core/server/api/v3/labels.js +10 -5
- package/core/server/api/v3/memberSigninUrls.js +5 -2
- package/core/server/api/v3/oembed.js +2 -2
- package/core/server/api/v3/pages-public.js +5 -2
- package/core/server/api/v3/pages.js +6 -3
- package/core/server/api/v3/posts-public.js +5 -3
- package/core/server/api/v3/posts.js +7 -3
- package/core/server/api/v3/preview.js +5 -3
- package/core/server/api/v3/session.js +7 -3
- package/core/server/api/v3/settings.js +8 -3
- package/core/server/api/v3/slugs.js +5 -4
- package/core/server/api/v3/utils/serializers/output/authentication.js +10 -4
- package/core/server/api/v3/utils/serializers/output/notifications.js +1 -0
- package/core/server/api/v3/utils/serializers/output/settings.js +2 -3
- package/core/server/api/v3/utils/serializers/output/users.js +6 -2
- package/core/server/api/v3/utils/serializers/output/utils/url.js +1 -1
- package/core/server/api/v3/utils/validators/input/images.js +12 -7
- package/core/server/api/v3/utils/validators/input/invitations.js +14 -6
- package/core/server/api/v3/utils/validators/input/invites.js +6 -2
- package/core/server/api/v3/utils/validators/input/oembed.js +6 -2
- package/core/server/api/v3/utils/validators/input/passwordreset.js +8 -3
- package/core/server/api/v3/utils/validators/input/settings.js +5 -4
- package/core/server/api/v3/utils/validators/input/setup.js +6 -2
- package/core/server/api/v3/utils/validators/input/users.js +6 -2
- package/core/server/api/v3/utils/validators/input/webhooks.js +8 -3
- package/core/server/data/exporter/table-lists.js +2 -1
- package/core/server/data/importer/handlers/image.js +1 -1
- package/core/server/data/importer/importers/image.js +1 -1
- package/core/server/data/migrations/init/1-create-tables.js +7 -8
- package/core/server/data/migrations/init/2-create-fixtures.js +8 -8
- package/core/server/data/migrations/versions/4.19/01-add-active-column-to-offers.js +7 -0
- package/core/server/data/migrations/versions/4.19/02-add-offer-redemptions-table.js +8 -0
- package/core/server/data/migrations/versions/4.20/01-remove-offer-redemptions-table.js +19 -0
- package/core/server/data/migrations/versions/4.20/02-remove-offers-table.js +30 -0
- package/core/server/data/migrations/versions/4.20/03-add-offers-table.js +21 -0
- package/core/server/data/migrations/versions/4.20/04-add-offer-redemptions-table.js +9 -0
- package/core/server/data/migrations/versions/4.20/05-remove-not-null-constraint-from-portal-title.js +41 -0
- package/core/server/data/schema/fixtures/utils.js +150 -143
- package/core/server/data/schema/schema.js +15 -3
- package/core/server/frontend/ghost.min.css +1 -0
- package/core/server/lib/image/blog-icon.js +10 -10
- package/core/server/lib/image/image-size.js +5 -5
- package/core/server/lib/image/image-utils.js +4 -4
- package/core/server/lib/image/index.js +1 -2
- package/core/server/lib/mobiledoc.js +3 -2
- package/core/server/models/action.js +7 -4
- package/core/server/models/base/plugins/overrides.js +19 -6
- package/core/server/models/custom-theme-setting.js +56 -1
- package/core/server/models/index.js +4 -45
- package/core/server/models/member.js +5 -0
- package/core/server/models/offer-redemption.js +10 -0
- package/core/server/models/user.js +2 -1
- package/core/server/overrides.js +6 -2
- package/core/server/run-update-check.js +0 -3
- package/core/server/services/adapter-manager/config.js +1 -0
- package/core/server/services/adapter-manager/index.js +9 -5
- package/core/server/services/adapter-manager/options-resolver.js +18 -0
- package/core/server/services/bulk-email/bulk-email-processor.js +6 -2
- package/core/server/services/bulk-email/mailgun.js +1 -1
- package/core/server/services/custom-theme-settings.js +10 -4
- package/core/server/services/invites/index.js +0 -2
- package/core/server/services/invites/invites.js +5 -5
- package/core/server/services/mail/GhostMailer.js +18 -10
- package/core/server/services/mega/mega.js +3 -3
- package/core/server/services/mega/post-email-serializer.js +2 -2
- package/core/server/services/members/api.js +3 -4
- package/core/server/services/members/emails/signin.js +1 -1
- package/core/server/services/members/emails/signup.js +1 -1
- package/core/server/services/members/emails/subscribe.js +1 -1
- package/core/server/services/members/middleware.js +10 -0
- package/core/server/services/members/service.js +2 -1
- package/core/server/services/notifications/index.js +1 -1
- package/core/server/services/notifications/notifications.js +40 -35
- package/core/server/services/oembed.js +4 -9
- package/core/server/services/offers/service.js +16 -6
- package/core/server/services/permissions/public.js +6 -2
- package/core/server/services/route-settings/route-settings.js +1 -1
- package/core/server/services/settings/index.js +3 -1
- package/core/server/services/settings/settings-bread-service.js +42 -20
- package/core/server/services/slack.js +1 -1
- package/core/server/services/themes/activate.js +2 -2
- package/core/server/services/themes/activation-bridge.js +6 -6
- package/core/server/services/themes/storage.js +1 -1
- package/core/{frontend → server}/services/url/Queue.js +0 -0
- package/core/{frontend → server}/services/url/Resource.js +0 -0
- package/core/{frontend → server}/services/url/Resources.js +2 -2
- package/core/{frontend → server}/services/url/UrlGenerator.js +14 -14
- package/core/{frontend → server}/services/url/UrlService.js +12 -15
- package/core/{frontend → server}/services/url/Urls.js +1 -1
- package/core/{frontend → server}/services/url/configs/canary.js +0 -0
- package/core/{frontend → server}/services/url/configs/v2.js +0 -0
- package/core/{frontend → server}/services/url/configs/v3.js +0 -0
- package/core/{frontend → server}/services/url/configs/v4.js +0 -0
- package/core/{frontend → server}/services/url/index.js +0 -0
- package/core/server/services/xmlrpc.js +1 -1
- package/core/server/update-check.js +3 -3
- package/core/server/web/admin/controller.js +11 -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/app.js +8 -9
- package/core/server/web/members/app.js +1 -0
- package/core/server/web/oauth/app.js +4 -2
- package/core/server/web/parent/backend.js +3 -3
- package/core/server/web/parent/frontend.js +2 -2
- package/core/server/web/shared/middlewares/api/spam-prevention.js +0 -2
- package/core/server/web/shared/middlewares/custom-redirects.js +0 -8
- package/core/server/web/shared/middlewares/maintenance.js +1 -1
- package/core/server/web/well-known.js +10 -10
- package/core/shared/config/defaults.json +2 -2
- package/core/shared/config/overrides.json +1 -1
- package/core/shared/express.js +10 -0
- package/core/shared/html-to-plaintext.js +2 -2
- package/core/shared/labs.js +14 -6
- package/loggingrc.js +10 -0
- package/package.json +60 -57
- package/yarn.lock +1317 -914
- package/core/built/assets/ghost-dark-13627f10941a7dbb2b12e1d41dc51c34.css +0 -1
- package/core/built/assets/ghost.min-d9cbfb4eb2db8915fcd2bf2416218616.css +0 -1
- package/core/built/assets/img/themes/London-68501c8ab797de7f2851cf9ea0a28e26.jpg +0 -0
- package/core/frontend/services/routing/bootstrap.js +0 -114
- package/core/server/public/404-ghost.png +0 -0
- package/core/server/public/404-ghost@2x.png +0 -0
- package/core/server/web/site/index.js +0 -1
- package/core/server/web/site/routes.js +0 -9
- package/core/shared/i18n/i18n.js +0 -312
- package/core/shared/i18n/index.js +0 -6
- package/core/shared/i18n/translations/en.json +0 -675
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
const jsonSchema = require('../utils/json-schema');
|
|
2
2
|
const config = require('../../../../../../shared/config');
|
|
3
|
-
const
|
|
3
|
+
const tpl = require('@tryghost/tpl');
|
|
4
4
|
const errors = require('@tryghost/errors');
|
|
5
5
|
const {imageSize, blogIcon} = require('../../../../../lib/image');
|
|
6
6
|
|
|
7
|
+
const messages = {
|
|
8
|
+
isNotSquare: 'Please select a valid image file with square dimensions.',
|
|
9
|
+
invalidFile: 'Please select a valid image.'
|
|
10
|
+
};
|
|
11
|
+
|
|
7
12
|
const profileImage = (frame) => {
|
|
8
13
|
return imageSize.getImageSizeFromPath(frame.file.path).then((response) => {
|
|
9
14
|
// save the image dimensions in new property for file
|
|
@@ -12,7 +17,7 @@ const profileImage = (frame) => {
|
|
|
12
17
|
// CASE: file needs to be a square
|
|
13
18
|
if (frame.file.dimensions.width !== frame.file.dimensions.height) {
|
|
14
19
|
return Promise.reject(new errors.ValidationError({
|
|
15
|
-
message:
|
|
20
|
+
message: tpl(messages.isNotSquare)
|
|
16
21
|
}));
|
|
17
22
|
}
|
|
18
23
|
});
|
|
@@ -28,7 +33,7 @@ const icon = (frame) => {
|
|
|
28
33
|
// CASE: file should not be larger than 100kb
|
|
29
34
|
if (!validIconFileSize(frame.file.size)) {
|
|
30
35
|
return Promise.reject(new errors.ValidationError({
|
|
31
|
-
message:
|
|
36
|
+
message: tpl(messages.invalidFile, {extensions: iconExtensions})
|
|
32
37
|
}));
|
|
33
38
|
}
|
|
34
39
|
|
|
@@ -39,7 +44,7 @@ const icon = (frame) => {
|
|
|
39
44
|
// CASE: file needs to be a square
|
|
40
45
|
if (frame.file.dimensions.width !== frame.file.dimensions.height) {
|
|
41
46
|
return Promise.reject(new errors.ValidationError({
|
|
42
|
-
message:
|
|
47
|
+
message: tpl(messages.invalidFile, {extensions: iconExtensions})
|
|
43
48
|
}));
|
|
44
49
|
}
|
|
45
50
|
|
|
@@ -47,14 +52,14 @@ const icon = (frame) => {
|
|
|
47
52
|
// .ico files can contain multiple sizes, we need at least a minimum of 60px (16px is ok, as long as 60px are present as well)
|
|
48
53
|
if (frame.file.dimensions.width < 60) {
|
|
49
54
|
return Promise.reject(new errors.ValidationError({
|
|
50
|
-
message:
|
|
55
|
+
message: tpl(messages.invalidFile, {extensions: iconExtensions})
|
|
51
56
|
}));
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
// CASE: icon needs to be smaller than or equal to 1000px
|
|
55
60
|
if (frame.file.dimensions.width > 1000) {
|
|
56
61
|
return Promise.reject(new errors.ValidationError({
|
|
57
|
-
message:
|
|
62
|
+
message: tpl(messages.invalidFile, {extensions: iconExtensions})
|
|
58
63
|
}));
|
|
59
64
|
}
|
|
60
65
|
});
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
const Promise = require('bluebird');
|
|
2
2
|
const validator = require('@tryghost/validator');
|
|
3
3
|
const debug = require('@tryghost/debug')('api:v2:utils:validators:input:invitation');
|
|
4
|
-
const
|
|
4
|
+
const tpl = require('@tryghost/tpl');
|
|
5
5
|
const errors = require('@tryghost/errors');
|
|
6
6
|
|
|
7
|
+
const messages = {
|
|
8
|
+
noTokenProvided: 'No token provided.',
|
|
9
|
+
noEmailProvided: 'No email provided.',
|
|
10
|
+
noPasswordProvided: 'No password provided.',
|
|
11
|
+
noNameProvided: 'No name provided.',
|
|
12
|
+
invalidEmailReceived: 'The server did not receive a valid email'
|
|
13
|
+
};
|
|
14
|
+
|
|
7
15
|
module.exports = {
|
|
8
16
|
acceptInvitation(apiConfig, frame) {
|
|
9
17
|
debug('acceptInvitation');
|
|
@@ -11,19 +19,19 @@ module.exports = {
|
|
|
11
19
|
const data = frame.data.invitation[0];
|
|
12
20
|
|
|
13
21
|
if (!data.token) {
|
|
14
|
-
return Promise.reject(new errors.ValidationError({message:
|
|
22
|
+
return Promise.reject(new errors.ValidationError({message: tpl(messages.noTokenProvided)}));
|
|
15
23
|
}
|
|
16
24
|
|
|
17
25
|
if (!data.email) {
|
|
18
|
-
return Promise.reject(new errors.ValidationError({message:
|
|
26
|
+
return Promise.reject(new errors.ValidationError({message: tpl(messages.noEmailProvided)}));
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
if (!data.password) {
|
|
22
|
-
return Promise.reject(new errors.ValidationError({message:
|
|
30
|
+
return Promise.reject(new errors.ValidationError({message: tpl(messages.noPasswordProvided)}));
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
if (!data.name) {
|
|
26
|
-
return Promise.reject(new errors.ValidationError({message:
|
|
34
|
+
return Promise.reject(new errors.ValidationError({message: tpl(messages.noNameProvided)}));
|
|
27
35
|
}
|
|
28
36
|
},
|
|
29
37
|
|
|
@@ -34,7 +42,7 @@ module.exports = {
|
|
|
34
42
|
|
|
35
43
|
if (typeof email !== 'string' || !validator.isEmail(email)) {
|
|
36
44
|
throw new errors.BadRequestError({
|
|
37
|
-
message:
|
|
45
|
+
message: tpl(messages.invalidEmailReceived)
|
|
38
46
|
});
|
|
39
47
|
}
|
|
40
48
|
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
const Promise = require('bluebird');
|
|
2
|
-
const
|
|
2
|
+
const tpl = require('@tryghost/tpl');
|
|
3
3
|
const errors = require('@tryghost/errors');
|
|
4
4
|
const models = require('../../../../../models');
|
|
5
5
|
|
|
6
|
+
const messages = {
|
|
7
|
+
userAlreadyRegistered: 'User is already registered.'
|
|
8
|
+
};
|
|
9
|
+
|
|
6
10
|
module.exports = {
|
|
7
11
|
add(apiConfig, frame) {
|
|
8
12
|
return models.User.findOne({email: frame.data.invites[0].email}, frame.options)
|
|
9
13
|
.then((user) => {
|
|
10
14
|
if (user) {
|
|
11
15
|
return Promise.reject(new errors.ValidationError({
|
|
12
|
-
message:
|
|
16
|
+
message: tpl(messages.userAlreadyRegistered)
|
|
13
17
|
}));
|
|
14
18
|
}
|
|
15
19
|
});
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
const Promise = require('bluebird');
|
|
2
|
-
const
|
|
2
|
+
const tpl = require('@tryghost/tpl');
|
|
3
3
|
const errors = require('@tryghost/errors');
|
|
4
4
|
|
|
5
|
+
const messages = {
|
|
6
|
+
noUrlProvided: 'No url provided.'
|
|
7
|
+
};
|
|
8
|
+
|
|
5
9
|
module.exports = {
|
|
6
10
|
read(apiConfig, frame) {
|
|
7
11
|
if (!frame.data.url || !frame.data.url.trim()) {
|
|
8
12
|
return Promise.reject(new errors.BadRequestError({
|
|
9
|
-
message:
|
|
13
|
+
message: tpl(messages.noUrlProvided)
|
|
10
14
|
}));
|
|
11
15
|
}
|
|
12
16
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
const Promise = require('bluebird');
|
|
2
2
|
const validator = require('@tryghost/validator');
|
|
3
3
|
const debug = require('@tryghost/debug')('api:v2:utils:validators:input:passwordreset');
|
|
4
|
-
const
|
|
4
|
+
const tpl = require('@tryghost/tpl');
|
|
5
5
|
const errors = require('@tryghost/errors');
|
|
6
6
|
|
|
7
|
+
const messages = {
|
|
8
|
+
newPasswordsDoNotMatch: 'Your new passwords do not match',
|
|
9
|
+
invalidEmailReceived: 'The server did not receive a valid email'
|
|
10
|
+
};
|
|
11
|
+
|
|
7
12
|
module.exports = {
|
|
8
13
|
resetPassword(apiConfig, frame) {
|
|
9
14
|
debug('resetPassword');
|
|
@@ -12,7 +17,7 @@ module.exports = {
|
|
|
12
17
|
|
|
13
18
|
if (data.newPassword !== data.ne2Password) {
|
|
14
19
|
return Promise.reject(new errors.ValidationError({
|
|
15
|
-
message:
|
|
20
|
+
message: tpl(messages.newPasswordsDoNotMatch)
|
|
16
21
|
}));
|
|
17
22
|
}
|
|
18
23
|
},
|
|
@@ -24,7 +29,7 @@ module.exports = {
|
|
|
24
29
|
|
|
25
30
|
if (typeof email !== 'string' || !validator.isEmail(email)) {
|
|
26
31
|
throw new errors.BadRequestError({
|
|
27
|
-
message:
|
|
32
|
+
message: tpl(messages.invalidEmailReceived)
|
|
28
33
|
});
|
|
29
34
|
}
|
|
30
35
|
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
const Promise = require('bluebird');
|
|
2
2
|
const _ = require('lodash');
|
|
3
|
-
const
|
|
3
|
+
const tpl = require('@tryghost/tpl');
|
|
4
4
|
const {BadRequestError, ValidationError} = require('@tryghost/errors');
|
|
5
5
|
|
|
6
|
+
const messages = {
|
|
7
|
+
error: 'Attempted to change active_theme via settings API',
|
|
8
|
+
help: 'Please activate theme via the themes API endpoints instead',
|
|
9
|
+
schemaValidationFailed: 'Validation failed for \'{key}\'.'
|
|
10
|
+
};
|
|
11
|
+
|
|
6
12
|
module.exports = {
|
|
7
13
|
edit(apiConfig, frame) {
|
|
8
14
|
const errors = [];
|
|
@@ -12,8 +18,8 @@ module.exports = {
|
|
|
12
18
|
// @NOTE: active theme has to be changed via theme endpoints
|
|
13
19
|
errors.push(
|
|
14
20
|
new BadRequestError({
|
|
15
|
-
message:
|
|
16
|
-
help:
|
|
21
|
+
message: tpl(messages.error),
|
|
22
|
+
help: tpl(messages.help)
|
|
17
23
|
})
|
|
18
24
|
);
|
|
19
25
|
}
|
|
@@ -25,7 +31,7 @@ module.exports = {
|
|
|
25
31
|
} catch (e) {
|
|
26
32
|
errors.push(
|
|
27
33
|
new ValidationError({
|
|
28
|
-
message:
|
|
34
|
+
message: tpl(messages.schemaValidationFailed, {
|
|
29
35
|
key: 'unsplash'
|
|
30
36
|
}),
|
|
31
37
|
property: 'unsplash'
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
const debug = require('@tryghost/debug')('api:v2:utils:validators:input:updateSetup');
|
|
2
|
-
const
|
|
2
|
+
const tpl = require('@tryghost/tpl');
|
|
3
3
|
const errors = require('@tryghost/errors');
|
|
4
4
|
|
|
5
|
+
const messages = {
|
|
6
|
+
notTheBlogOwner: 'You are not the site owner.'
|
|
7
|
+
};
|
|
8
|
+
|
|
5
9
|
module.exports = {
|
|
6
10
|
updateSetup(apiConfig, frame) {
|
|
7
11
|
debug('resetPassword');
|
|
8
12
|
|
|
9
13
|
if (!frame.options.context || !frame.options.context.user) {
|
|
10
|
-
throw new errors.NoPermissionError({message:
|
|
14
|
+
throw new errors.NoPermissionError({message: tpl(messages.notTheBlogOwner)});
|
|
11
15
|
}
|
|
12
16
|
}
|
|
13
17
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const Promise = require('bluebird');
|
|
2
2
|
const debug = require('@tryghost/debug')('api:v2:utils:validators:input:users');
|
|
3
|
-
const
|
|
3
|
+
const tpl = require('@tryghost/tpl');
|
|
4
4
|
const errors = require('@tryghost/errors');
|
|
5
|
+
const messages = {
|
|
6
|
+
newPasswordsDoNotMatch: 'Your new passwords do not match'
|
|
7
|
+
};
|
|
5
8
|
|
|
6
9
|
module.exports = {
|
|
7
10
|
changePassword(apiConfig, frame) {
|
|
@@ -11,7 +14,7 @@ module.exports = {
|
|
|
11
14
|
|
|
12
15
|
if (data.newPassword !== data.ne2Password) {
|
|
13
16
|
return Promise.reject(new errors.ValidationError({
|
|
14
|
-
message:
|
|
17
|
+
message: tpl(messages.newPasswordsDoNotMatch)
|
|
15
18
|
}));
|
|
16
19
|
}
|
|
17
20
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
const api = require('./index');
|
|
2
2
|
const config = require('../../../shared/config');
|
|
3
|
-
const i18n = require('../../../shared/i18n');
|
|
4
3
|
const errors = require('@tryghost/errors');
|
|
5
4
|
const web = require('../../web');
|
|
6
5
|
const models = require('../../models');
|
|
7
6
|
const auth = require('../../services/auth');
|
|
8
7
|
const invitations = require('../../services/invitations');
|
|
8
|
+
const tpl = require('@tryghost/tpl');
|
|
9
|
+
|
|
10
|
+
const messages = {
|
|
11
|
+
notTheBlogOwner: 'You are not the site owner.'
|
|
12
|
+
};
|
|
9
13
|
|
|
10
14
|
module.exports = {
|
|
11
15
|
docName: 'authentication',
|
|
@@ -50,7 +54,7 @@ module.exports = {
|
|
|
50
54
|
return models.User.findOne({role: 'Owner', status: 'all'})
|
|
51
55
|
.then((owner) => {
|
|
52
56
|
if (owner.id !== frame.options.context.user) {
|
|
53
|
-
throw new errors.NoPermissionError({message:
|
|
57
|
+
throw new errors.NoPermissionError({message: tpl(messages.notTheBlogOwner)});
|
|
54
58
|
}
|
|
55
59
|
});
|
|
56
60
|
},
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
const Promise = require('bluebird');
|
|
2
|
-
const i18n = require('../../../shared/i18n');
|
|
3
2
|
const errors = require('@tryghost/errors');
|
|
4
3
|
const models = require('../../models');
|
|
5
4
|
const ALLOWED_INCLUDES = ['count.posts'];
|
|
5
|
+
const tpl = require('@tryghost/tpl');
|
|
6
|
+
|
|
7
|
+
const messages = {
|
|
8
|
+
notFound: 'Author not found.'
|
|
9
|
+
};
|
|
6
10
|
|
|
7
11
|
module.exports = {
|
|
8
12
|
docName: 'authors',
|
|
@@ -54,7 +58,7 @@ module.exports = {
|
|
|
54
58
|
.then((model) => {
|
|
55
59
|
if (!model) {
|
|
56
60
|
return Promise.reject(new errors.NotFoundError({
|
|
57
|
-
message:
|
|
61
|
+
message: tpl(messages.notFound)
|
|
58
62
|
}));
|
|
59
63
|
}
|
|
60
64
|
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
const models = require('../../models');
|
|
2
|
-
const i18n = require('../../../shared/i18n');
|
|
3
2
|
const errors = require('@tryghost/errors');
|
|
4
3
|
const megaService = require('../../services/mega');
|
|
4
|
+
const tpl = require('@tryghost/tpl');
|
|
5
|
+
|
|
6
|
+
const messages = {
|
|
7
|
+
emailNotFound: 'Email not found.',
|
|
8
|
+
retryNotAllowed: 'Only failed emails can be retried'
|
|
9
|
+
};
|
|
5
10
|
|
|
6
11
|
module.exports = {
|
|
7
12
|
docName: 'emails',
|
|
@@ -24,7 +29,7 @@ module.exports = {
|
|
|
24
29
|
.then((model) => {
|
|
25
30
|
if (!model) {
|
|
26
31
|
throw new errors.NotFoundError({
|
|
27
|
-
message:
|
|
32
|
+
message: tpl(messages.emailNotFound)
|
|
28
33
|
});
|
|
29
34
|
}
|
|
30
35
|
|
|
@@ -43,13 +48,13 @@ module.exports = {
|
|
|
43
48
|
.then(async (model) => {
|
|
44
49
|
if (!model) {
|
|
45
50
|
throw new errors.NotFoundError({
|
|
46
|
-
message:
|
|
51
|
+
message: tpl(messages.emailNotFound)
|
|
47
52
|
});
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
if (model.get('status') !== 'failed') {
|
|
51
56
|
throw new errors.IncorrectUsageError({
|
|
52
|
-
message:
|
|
57
|
+
message: tpl(messages.retryNotAllowed)
|
|
53
58
|
});
|
|
54
59
|
}
|
|
55
60
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const i18n = require('../../../shared/i18n');
|
|
2
1
|
const errors = require('@tryghost/errors');
|
|
3
2
|
const models = require('../../models');
|
|
3
|
+
const tpl = require('@tryghost/tpl');
|
|
4
4
|
const getIntegrationsServiceInstance = require('../../services/integrations/integrations-service');
|
|
5
5
|
|
|
6
6
|
const integrationsService = getIntegrationsServiceInstance({
|
|
@@ -8,6 +8,10 @@ const integrationsService = getIntegrationsServiceInstance({
|
|
|
8
8
|
ApiKeyModel: models.ApiKey
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
+
const messages = {
|
|
12
|
+
resourceNotFound: '{resource} not found.'
|
|
13
|
+
};
|
|
14
|
+
|
|
11
15
|
module.exports = {
|
|
12
16
|
docName: 'integrations',
|
|
13
17
|
browse: {
|
|
@@ -51,7 +55,7 @@ module.exports = {
|
|
|
51
55
|
return models.Integration.findOne(data, Object.assign(options, {require: true}))
|
|
52
56
|
.catch(models.Integration.NotFoundError, () => {
|
|
53
57
|
throw new errors.NotFoundError({
|
|
54
|
-
message:
|
|
58
|
+
message: tpl(messages.resourceNotFound, {
|
|
55
59
|
resource: 'Integration'
|
|
56
60
|
})
|
|
57
61
|
});
|
|
@@ -136,7 +140,7 @@ module.exports = {
|
|
|
136
140
|
return models.Integration.destroy(Object.assign(options, {require: true}))
|
|
137
141
|
.catch(models.Integration.NotFoundError, () => {
|
|
138
142
|
return Promise.reject(new errors.NotFoundError({
|
|
139
|
-
message:
|
|
143
|
+
message: tpl(messages.resourceNotFound, {
|
|
140
144
|
resource: 'Integration'
|
|
141
145
|
})
|
|
142
146
|
}));
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
const Promise = require('bluebird');
|
|
2
|
-
const
|
|
2
|
+
const tpl = require('@tryghost/tpl');
|
|
3
3
|
const errors = require('@tryghost/errors');
|
|
4
4
|
const invites = require('../../services/invites');
|
|
5
5
|
const models = require('../../models');
|
|
6
6
|
const api = require('./index');
|
|
7
7
|
const ALLOWED_INCLUDES = [];
|
|
8
8
|
const UNSAFE_ATTRS = ['role_id'];
|
|
9
|
+
const messages = {
|
|
10
|
+
inviteNotFound: 'Invite not found.'
|
|
11
|
+
};
|
|
9
12
|
|
|
10
13
|
module.exports = {
|
|
11
14
|
docName: 'invites',
|
|
@@ -50,7 +53,7 @@ module.exports = {
|
|
|
50
53
|
.then((model) => {
|
|
51
54
|
if (!model) {
|
|
52
55
|
return Promise.reject(new errors.NotFoundError({
|
|
53
|
-
message:
|
|
56
|
+
message: tpl(messages.inviteNotFound)
|
|
54
57
|
}));
|
|
55
58
|
}
|
|
56
59
|
|
|
@@ -78,7 +81,7 @@ module.exports = {
|
|
|
78
81
|
.then(() => null)
|
|
79
82
|
.catch(models.Invite.NotFoundError, () => {
|
|
80
83
|
return Promise.reject(new errors.NotFoundError({
|
|
81
|
-
message:
|
|
84
|
+
message: tpl(messages.inviteNotFound)
|
|
82
85
|
}));
|
|
83
86
|
});
|
|
84
87
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
const Promise = require('bluebird');
|
|
2
|
-
const i18n = require('../../../shared/i18n');
|
|
3
2
|
const errors = require('@tryghost/errors');
|
|
4
3
|
const models = require('../../models');
|
|
4
|
+
const tpl = require('@tryghost/tpl');
|
|
5
|
+
|
|
6
|
+
const messages = {
|
|
7
|
+
labelNotFound: 'Label not found.',
|
|
8
|
+
labelAlreadyExists: 'Label already exists'
|
|
9
|
+
};
|
|
5
10
|
|
|
6
11
|
const ALLOWED_INCLUDES = ['count.members'];
|
|
7
12
|
|
|
@@ -53,7 +58,7 @@ module.exports = {
|
|
|
53
58
|
.then((model) => {
|
|
54
59
|
if (!model) {
|
|
55
60
|
return Promise.reject(new errors.NotFoundError({
|
|
56
|
-
message:
|
|
61
|
+
message: tpl(messages.labelNotFound)
|
|
57
62
|
}));
|
|
58
63
|
}
|
|
59
64
|
|
|
@@ -80,7 +85,7 @@ module.exports = {
|
|
|
80
85
|
return models.Label.add(frame.data.labels[0], frame.options)
|
|
81
86
|
.catch((error) => {
|
|
82
87
|
if (error.code && error.message.toLowerCase().indexOf('unique') !== -1) {
|
|
83
|
-
throw new errors.ValidationError({message:
|
|
88
|
+
throw new errors.ValidationError({message: tpl(messages.labelAlreadyExists)});
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
throw error;
|
|
@@ -110,7 +115,7 @@ module.exports = {
|
|
|
110
115
|
.then((model) => {
|
|
111
116
|
if (!model) {
|
|
112
117
|
return Promise.reject(new errors.NotFoundError({
|
|
113
|
-
message:
|
|
118
|
+
message: tpl(messages.labelNotFound)
|
|
114
119
|
}));
|
|
115
120
|
}
|
|
116
121
|
|
|
@@ -149,7 +154,7 @@ module.exports = {
|
|
|
149
154
|
.then(() => null)
|
|
150
155
|
.catch(models.Label.NotFoundError, () => {
|
|
151
156
|
return Promise.reject(new errors.NotFoundError({
|
|
152
|
-
message:
|
|
157
|
+
message: tpl(messages.labelNotFound)
|
|
153
158
|
}));
|
|
154
159
|
});
|
|
155
160
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const tpl = require('@tryghost/tpl');
|
|
2
2
|
const errors = require('@tryghost/errors');
|
|
3
3
|
const membersService = require('../../services/members');
|
|
4
|
+
const messages = {
|
|
5
|
+
memberNotFound: 'Member not found.'
|
|
6
|
+
};
|
|
4
7
|
|
|
5
8
|
module.exports = {
|
|
6
9
|
docName: 'member_signin_urls',
|
|
@@ -15,7 +18,7 @@ module.exports = {
|
|
|
15
18
|
|
|
16
19
|
if (!model) {
|
|
17
20
|
throw new errors.NotFoundError({
|
|
18
|
-
message:
|
|
21
|
+
message: tpl(messages.memberNotFound)
|
|
19
22
|
});
|
|
20
23
|
}
|
|
21
24
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const config = require('../../../shared/config');
|
|
2
2
|
const externalRequest = require('../../lib/request-external');
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
const OEmbed = require('../../services/oembed');
|
|
5
|
-
const oembed = new OEmbed({config, externalRequest
|
|
5
|
+
const oembed = new OEmbed({config, externalRequest});
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
8
|
docName: 'oembed',
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const tpl = require('@tryghost/tpl');
|
|
2
2
|
const errors = require('@tryghost/errors');
|
|
3
3
|
const models = require('../../models');
|
|
4
4
|
const ALLOWED_INCLUDES = ['tags', 'authors'];
|
|
5
|
+
const messages = {
|
|
6
|
+
pageNotFound: 'Page not found'
|
|
7
|
+
};
|
|
5
8
|
|
|
6
9
|
module.exports = {
|
|
7
10
|
docName: 'pages',
|
|
@@ -63,7 +66,7 @@ module.exports = {
|
|
|
63
66
|
.then((model) => {
|
|
64
67
|
if (!model) {
|
|
65
68
|
throw new errors.NotFoundError({
|
|
66
|
-
message:
|
|
69
|
+
message: tpl(messages.pageNotFound)
|
|
67
70
|
});
|
|
68
71
|
}
|
|
69
72
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
const models = require('../../models');
|
|
2
|
-
const
|
|
2
|
+
const tpl = require('@tryghost/tpl');
|
|
3
3
|
const errors = require('@tryghost/errors');
|
|
4
4
|
const getPostServiceInstance = require('../../services/posts/posts-service');
|
|
5
5
|
const ALLOWED_INCLUDES = ['tags', 'authors', 'authors.roles'];
|
|
6
6
|
const UNSAFE_ATTRS = ['status', 'authors', 'visibility'];
|
|
7
|
+
const messages = {
|
|
8
|
+
pageNotFound: 'Page not found'
|
|
9
|
+
};
|
|
7
10
|
|
|
8
11
|
const postsService = getPostServiceInstance('v3');
|
|
9
12
|
|
|
@@ -75,7 +78,7 @@ module.exports = {
|
|
|
75
78
|
.then((model) => {
|
|
76
79
|
if (!model) {
|
|
77
80
|
throw new errors.NotFoundError({
|
|
78
|
-
message:
|
|
81
|
+
message: tpl(messages.pageNotFound)
|
|
79
82
|
});
|
|
80
83
|
}
|
|
81
84
|
|
|
@@ -188,7 +191,7 @@ module.exports = {
|
|
|
188
191
|
.then(() => null)
|
|
189
192
|
.catch(models.Post.NotFoundError, () => {
|
|
190
193
|
return Promise.reject(new errors.NotFoundError({
|
|
191
|
-
message:
|
|
194
|
+
message: tpl(messages.pageNotFound)
|
|
192
195
|
}));
|
|
193
196
|
});
|
|
194
197
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const models = require('../../models');
|
|
2
|
-
const
|
|
2
|
+
const tpl = require('@tryghost/tpl');
|
|
3
3
|
const errors = require('@tryghost/errors');
|
|
4
4
|
const allowedIncludes = ['tags', 'authors'];
|
|
5
|
-
|
|
5
|
+
const messages = {
|
|
6
|
+
postNotFound: 'Post not found.'
|
|
7
|
+
};
|
|
6
8
|
module.exports = {
|
|
7
9
|
docName: 'posts',
|
|
8
10
|
|
|
@@ -63,7 +65,7 @@ module.exports = {
|
|
|
63
65
|
.then((model) => {
|
|
64
66
|
if (!model) {
|
|
65
67
|
throw new errors.NotFoundError({
|
|
66
|
-
message:
|
|
68
|
+
message: tpl(messages.postNotFound)
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
71
|
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
const models = require('../../models');
|
|
2
|
-
const
|
|
2
|
+
const tpl = require('@tryghost/tpl');
|
|
3
3
|
const errors = require('@tryghost/errors');
|
|
4
4
|
const getPostServiceInstance = require('../../services/posts/posts-service');
|
|
5
5
|
const allowedIncludes = ['tags', 'authors', 'authors.roles', 'email'];
|
|
6
6
|
const unsafeAttrs = ['status', 'authors', 'visibility'];
|
|
7
7
|
|
|
8
|
+
const messages = {
|
|
9
|
+
postNotFound: 'Post not found.'
|
|
10
|
+
};
|
|
11
|
+
|
|
8
12
|
const postsService = getPostServiceInstance('v3');
|
|
9
13
|
|
|
10
14
|
module.exports = {
|
|
@@ -73,7 +77,7 @@ module.exports = {
|
|
|
73
77
|
.then((model) => {
|
|
74
78
|
if (!model) {
|
|
75
79
|
throw new errors.NotFoundError({
|
|
76
|
-
message:
|
|
80
|
+
message: tpl(messages.postNotFound)
|
|
77
81
|
});
|
|
78
82
|
}
|
|
79
83
|
|
|
@@ -188,7 +192,7 @@ module.exports = {
|
|
|
188
192
|
.then(() => null)
|
|
189
193
|
.catch(models.Post.NotFoundError, () => {
|
|
190
194
|
return Promise.reject(new errors.NotFoundError({
|
|
191
|
-
message:
|
|
195
|
+
message: tpl(messages.postNotFound)
|
|
192
196
|
}));
|
|
193
197
|
});
|
|
194
198
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const tpl = require('@tryghost/tpl');
|
|
2
2
|
const errors = require('@tryghost/errors');
|
|
3
3
|
const models = require('../../models');
|
|
4
4
|
const ALLOWED_INCLUDES = ['authors', 'tags'];
|
|
5
|
-
|
|
5
|
+
const messages = {
|
|
6
|
+
postNotFound: 'Post not found.'
|
|
7
|
+
};
|
|
6
8
|
module.exports = {
|
|
7
9
|
docName: 'preview',
|
|
8
10
|
|
|
@@ -31,7 +33,7 @@ module.exports = {
|
|
|
31
33
|
.then((model) => {
|
|
32
34
|
if (!model) {
|
|
33
35
|
throw new errors.NotFoundError({
|
|
34
|
-
message:
|
|
36
|
+
message: tpl(messages.postNotFound)
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
39
|
|