mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-03 03:55:26 +03:00
Add include parameter for posts API
closes #2609 - added include parameter to api.posts.* - changed toJSON to omit objects that are not included - added include parameter to admin - added include parameter to frontend.js - updated tests - removed duplicate code from posts model **Known Issue:** It is not possible to attach a tag using an ID.
This commit is contained in:
parent
8d2cf655c2
commit
254b6618f3
@ -49,6 +49,7 @@
|
||||
if (method === 'create' || method === 'update') {
|
||||
options.data = JSON.stringify({posts: [this.attributes]});
|
||||
options.contentType = 'application/json';
|
||||
options.url = model.url() + '?include=tags';
|
||||
}
|
||||
|
||||
return Backbone.Model.prototype.sync.apply(this, arguments);
|
||||
|
@ -3,7 +3,7 @@
|
||||
'use strict';
|
||||
|
||||
Ghost.Models.Themes = Backbone.Model.extend({
|
||||
url: Ghost.paths.apiRoot + '/themes'
|
||||
url: Ghost.paths.apiRoot + '/themes/'
|
||||
});
|
||||
|
||||
}());
|
||||
|
@ -36,7 +36,7 @@
|
||||
blog: function () {
|
||||
var posts = new Ghost.Collections.Posts();
|
||||
NProgress.start();
|
||||
posts.fetch({ data: { status: 'all', staticPages: 'all'} }).then(function () {
|
||||
posts.fetch({ data: { status: 'all', staticPages: 'all', include: 'author'} }).then(function () {
|
||||
Ghost.currentView = new Ghost.Views.Blog({ el: '#main', collection: posts });
|
||||
NProgress.done();
|
||||
});
|
||||
@ -63,7 +63,7 @@
|
||||
post.urlRoot = Ghost.paths.apiRoot + '/posts';
|
||||
if (id) {
|
||||
post.id = id;
|
||||
post.fetch({ data: {status: 'all'}}).then(function () {
|
||||
post.fetch({ data: {status: 'all', include: 'tags'}}).then(function () {
|
||||
Ghost.currentView = new Ghost.Views.Editor({ el: '#main', model: post });
|
||||
});
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user