mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Added built-in automatic featured collection
refs https://github.com/TryGhost/Team/issues/3376 - When the Ghost instance is initialized it has to have a set of built-in collections. With these changes Ghost starts with a "featured posts" collection - available to be used right away.
This commit is contained in:
parent
fbfb1d0008
commit
bdbd9327d9
5 changed files with 45 additions and 4 deletions
|
@ -325,6 +325,7 @@ async function initServices({config}) {
|
|||
const postsPublic = require('./server/services/posts-public');
|
||||
const slackNotifications = require('./server/services/slack-notifications');
|
||||
const mediaInliner = require('./server/services/media-inliner');
|
||||
const collections = require('./server/services/collections');
|
||||
|
||||
const urlUtils = require('./shared/url-utils');
|
||||
|
||||
|
@ -361,6 +362,7 @@ async function initServices({config}) {
|
|||
linkTracking.init(),
|
||||
emailSuppressionList.init(),
|
||||
slackNotifications.init(),
|
||||
collections.init(),
|
||||
mediaInliner.init()
|
||||
]);
|
||||
debug('End: Services');
|
||||
|
|
|
@ -44,6 +44,16 @@ class CollectionsServiceWrapper {
|
|||
destroyCollectionPost: collectionsService.removePostFromCollection.bind(collectionsService)
|
||||
};
|
||||
}
|
||||
|
||||
async init() {
|
||||
this.api.add({
|
||||
title: 'Featured Posts',
|
||||
slug: 'featured',
|
||||
description: 'Collection of featured posts',
|
||||
type: 'automatic',
|
||||
filter: 'featured:true'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new CollectionsServiceWrapper();
|
||||
|
|
|
@ -182,6 +182,17 @@ Object {
|
|||
exports[`Collections API Can browse Collections 1: [body] 1`] = `
|
||||
Object {
|
||||
"collections": Array [
|
||||
Object {
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"description": "Collection of featured posts",
|
||||
"feature_image": null,
|
||||
"filter": "featured:true",
|
||||
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||
"posts": Array [],
|
||||
"title": "Featured Posts",
|
||||
"type": "automatic",
|
||||
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
},
|
||||
Object {
|
||||
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||
"description": "Test Collection Description",
|
||||
|
@ -196,12 +207,12 @@ Object {
|
|||
],
|
||||
"meta": Object {
|
||||
"pagination": Object {
|
||||
"limit": 1,
|
||||
"limit": 2,
|
||||
"next": null,
|
||||
"page": 1,
|
||||
"pages": 1,
|
||||
"prev": null,
|
||||
"total": 1,
|
||||
"total": 2,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -211,7 +222,7 @@ exports[`Collections API Can browse Collections 2: [headers] 1`] = `
|
|||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
"content-length": "350",
|
||||
"content-length": "610",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
|
|
|
@ -82,7 +82,7 @@ describe('Collections API', function () {
|
|||
etag: anyEtag
|
||||
})
|
||||
.matchBodySnapshot({
|
||||
collections: [matchCollection]
|
||||
collections: Array(2).fill(buildMatcher(0))
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
const assert = require('assert');
|
||||
const collectionsServiceWrapper = require('../../../../../core/server/services/collections');
|
||||
|
||||
describe('CollectionsServiceWrapper', function () {
|
||||
it('Exposes a valid instance of CollectionsServiceWrapper', async function () {
|
||||
assert.ok(collectionsServiceWrapper);
|
||||
assert.ok(collectionsServiceWrapper.api);
|
||||
assert.deepEqual(Object.keys(collectionsServiceWrapper.api), [
|
||||
'browse',
|
||||
'read',
|
||||
'add',
|
||||
'edit',
|
||||
'addPost',
|
||||
'destroy',
|
||||
'destroyCollectionPost'
|
||||
]);
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue