diff --git a/core/client/app/adapters/base.js b/core/client/app/adapters/base.js index c01977f9d3..2c8e7d6bfb 100644 --- a/core/client/app/adapters/base.js +++ b/core/client/app/adapters/base.js @@ -13,7 +13,7 @@ var BaseAdapter = DS.RESTAdapter.extend({ delete query.id; } - return this.ajax(this.buildURL(type.typeKey, id), 'GET', {data: query}); + return this.ajax(this.buildURL(type.modelName, id), 'GET', {data: query}); }, buildURL: function (type, id) { diff --git a/core/client/app/adapters/embedded-relation-adapter.js b/core/client/app/adapters/embedded-relation-adapter.js index 21ad3b12c2..08d9559ce4 100644 --- a/core/client/app/adapters/embedded-relation-adapter.js +++ b/core/client/app/adapters/embedded-relation-adapter.js @@ -53,7 +53,7 @@ var EmbeddedRelationAdapter = BaseAdapter.extend({ }, preparePayload: function (store, type, record) { - var serializer = store.serializerFor(type.typeKey), + var serializer = store.serializerFor(type.modelName), payload = {}; serializer.serializeIntoHash(payload, type, record); @@ -62,7 +62,7 @@ var EmbeddedRelationAdapter = BaseAdapter.extend({ }, buildIncludeURL: function (store, type, id) { - var url = this.buildURL(type.typeKey, id), + var url = this.buildURL(type.modelName, id), includes = this.getEmbeddedRelations(store, type); if (includes.length) { diff --git a/core/client/app/adapters/setting.js b/core/client/app/adapters/setting.js index f2c021f171..769fce42dd 100644 --- a/core/client/app/adapters/setting.js +++ b/core/client/app/adapters/setting.js @@ -3,7 +3,7 @@ import ApplicationAdapter from 'ghost/adapters/application'; var SettingAdapter = ApplicationAdapter.extend({ updateRecord: function (store, type, record) { var data = {}, - serializer = store.serializerFor(type.typeKey); + serializer = store.serializerFor(type.modelName); // remove the fake id that we added onto the model. delete record.id; @@ -14,7 +14,7 @@ var SettingAdapter = ApplicationAdapter.extend({ // use the ApplicationAdapter's buildURL method but do not // pass in an id. - return this.ajax(this.buildURL(type.typeKey), 'PUT', {data: data}); + return this.ajax(this.buildURL(type.modelName), 'PUT', {data: data}); } }); diff --git a/core/client/app/controllers/post-settings-menu.js b/core/client/app/controllers/post-settings-menu.js index b95ddfb4b6..9891966e6f 100644 --- a/core/client/app/controllers/post-settings-menu.js +++ b/core/client/app/controllers/post-settings-menu.js @@ -70,20 +70,21 @@ export default Ember.Controller.extend(SettingsMenuMixin, { }), /*jshint unused:false */ - publishedAtValue: Ember.computed('model.published_at', function (key, value) { - var pubDate = this.get('model.published_at'); + publishedAtValue: Ember.computed('model.published_at', { + get: function () { + var pubDate = this.get('model.published_at'); - // We're using a fake setter to reset - // the cache for this property - if (arguments.length > 1) { + if (pubDate) { + return formatDate(pubDate); + } + + return formatDate(moment()); + }, + set: function (key, value) { + // We're using a fake setter to reset + // the cache for this property return formatDate(moment()); } - - if (pubDate) { - return formatDate(pubDate); - } - - return formatDate(moment()); }), /*jshint unused:true */ diff --git a/core/client/app/controllers/settings/general.js b/core/client/app/controllers/settings/general.js index b36ff95230..586e64cb9e 100644 --- a/core/client/app/controllers/settings/general.js +++ b/core/client/app/controllers/settings/general.js @@ -14,16 +14,18 @@ export default Ember.Controller.extend({ return this.get('model.cover') || ''; }), - isDatedPermalinks: Ember.computed('model.permalinks', function (key, value) { - // setter - if (arguments.length > 1) { + isDatedPermalinks: Ember.computed('model.permalinks', { + set: function (key, value) { this.set('model.permalinks', value ? '/:year/:month/:day/:slug/' : '/:slug/'); + + var slugForm = this.get('model.permalinks'); + return slugForm !== '/:slug/'; + }, + get: function () { + var slugForm = this.get('model.permalinks'); + + return slugForm !== '/:slug/'; } - - // getter - var slugForm = this.get('model.permalinks'); - - return slugForm !== '/:slug/'; }), themes: Ember.computed(function () { diff --git a/core/client/app/mixins/editor-base-controller.js b/core/client/app/mixins/editor-base-controller.js index 422dad2e27..fe470f5bd6 100644 --- a/core/client/app/mixins/editor-base-controller.js +++ b/core/client/app/mixins/editor-base-controller.js @@ -120,55 +120,56 @@ export default Ember.Mixin.create({ // an ugly hack, but necessary to watch all the model's properties // and more, without having to be explicit and do it manually - isDirty: Ember.computed.apply(Ember, watchedProps.concat(function (key, value) { - if (arguments.length > 1) { - return value; - } + isDirty: Ember.computed.apply(Ember, watchedProps.concat({ + get: function () { + var model = this.get('model'), + markdown = model.get('markdown'), + title = model.get('title'), + titleScratch = model.get('titleScratch'), + scratch = this.get('editor').getValue(), + changedAttributes; - var model = this.get('model'), - markdown = model.get('markdown'), - title = model.get('title'), - titleScratch = model.get('titleScratch'), - scratch = this.get('editor').getValue(), - changedAttributes; - - if (!this.tagNamesEqual()) { - return true; - } - - if (titleScratch !== title) { - return true; - } - - // since `scratch` is not model property, we need to check - // it explicitly against the model's markdown attribute - if (markdown !== scratch) { - return true; - } - - // if the Adapter failed to save the model isError will be true - // and we should consider the model still dirty. - if (model.get('isError')) { - return true; - } - - // models created on the client always return `isDirty: true`, - // so we need to see which properties have actually changed. - if (model.get('isNew')) { - changedAttributes = Ember.keys(model.changedAttributes()); - - if (changedAttributes.length) { + if (!this.tagNamesEqual()) { return true; } - return false; - } + if (titleScratch !== title) { + return true; + } - // even though we use the `scratch` prop to show edits, - // which does *not* change the model's `isDirty` property, - // `isDirty` will tell us if the other props have changed, - // as long as the model is not new (model.isNew === false). - return model.get('isDirty'); + // since `scratch` is not model property, we need to check + // it explicitly against the model's markdown attribute + if (markdown !== scratch) { + return true; + } + + // if the Adapter failed to save the model isError will be true + // and we should consider the model still dirty. + if (model.get('isError')) { + return true; + } + + // models created on the client always return `isDirty: true`, + // so we need to see which properties have actually changed. + if (model.get('isNew')) { + changedAttributes = Ember.keys(model.changedAttributes()); + + if (changedAttributes.length) { + return true; + } + + return false; + } + + // even though we use the `scratch` prop to show edits, + // which does *not* change the model's `isDirty` property, + // `isDirty` will tell us if the other props have changed, + // as long as the model is not new (model.isNew === false). + return model.get('isDirty'); + }, + set: function (key, value) { + return value; + } })), // used on window.onbeforeunload diff --git a/core/client/app/mixins/settings-menu-controller.js b/core/client/app/mixins/settings-menu-controller.js index 6a0509a0db..a213418c61 100644 --- a/core/client/app/mixins/settings-menu-controller.js +++ b/core/client/app/mixins/settings-menu-controller.js @@ -3,16 +3,17 @@ import Ember from 'ember'; export default Ember.Mixin.create({ application: Ember.inject.controller(), - isViewingSubview: Ember.computed('application.showSettingsMenu', function (key, value) { - // Not viewing a subview if we can't even see the PSM - if (!this.get('application.showSettingsMenu')) { + isViewingSubview: Ember.computed('application.showSettingsMenu', { + get: function () { return false; - } - if (arguments.length > 1) { + }, + set: function (key, value) { + // Not viewing a subview if we can't even see the PSM + if (!this.get('application.showSettingsMenu')) { + return false; + } return value; } - - return false; }), actions: { diff --git a/core/client/app/models/user.js b/core/client/app/models/user.js index 7243c43bc9..f2f5cac99b 100644 --- a/core/client/app/models/user.js +++ b/core/client/app/models/user.js @@ -29,16 +29,17 @@ export default DS.Model.extend(ValidationEngine, { ghostPaths: Ember.inject.service('ghost-paths'), - role: Ember.computed('roles', function (name, value) { - if (arguments.length > 1) { + role: Ember.computed('roles', { + get: function () { + return this.get('roles.firstObject'); + }, + set: function (key, value) { // Only one role per user, so remove any old data. this.get('roles').clear(); this.get('roles').pushObject(value); return value; } - - return this.get('roles.firstObject'); }), // TODO: Once client-side permissions are in place, diff --git a/core/client/app/serializers/application.js b/core/client/app/serializers/application.js index 0148f258a4..a6ef198ae7 100644 --- a/core/client/app/serializers/application.js +++ b/core/client/app/serializers/application.js @@ -7,7 +7,7 @@ var ApplicationSerializer = DS.RESTSerializer.extend({ options.includeId = true; // We have a plural root in the API - var root = Ember.String.pluralize(type.typeKey), + var root = Ember.String.pluralize(type.modelName), data = this.serialize(record, options); // Don't ever pass uuid's diff --git a/core/client/app/serializers/post.js b/core/client/app/serializers/post.js index 13db58363a..23a2a58b76 100644 --- a/core/client/app/serializers/post.js +++ b/core/client/app/serializers/post.js @@ -18,8 +18,8 @@ var PostSerializer = ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, { }, extractSingle: function (store, primaryType, payload) { - var root = this.keyForAttribute(primaryType.typeKey), - pluralizedRoot = Ember.String.pluralize(primaryType.typeKey); + var root = this.keyForAttribute(primaryType.modelName), + pluralizedRoot = Ember.String.pluralize(primaryType.modelName); // make payload { post: { title: '', tags: [obj, obj], etc. } }. // this allows ember-data to pull the embedded tags out again, @@ -37,7 +37,7 @@ var PostSerializer = ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, { options.includeId = true; // We have a plural root in the API - var root = Ember.String.pluralize(type.typeKey), + var root = Ember.String.pluralize(type.modelName), data = this.serialize(record, options); // Properties that exist on the model but we don't want sent in the payload diff --git a/core/client/app/serializers/setting.js b/core/client/app/serializers/setting.js index 943793b105..8acd6e1e03 100644 --- a/core/client/app/serializers/setting.js +++ b/core/client/app/serializers/setting.js @@ -7,7 +7,7 @@ var SettingSerializer = ApplicationSerializer.extend({ options = options || {}; options.includeId = false; - var root = Ember.String.pluralize(type.typeKey), + var root = Ember.String.pluralize(type.modelName), data = this.serialize(record, options), payload = []; diff --git a/core/client/app/serializers/tag.js b/core/client/app/serializers/tag.js index 99e6b243d8..3408d994fc 100644 --- a/core/client/app/serializers/tag.js +++ b/core/client/app/serializers/tag.js @@ -6,7 +6,7 @@ var TagSerializer = ApplicationSerializer.extend({ options = options || {}; options.includeId = true; - var root = Ember.String.pluralize(type.typeKey), + var root = Ember.String.pluralize(type.modelName), data = this.serialize(record, options); // Properties that exist on the model but we don't want sent in the payload diff --git a/core/client/app/serializers/user.js b/core/client/app/serializers/user.js index eecf52943e..0cdbfc742e 100644 --- a/core/client/app/serializers/user.js +++ b/core/client/app/serializers/user.js @@ -8,8 +8,8 @@ var UserSerializer = ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, { }, extractSingle: function (store, primaryType, payload) { - var root = this.keyForAttribute(primaryType.typeKey), - pluralizedRoot = Ember.String.pluralize(primaryType.typeKey); + var root = this.keyForAttribute(primaryType.modelName), + pluralizedRoot = Ember.String.pluralize(primaryType.modelName); payload[root] = payload[pluralizedRoot][0]; delete payload[pluralizedRoot]; diff --git a/core/client/app/templates/-import-errors.hbs b/core/client/app/templates/-import-errors.hbs index b7364efaff..abc767e207 100644 --- a/core/client/app/templates/-import-errors.hbs +++ b/core/client/app/templates/-import-errors.hbs @@ -1,6 +1,6 @@ {{#if importErrors}} -{{#each error in importErrors}} +{{#each importErrors as |error|}} {{/each}}
{{error.message}}
diff --git a/core/client/app/templates/components/gh-alert.hbs b/core/client/app/templates/components/gh-alert.hbs index c370b231e6..299f731c00 100644 --- a/core/client/app/templates/components/gh-alert.hbs +++ b/core/client/app/templates/components/gh-alert.hbs @@ -1,4 +1,4 @@
{{message.message}}
- \ No newline at end of file + \ No newline at end of file diff --git a/core/client/app/templates/components/gh-alerts.hbs b/core/client/app/templates/components/gh-alerts.hbs index 895ae7979b..e7920538a3 100644 --- a/core/client/app/templates/components/gh-alerts.hbs +++ b/core/client/app/templates/components/gh-alerts.hbs @@ -1,3 +1,3 @@ -{{#each message in messages}} +{{#each messages as |message|}} {{gh-alert message=message}} {{/each}} \ No newline at end of file diff --git a/core/client/app/templates/components/gh-notifications.hbs b/core/client/app/templates/components/gh-notifications.hbs index 5ff9838c42..4d4a955bc6 100644 --- a/core/client/app/templates/components/gh-notifications.hbs +++ b/core/client/app/templates/components/gh-notifications.hbs @@ -1,3 +1,3 @@ -{{#each message in messages}} +{{#each messages as |message|}} {{gh-notification message=message}} {{/each}} diff --git a/core/client/app/templates/components/gh-role-selector.hbs b/core/client/app/templates/components/gh-role-selector.hbs index 6b093f056e..9f534be421 100644 --- a/core/client/app/templates/components/gh-role-selector.hbs +++ b/core/client/app/templates/components/gh-role-selector.hbs @@ -1,5 +1,5 @@ diff --git a/core/client/app/templates/error.hbs b/core/client/app/templates/error.hbs index e268a38108..6e6f4ac804 100644 --- a/core/client/app/templates/error.hbs +++ b/core/client/app/templates/error.hbs @@ -16,7 +16,7 @@

Stack Trace

{{message}}