Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Add v2.14.2
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickRe committed Feb 13, 2019
1 parent df5aafd commit 8d1a403
Show file tree
Hide file tree
Showing 24 changed files with 811 additions and 613 deletions.

Large diffs are not rendered by default.

11 changes: 1 addition & 10 deletions core/server/api/v2/configuration.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const Promise = require('bluebird');
const {isPlainObject} = require('lodash');
const urlService = require('../../services/url');
const models = require('../../models');
const config = require('../../config');
const labs = require('../../services/labs');
const settingsCache = require('../../services/settings/cache');
Expand Down Expand Up @@ -41,15 +40,7 @@ module.exports = {
],
query({data}) {
if (!data.key) {
return models.Client.findOne({slug: 'ghost-admin'})
.then((ghostAdmin) => {
const configuration = getBaseConfig();

configuration.clientId = ghostAdmin.get('slug');
configuration.clientSecret = ghostAdmin.get('secret');

return configuration;
});
return Promise.resolve(getBaseConfig());
}

if (data.key === 'about') {
Expand Down
4 changes: 2 additions & 2 deletions core/server/api/v2/utils/serializers/input/utils/url.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const _ = require('lodash');
const {absoluteToRelative, getBlogUrl, STATIC_IMAGE_URL_PREFIX} = require('../../../../../../services/url/utils');

const blogDomain = getBlogUrl().replace(/^http(s?):\/\//, '').replace(/\/$/, '');

const handleImageUrl = (imageUrl) => {
const blogDomain = getBlogUrl().replace(/^http(s?):\/\//, '').replace(/\/$/, '');
const imageUrlAbsolute = imageUrl.replace(/^http(s?):\/\//, '');
const imagePathRe = new RegExp(`^${blogDomain}/${STATIC_IMAGE_URL_PREFIX}`);
if (imagePathRe.test(imageUrlAbsolute)) {
Expand All @@ -13,6 +12,7 @@ const handleImageUrl = (imageUrl) => {
};

const handleContentUrls = (content) => {
const blogDomain = getBlogUrl().replace(/^http(s?):\/\//, '').replace(/\/$/, '');
const imagePathRe = new RegExp(`(http(s?)://)?${blogDomain}/${STATIC_IMAGE_URL_PREFIX}`, 'g');

const matches = _.uniq(content.match(imagePathRe));
Expand Down
108 changes: 57 additions & 51 deletions core/server/api/v2/utils/serializers/output/utils/clean.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,81 @@
const _ = require('lodash');
const localUtils = require('../../../index');

const tag = (attrs) => {
const tag = (attrs, frame) => {
if (localUtils.isContentAPI(frame)) {
delete attrs.created_at;
delete attrs.updated_at;

// We are standardising on returning null from the Content API for any empty values
if (attrs.meta_title === '') {
attrs.meta_title = null;
}
if (attrs.meta_description === '') {
attrs.meta_description = null;
}
if (attrs.description === '') {
attrs.description = null;
}
}

// Already deleted in model.toJSON, but leaving here so that we can clean that up when we deprecate v0.1
delete attrs.parent_id;

// Extra properties removed from v2
// @NOTE: unused fields
delete attrs.parent;
delete attrs.created_at;
delete attrs.updated_at;

// We are standardising on returning null from the Content API for any empty values
if (attrs.meta_title === '') {
attrs.meta_title = null;
}
if (attrs.meta_description === '') {
attrs.meta_description = null;
}
if (attrs.description === '') {
attrs.description = null;
}

return attrs;
};

const author = (attrs) => {
// Already deleted in model.toJSON, but leaving here so that we can clean that up when we deprecate v0.1
delete attrs.created_at;
delete attrs.updated_at;
delete attrs.last_seen;
delete attrs.status;
delete attrs.ghost_auth_id;
const author = (attrs, frame) => {
if (localUtils.isContentAPI(frame)) {
// Already deleted in model.toJSON, but leaving here so that we can clean that up when we deprecate v0.1
delete attrs.created_at;
delete attrs.updated_at;
delete attrs.last_seen;
delete attrs.status;

// Extra properties removed from v2
delete attrs.accessibility;
delete attrs.locale;
delete attrs.tour;
delete attrs.visibility;
// Extra properties removed from v2
delete attrs.tour;

// We are standardising on returning null from the Content API for any empty values
if (attrs.twitter === '') {
attrs.twitter = null;
}
if (attrs.bio === '') {
attrs.bio = null;
}
if (attrs.website === '') {
attrs.website = null;
}
if (attrs.facebook === '') {
attrs.facebook = null;
}
if (attrs.meta_title === '') {
attrs.meta_title = null;
}
if (attrs.meta_description === '') {
attrs.meta_description = null;
}
if (attrs.location === '') {
attrs.location = null;
// We are standardising on returning null from the Content API for any empty values
if (attrs.twitter === '') {
attrs.twitter = null;
}
if (attrs.bio === '') {
attrs.bio = null;
}
if (attrs.website === '') {
attrs.website = null;
}
if (attrs.facebook === '') {
attrs.facebook = null;
}
if (attrs.meta_title === '') {
attrs.meta_title = null;
}
if (attrs.meta_description === '') {
attrs.meta_description = null;
}
if (attrs.location === '') {
attrs.location = null;
}
}

// @NOTE: unused fields
delete attrs.visibility;
delete attrs.accessibility;
delete attrs.locale;
delete attrs.ghost_auth_id;

return attrs;
};

const post = (attrs, frame) => {
if (localUtils.isContentAPI(frame)) {
delete attrs.locale;

// @TODO: https://github.com/TryGhost/Ghost/issues/10335
// delete attrs.page;
delete attrs.status;
delete attrs.visibility;

// We are standardising on returning null from the Content API for any empty values
if (attrs.twitter_title === '') {
Expand All @@ -94,6 +98,8 @@ const post = (attrs, frame) => {
}
}

delete attrs.locale;
delete attrs.visibility;
delete attrs.author;

return attrs;
Expand Down
9 changes: 2 additions & 7 deletions core/server/api/v2/utils/serializers/output/utils/mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ const mapUser = (model, frame) => {

url.forUser(model.id, jsonModel);

if (utils.isContentAPI(frame)) {
clean.author(jsonModel);
}
clean.author(jsonModel, frame);

return jsonModel;
};
Expand All @@ -21,10 +19,7 @@ const mapTag = (model, frame) => {
const jsonModel = model.toJSON ? model.toJSON(frame.options) : model;

url.forTag(model.id, jsonModel);

if (utils.isContentAPI(frame)) {
clean.tag(jsonModel);
}
clean.tag(jsonModel, frame);

return jsonModel;
};
Expand Down
4 changes: 4 additions & 0 deletions core/server/api/v2/utils/validators/input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module.exports = {
return require('./settings');
},

get tags() {
return require('./tags');
},

get users() {
return require('./users');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"properties": {
"posts": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"type": "object",
"allOf": [{"$ref": "posts#/definitions/post"}],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"properties": {
"posts": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {"$ref": "posts#/definitions/post"}
}
},
Expand Down
51 changes: 27 additions & 24 deletions core/server/api/v2/utils/validators/input/schemas/posts.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"maxLength": 24
},
"title": {
"type": "string",
"maxLength": 2000
Expand All @@ -27,7 +23,7 @@
},
"feature_image": {
"type": ["string", "null"],
"format": "uri",
"format": "uri-reference",
"maxLength": 2000
},
"featured": {
Expand Down Expand Up @@ -56,30 +52,14 @@
"type": ["string", "null"],
"maxLength": 500
},
"created_at": {
"type": "string",
"format": "date-time"
},
"created_by": {
"type": "string",
"maxLength": 24
},
"updated_at": {
"type": ["string", "null"],
"format": "date-time"
},
"updated_by": {
"type": ["string", "null"],
"maxLength": 24
},
"published_at": {
"type": ["string", "null"],
"format": "date-time"
},
"published_by": {
"type": ["string", "null"],
"maxLength": 24
},
"custom_excerpt": {
"type": ["string", "null"],
"maxLength": 300
Expand All @@ -94,7 +74,7 @@
},
"og_image": {
"type": ["string", "null"],
"format": "uri",
"format": "uri-reference",
"maxLength": 2000
},
"og_title": {
Expand All @@ -107,7 +87,7 @@
},
"twitter_image": {
"type": ["string", "null"],
"format": "uri",
"format": "uri-reference",
"maxLength": 2000
},
"twitter_title": {
Expand All @@ -127,6 +107,21 @@
},
"tags": {
"$ref": "#/definitions/post-tags"
},
"id": {
"strip": true
},
"created_at": {
"strip": true
},
"created_by": {
"strip": true
},
"updated_by": {
"strip": true
},
"published_by": {
"strip": true
}
}
},
Expand All @@ -153,6 +148,14 @@
"id": {
"type": "string",
"maxLength": 24
},
"name": {
"type": "string",
"maxLength": 191
},
"slug": {
"type": "string",
"maxLength": 191
}
},
"anyOf": [
Expand All @@ -163,4 +166,4 @@
}
}
}
}
}
23 changes: 23 additions & 0 deletions core/server/api/v2/utils/validators/input/schemas/tags-add.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "tags.add",
"title": "tags.add",
"description": "Schema for tags.add",
"type": "object",
"additionalProperties": false,
"properties": {
"tags": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"additionalProperties": false,
"items": {
"type": "object",
"allOf": [{"$ref": "tags#/definitions/tag"}],
"required": ["name"]
}
}
},
"required": [ "tags" ]
}
18 changes: 18 additions & 0 deletions core/server/api/v2/utils/validators/input/schemas/tags-edit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "tags.edit",
"title": "tags.edit",
"description": "Schema for tags.edit",
"type": "object",
"additionalProperties": false,
"properties": {
"tags": {
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {"$ref": "tags#/definitions/tag"}
}
},
"required": [ "tags" ]
}
Loading

0 comments on commit 8d1a403

Please sign in to comment.