diff --git a/ghost/admin/app/components/gh-tag-settings-form.js b/ghost/admin/app/components/gh-tag-settings-form.js index 44964d9c42..b91bd19a83 100644 --- a/ghost/admin/app/components/gh-tag-settings-form.js +++ b/ghost/admin/app/components/gh-tag-settings-form.js @@ -18,8 +18,8 @@ export default Component.extend({ scratchName: boundOneWay('tag.name'), scratchSlug: boundOneWay('tag.slug'), scratchDescription: boundOneWay('tag.description'), - scratchMetaTitle: boundOneWay('tag.meta_title'), - scratchMetaDescription: boundOneWay('tag.meta_description'), + scratchMetaTitle: boundOneWay('tag.metaTitle'), + scratchMetaDescription: boundOneWay('tag.metaDescription'), isViewingSubview: false, diff --git a/ghost/admin/app/components/gh-user-active.js b/ghost/admin/app/components/gh-user-active.js index fe5fb91e4e..13e7735bdb 100644 --- a/ghost/admin/app/components/gh-user-active.js +++ b/ghost/admin/app/components/gh-user-active.js @@ -23,8 +23,8 @@ export default Component.extend({ return Ember.String.htmlSafe(`background-image: url(${url})`); }), - lastLogin: computed('user.last_login', function () { - let lastLogin = this.get('user.last_login'); + lastLogin: computed('user.lastLogin', function () { + let lastLogin = this.get('user.lastLogin'); return lastLogin ? lastLogin.fromNow() : '(Never)'; }) diff --git a/ghost/admin/app/components/gh-user-invited.js b/ghost/admin/app/components/gh-user-invited.js index 2444cecb66..45a89c2ccb 100644 --- a/ghost/admin/app/components/gh-user-invited.js +++ b/ghost/admin/app/components/gh-user-invited.js @@ -14,8 +14,8 @@ export default Component.extend({ notifications: service(), - createdAt: computed('user.created_at', function () { - let createdAt = this.get('user.created_at'); + createdAt: computed('user.createdAt', function () { + let createdAt = this.get('user.createdAt'); return createdAt ? createdAt.fromNow() : ''; }), diff --git a/ghost/admin/app/controllers/post-settings-menu.js b/ghost/admin/app/controllers/post-settings-menu.js index 07f7231de8..3662eefd1d 100644 --- a/ghost/admin/app/controllers/post-settings-menu.js +++ b/ghost/admin/app/controllers/post-settings-menu.js @@ -85,8 +85,8 @@ export default Controller.extend(SettingsMenuMixin, { this.set('lastPromise', promise); }, - metaTitleScratch: boundOneWay('model.meta_title'), - metaDescriptionScratch: boundOneWay('model.meta_description'), + metaTitleScratch: boundOneWay('model.metaTitle'), + metaDescriptionScratch: boundOneWay('model.metaDescription'), seoTitle: computed('model.titleScratch', 'metaTitleScratch', function () { let metaTitle = this.get('metaTitleScratch') || ''; @@ -291,13 +291,13 @@ export default Controller.extend(SettingsMenuMixin, { */ setPublishedAt(userInput) { let newPublishedAt = parseDateString(userInput); - let publishedAt = moment(this.get('model.published_at')); + let publishedAt = moment(this.get('model.publishedAt')); let errMessage = ''; if (!userInput) { - // Clear out the published_at field for a draft + // Clear out the publishedAt field for a draft if (this.get('model.isDraft')) { - this.set('model.published_at', null); + this.set('model.publishedAt', null); } return; @@ -324,7 +324,7 @@ export default Controller.extend(SettingsMenuMixin, { } // Validation complete - this.set('model.published_at', newPublishedAt); + this.set('model.publishedAt', newPublishedAt); // If this is a new post. Don't save the model. Defer the save // to the user pressing the save button @@ -339,7 +339,7 @@ export default Controller.extend(SettingsMenuMixin, { }, setMetaTitle(metaTitle) { - let property = 'meta_title'; + let property = 'metaTitle'; let model = this.get('model'); let currentTitle = model.get(property) || ''; @@ -360,7 +360,7 @@ export default Controller.extend(SettingsMenuMixin, { }, setMetaDescription(metaDescription) { - let property = 'meta_description'; + let property = 'metaDescription'; let model = this.get('model'); let currentDescription = model.get(property) || ''; diff --git a/ghost/admin/app/controllers/posts.js b/ghost/admin/app/controllers/posts.js index 5518567607..c72d27aefe 100644 --- a/ghost/admin/app/controllers/posts.js +++ b/ghost/admin/app/controllers/posts.js @@ -5,18 +5,18 @@ const {equal} = computed; // a custom sort function is needed in order to sort the posts list the same way the server would: // status: ASC -// published_at: DESC -// updated_at: DESC +// publishedAt: DESC +// updatedAt: DESC // id: DESC function comparator(item1, item2) { - let updated1 = item1.get('updated_at'); - let updated2 = item2.get('updated_at'); + let updated1 = item1.get('updatedAt'); + let updated2 = item2.get('updatedAt'); let idResult, publishedAtResult, statusResult, updatedAtResult; - // when `updated_at` is undefined, the model is still + // when `updatedAt` is undefined, the model is still // being written to with the results from the server if (item1.get('isNew') || !updated1) { return -1; @@ -48,8 +48,8 @@ function comparator(item1, item2) { } function publishedAtCompare(item1, item2) { - let published1 = item1.get('published_at'); - let published2 = item2.get('published_at'); + let published1 = item1.get('publishedAt'); + let published2 = item2.get('publishedAt'); if (!published1 && !published2) { return 0; @@ -74,7 +74,7 @@ export default Controller.extend({ postListFocused: equal('keyboardFocus', 'postList'), postContentFocused: equal('keyboardFocus', 'postContent'), - sortedPosts: computed('model.@each.status', 'model.@each.published_at', 'model.@each.isNew', 'model.@each.updated_at', function () { + sortedPosts: computed('model.@each.status', 'model.@each.publishedAt', 'model.@each.isNew', 'model.@each.updatedAt', function () { let postsArray = this.get('model').toArray(); return postsArray.sort(comparator); diff --git a/ghost/admin/app/mixins/editor-base-controller.js b/ghost/admin/app/mixins/editor-base-controller.js index d789e4387c..c17065846c 100644 --- a/ghost/admin/app/mixins/editor-base-controller.js +++ b/ghost/admin/app/mixins/editor-base-controller.js @@ -308,8 +308,8 @@ export default Mixin.create({ } this.set('model.title', this.get('model.titleScratch')); - this.set('model.meta_title', psmController.get('metaTitleScratch')); - this.set('model.meta_description', psmController.get('metaDescriptionScratch')); + this.set('model.metaTitle', psmController.get('metaTitleScratch')); + this.set('model.metaDescription', psmController.get('metaDescriptionScratch')); if (!this.get('model.slug')) { // Cancel any pending slug generation that may still be queued in the diff --git a/ghost/admin/app/models/post.js b/ghost/admin/app/models/post.js index 85762716a4..a1c094e032 100644 --- a/ghost/admin/app/models/post.js +++ b/ghost/admin/app/models/post.js @@ -24,16 +24,16 @@ export default Model.extend(ValidationEngine, { page: attr('boolean', {defaultValue: false}), status: attr('string', {defaultValue: 'draft'}), language: attr('string', {defaultValue: 'en_US'}), - meta_title: attr('string'), - meta_description: attr('string'), + metaTitle: attr('string'), + metaDescription: attr('string'), author: belongsTo('user', {async: true}), - author_id: attr('number'), - updated_at: attr('moment-date'), - updated_by: attr(), - published_at: attr('moment-date'), - published_by: belongsTo('user', {async: true}), - created_at: attr('moment-date'), - created_by: attr(), + authorId: attr('number'), + updatedAt: attr('moment-date'), + updatedBy: attr(), + publishedAt: attr('moment-date'), + publishedBy: belongsTo('user', {async: true}), + createdAt: attr('moment-date'), + createdBy: attr(), tags: hasMany('tag', { embedded: 'always', async: false @@ -81,7 +81,7 @@ export default Model.extend(ValidationEngine, { }, isAuthoredByUser(user) { - return parseInt(user.get('id'), 10) === parseInt(this.get('author_id'), 10); + return parseInt(user.get('id'), 10) === parseInt(this.get('authorId'), 10); } }); diff --git a/ghost/admin/app/models/role.js b/ghost/admin/app/models/role.js index 0def8f5f49..6d93ba775b 100644 --- a/ghost/admin/app/models/role.js +++ b/ghost/admin/app/models/role.js @@ -9,10 +9,10 @@ export default Model.extend({ uuid: attr('string'), name: attr('string'), description: attr('string'), - created_at: attr('moment-date'), - updated_at: attr('moment-date'), - created_by: attr(), - updated_by: attr(), + createdAt: attr('moment-date'), + updatedAt: attr('moment-date'), + createdBy: attr(), + updatedBy: attr(), lowerCaseName: computed('name', function () { return this.get('name').toLocaleLowerCase(); diff --git a/ghost/admin/app/models/tag.js b/ghost/admin/app/models/tag.js index 04deeaf42a..ef5f03f7a1 100644 --- a/ghost/admin/app/models/tag.js +++ b/ghost/admin/app/models/tag.js @@ -11,13 +11,13 @@ export default Model.extend(ValidationEngine, { slug: attr('string'), description: attr('string'), parent: attr(), - meta_title: attr('string'), - meta_description: attr('string'), + metaTitle: attr('string'), + metaDescription: attr('string'), image: attr('string'), hidden: attr('boolean'), - created_at: attr('moment-date'), - updated_at: attr('moment-date'), - created_by: attr(), - updated_by: attr(), + createdAt: attr('moment-date'), + updatedAt: attr('moment-date'), + createdBy: attr(), + updatedBy: attr(), count: attr('raw') }); diff --git a/ghost/admin/app/models/user.js b/ghost/admin/app/models/user.js index b973ac253e..17a97a763f 100644 --- a/ghost/admin/app/models/user.js +++ b/ghost/admin/app/models/user.js @@ -26,13 +26,13 @@ export default Model.extend(ValidationEngine, { accessibility: attr('string'), status: attr('string'), language: attr('string', {defaultValue: 'en_US'}), - meta_title: attr('string'), - meta_description: attr('string'), - last_login: attr('moment-date'), - created_at: attr('moment-date'), - created_by: attr('number'), - updated_at: attr('moment-date'), - updated_by: attr('number'), + metaTitle: attr('string'), + metaDescription: attr('string'), + lastLogin: attr('moment-date'), + createdAt: attr('moment-date'), + createdBy: attr('number'), + updatedAt: attr('moment-date'), + updatedBy: attr('number'), roles: hasMany('role', { embedded: 'always', async: false diff --git a/ghost/admin/app/serializers/application.js b/ghost/admin/app/serializers/application.js index 6bf403115f..9d15cf539d 100644 --- a/ghost/admin/app/serializers/application.js +++ b/ghost/admin/app/serializers/application.js @@ -1,6 +1,10 @@ import Ember from 'ember'; import RESTSerializer from 'ember-data/serializers/rest'; +const { + decamelize +} = Ember.String; + export default RESTSerializer.extend({ serializeIntoHash(hash, type, record, options) { // Our API expects an id on the posted object @@ -15,5 +19,9 @@ export default RESTSerializer.extend({ delete data.uuid; hash[root] = [data]; + }, + + keyForAttribute(attr) { + return decamelize(attr); } }); diff --git a/ghost/admin/app/serializers/post.js b/ghost/admin/app/serializers/post.js index 8a5292528b..f30a2c11a6 100644 --- a/ghost/admin/app/serializers/post.js +++ b/ghost/admin/app/serializers/post.js @@ -12,10 +12,10 @@ export default ApplicationSerializer.extend(EmbeddedRecordsMixin, { }, normalize(typeClass, hash, prop) { - // this is to enable us to still access the raw author_id + // this is to enable us to still access the raw authorId // without requiring an extra get request (since it is an // async relationship). - hash.author_id = hash.author; + hash.authorId = hash.author; return this._super(typeClass, hash, prop); }, @@ -47,7 +47,7 @@ export default ApplicationSerializer.extend(EmbeddedRecordsMixin, { delete data.uuid; delete data.html; // Inserted locally as a convenience. - delete data.author_id; + delete data.authorId; // Read-only virtual property. delete data.url; diff --git a/ghost/admin/app/serializers/setting.js b/ghost/admin/app/serializers/setting.js index 1e6d1f85b2..634ae484c2 100644 --- a/ghost/admin/app/serializers/setting.js +++ b/ghost/admin/app/serializers/setting.js @@ -30,6 +30,10 @@ export default ApplicationSerializer.extend({ return this._super(store, primaryModelClass, payload, id, requestType); }, + keyForAttribute(attr) { + return attr; + }, + _extractObjectFromArrayPayload(_payload) { let payload = {id: '0'}; diff --git a/ghost/admin/app/templates/components/gh-tag-settings-form.hbs b/ghost/admin/app/templates/components/gh-tag-settings-form.hbs index db5b638082..fdcf58779e 100644 --- a/ghost/admin/app/templates/components/gh-tag-settings-form.hbs +++ b/ghost/admin/app/templates/components/gh-tag-settings-form.hbs @@ -57,17 +57,17 @@