Merge branch 'master' into v3

This commit is contained in:
Kevin Ansfield 2019-10-10 10:37:42 +01:00
commit 7fc10106dc
11 changed files with 40 additions and 18 deletions

@ -1 +1 @@
Subproject commit ebe7c1475f6be9ec3e6471be7b58e76dcb4ae9c6
Subproject commit 2e91cb09bf9ea348552eae7daede465f227cb4b3

View File

@ -1,3 +1,5 @@
const readingMinutes = require('@tryghost/helpers').utils.readingMinutes;
module.exports.forPost = (frame, model, attrs) => {
const _ = require('lodash');
@ -15,6 +17,19 @@ module.exports.forPost = (frame, model, attrs) => {
attrs.excerpt = attrs.custom_excerpt;
}
}
if (!Object.prototype.hasOwnProperty.call(frame.options, 'columns') ||
(frame.options.columns.includes('reading_time'))) {
if (attrs.html) {
let additionalImages = 0;
if (attrs.feature_image) {
additionalImages += 1;
}
attrs.reading_time = readingMinutes(attrs.html, additionalImages);
}
}
};
module.exports.forSettings = (attrs, frame) => {

View File

@ -26,7 +26,12 @@ const nonePublicAuth = (apiConfig, frame) => {
permissionIdentifier = apiConfig.identifier(frame);
}
const unsafeAttrObject = apiConfig.unsafeAttrs && _.has(frame, `data.[${apiConfig.docName}][0]`) ? _.pick(frame.data[apiConfig.docName][0], apiConfig.unsafeAttrs) : {};
let unsafeAttrObject = apiConfig.unsafeAttrs && _.has(frame, `data.[${apiConfig.docName}][0]`) ? _.pick(frame.data[apiConfig.docName][0], apiConfig.unsafeAttrs) : {};
if (apiConfig.unsafeAttrsObject) {
unsafeAttrObject = apiConfig.unsafeAttrsObject(frame);
}
const permsPromise = permissions.canThis(frame.options.context)[apiConfig.method][singular](permissionIdentifier, unsafeAttrObject);
return permsPromise.then((result) => {

View File

@ -33,6 +33,7 @@ const expectedProperties = {
.concat(
..._(schema.posts_meta).keys().without('post_id', 'id')
)
.concat('reading_time')
,
author: _(schema.users)
.keys()

View File

@ -60,7 +60,7 @@ describe('DB API', function () {
const jsonResponse = res.body;
should.exist(jsonResponse.db);
jsonResponse.db.should.have.length(1);
Object.keys(jsonResponse.db[0].data).length.should.eql(28);
Object.keys(jsonResponse.db[0].data).length.should.eql(29);
});
});

View File

@ -5,7 +5,7 @@ const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('Settings API', function () {
describe('Settings API (canary)', function () {
let ghostServer;
let request;

View File

@ -32,6 +32,7 @@ const expectedProperties = {
.concat(
..._(schema.posts_meta).keys().without('post_id', 'id')
)
.concat('reading_time')
,
author: _(schema.users)
.keys()

View File

@ -60,7 +60,7 @@ describe('DB API', function () {
const jsonResponse = res.body;
should.exist(jsonResponse.db);
jsonResponse.db.should.have.length(1);
Object.keys(jsonResponse.db[0].data).length.should.eql(28);
Object.keys(jsonResponse.db[0].data).length.should.eql(29);
});
});

View File

@ -5,7 +5,7 @@ const testUtils = require('../../../../utils');
const localUtils = require('./utils');
const ghost = testUtils.startGhost;
describe('Settings API', function () {
describe('Settings API (v2)', function () {
let ghostServer;
let request;
@ -262,7 +262,7 @@ describe('Settings API', function () {
});
});
it('cannot toggle member setting', function (done) {
it.skip('cannot toggle member setting', function (done) {
const settingToChange = {
settings: [
{

View File

@ -1,6 +1,6 @@
{
"name": "ghost",
"version": "2.33.0",
"version": "2.34.0",
"description": "The professional publishing platform",
"author": "Ghost Foundation",
"homepage": "https://ghost.org",
@ -40,12 +40,12 @@
},
"dependencies": {
"@nexes/nql": "0.3.0",
"@tryghost/helpers": "1.1.12",
"@tryghost/helpers": "1.1.15",
"@tryghost/members-api": "0.8.0",
"@tryghost/members-ssr": "0.7.0",
"@tryghost/social-urls": "0.1.2",
"@tryghost/string": "^0.1.3",
"@tryghost/url-utils": "0.6.1",
"@tryghost/url-utils": "0.6.5",
"ajv": "6.10.2",
"amperize": "0.6.0",
"analytics-node": "3.3.0",

View File

@ -199,10 +199,10 @@
mkdirp "0.5.0"
yauzl "2.4.1"
"@tryghost/helpers@1.1.12":
version "1.1.12"
resolved "https://registry.yarnpkg.com/@tryghost/helpers/-/helpers-1.1.12.tgz#ca77aa2649abd2d12760b36af2d6779619202971"
integrity sha512-9ns/YTXfUb+UOmILQq071qZ8Y6eIEvNQFLZtFiguhOzXqSHC+rKg45aNCcoP8G9opG7vmm7bkxeE/hiQ205qpw==
"@tryghost/helpers@1.1.15":
version "1.1.15"
resolved "https://registry.yarnpkg.com/@tryghost/helpers/-/helpers-1.1.15.tgz#8a8e53af47630707aeb328fc949ce37464f7d447"
integrity sha512-llve/Ha+uUnqrqP4TlGIXf+W5nDRv6XsiqLWoUFARtciP42kMQLQY+ABC4Fmc0N1daD1P020jTjd7eX+9fdVFw==
dependencies:
lodash-es "^4.17.11"
@ -297,10 +297,10 @@
dependencies:
unidecode "^0.1.8"
"@tryghost/url-utils@0.6.1":
version "0.6.1"
resolved "https://registry.yarnpkg.com/@tryghost/url-utils/-/url-utils-0.6.1.tgz#cb3a1c199ff855a131588258e43bbcb1599b856c"
integrity sha512-FfHc/OoMqKvKbQ8Rir09wkeFZPV7FZMfmnKaVFOUoJPuULetFmfS8yP0WNBHNfGj197aT+JyyJH2QpFokvPprQ==
"@tryghost/url-utils@0.6.5":
version "0.6.5"
resolved "https://registry.yarnpkg.com/@tryghost/url-utils/-/url-utils-0.6.5.tgz#a393e67e60daf265fd5d3e4ff6423bd0573bcd10"
integrity sha512-Ah6gmFo79a4p/lpzGC/EMwKgw5jEiURJAtaj3RSAiOaDF8VIAdjg7G4zO6CY8ShnMCCo7xizIGUMETHePRBgVA==
dependencies:
cheerio "0.22.0"
moment "2.24.0"