diff --git a/core/client/.jshintrc b/core/client/.jshintrc index 04a423ad61..50539148fd 100644 --- a/core/client/.jshintrc +++ b/core/client/.jshintrc @@ -6,7 +6,6 @@ "-Notification", "$", "validator", - "ic", "moment" ], "browser": true, diff --git a/core/client/Brocfile.js b/core/client/Brocfile.js index 573e423e56..5a12b3e5cd 100644 --- a/core/client/Brocfile.js +++ b/core/client/Brocfile.js @@ -36,7 +36,6 @@ app = new EmberApp({ // 'dem Scripts app.import('bower_components/loader.js/loader.js'); app.import('bower_components/jquery/dist/jquery.js'); -app.import('bower_components/ic-ajax/dist/globals/main.js'); app.import('bower_components/ember-load-initializers/ember-load-initializers.js'); app.import('bower_components/validator-js/validator.js'); app.import('bower_components/rangyinputs/rangyinputs-jquery-src.js'); diff --git a/core/client/app/controllers/modals/delete-all.js b/core/client/app/controllers/modals/delete-all.js index 4d83e235e9..b7f7307386 100644 --- a/core/client/app/controllers/modals/delete-all.js +++ b/core/client/app/controllers/modals/delete-all.js @@ -1,10 +1,12 @@ import Ember from 'ember'; -var DeleteAllController = Ember.Controller.extend({ +import {request as ajax} from 'ic-ajax'; + +export default Ember.Controller.extend({ actions: { confirmAccept: function () { var self = this; - ic.ajax.request(this.get('ghostPaths.url').api('db'), { + ajax(this.get('ghostPaths.url').api('db'), { type: 'DELETE' }).then(function () { self.notifications.showSuccess('All content deleted from database.'); @@ -31,5 +33,3 @@ var DeleteAllController = Ember.Controller.extend({ } } }); - -export default DeleteAllController; diff --git a/core/client/app/controllers/modals/transfer-owner.js b/core/client/app/controllers/modals/transfer-owner.js index afd416e3b9..30075c91b2 100644 --- a/core/client/app/controllers/modals/transfer-owner.js +++ b/core/client/app/controllers/modals/transfer-owner.js @@ -1,5 +1,7 @@ import Ember from 'ember'; -var TransferOwnerController = Ember.Controller.extend({ +import {request as ajax} from 'ic-ajax'; + +export default Ember.Controller.extend({ actions: { confirmAccept: function () { var user = this.get('model'), @@ -8,7 +10,7 @@ var TransferOwnerController = Ember.Controller.extend({ self.get('dropdown').closeDropdowns(); - ic.ajax.request(url, { + ajax(url, { type: 'PUT', data: { owner: [{ @@ -49,5 +51,3 @@ var TransferOwnerController = Ember.Controller.extend({ } } }); - -export default TransferOwnerController; diff --git a/core/client/app/controllers/reset.js b/core/client/app/controllers/reset.js index b500d083eb..ca3ebfe555 100644 --- a/core/client/app/controllers/reset.js +++ b/core/client/app/controllers/reset.js @@ -1,60 +1,58 @@ import Ember from 'ember'; -import ajax from 'ghost/utils/ajax'; -import ValidationEngine from 'ghost/mixins/validation-engine'; - -var ResetController = Ember.Controller.extend(ValidationEngine, { - newPassword: '', - ne2Password: '', - token: '', - submitting: false, - - validationType: 'reset', - - email: Ember.computed('token', function () { - // The token base64 encodes the email (and some other stuff), - // each section is divided by a '|'. Email comes second. - return atob(this.get('token')).split('|')[1]; - }), - - // Used to clear sensitive information - clearData: function () { - this.setProperties({ - newPassword: '', - ne2Password: '', - token: '' - }); - }, - - actions: { - submit: function () { - var credentials = this.getProperties('newPassword', 'ne2Password', 'token'), - self = this; - - this.toggleProperty('submitting'); - this.validate({format: false}).then(function () { - ajax({ - url: self.get('ghostPaths.url').api('authentication', 'passwordreset'), - type: 'PUT', - data: { - passwordreset: [credentials] - } - }).then(function (resp) { - self.toggleProperty('submitting'); - self.notifications.showSuccess(resp.passwordreset[0].message, true); - self.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', { - identification: self.get('email'), - password: credentials.newPassword - }); - }).catch(function (response) { - self.notifications.showAPIError(response); - self.toggleProperty('submitting'); - }); - }).catch(function (error) { - self.toggleProperty('submitting'); - self.notifications.showErrors(error); - }); - } - } -}); - -export default ResetController; +import {request as ajax} from 'ic-ajax'; +import ValidationEngine from 'ghost/mixins/validation-engine'; + +export default Ember.Controller.extend(ValidationEngine, { + newPassword: '', + ne2Password: '', + token: '', + submitting: false, + + validationType: 'reset', + + email: Ember.computed('token', function () { + // The token base64 encodes the email (and some other stuff), + // each section is divided by a '|'. Email comes second. + return atob(this.get('token')).split('|')[1]; + }), + + // Used to clear sensitive information + clearData: function () { + this.setProperties({ + newPassword: '', + ne2Password: '', + token: '' + }); + }, + + actions: { + submit: function () { + var credentials = this.getProperties('newPassword', 'ne2Password', 'token'), + self = this; + + this.toggleProperty('submitting'); + this.validate({format: false}).then(function () { + ajax({ + url: self.get('ghostPaths.url').api('authentication', 'passwordreset'), + type: 'PUT', + data: { + passwordreset: [credentials] + } + }).then(function (resp) { + self.toggleProperty('submitting'); + self.notifications.showSuccess(resp.passwordreset[0].message, true); + self.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', { + identification: self.get('email'), + password: credentials.newPassword + }); + }).catch(function (response) { + self.notifications.showAPIError(response); + self.toggleProperty('submitting'); + }); + }).catch(function (error) { + self.toggleProperty('submitting'); + self.notifications.showErrors(error); + }); + } + } +}); diff --git a/core/client/app/controllers/settings/labs.js b/core/client/app/controllers/settings/labs.js index a8a3e4f4ce..826cd5cd3b 100644 --- a/core/client/app/controllers/settings/labs.js +++ b/core/client/app/controllers/settings/labs.js @@ -1,5 +1,7 @@ import Ember from 'ember'; -var LabsController = Ember.Controller.extend(Ember.Evented, { +import {request as ajax} from 'ic-ajax'; + +export default Ember.Controller.extend(Ember.Evented, { needs: ['feature'], uploadButtonText: 'Import', @@ -34,7 +36,7 @@ var LabsController = Ember.Controller.extend(Ember.Evented, { formData.append('importfile', file); - ic.ajax.request(this.get('ghostPaths.url').api('db'), { + ajax(this.get('ghostPaths.url').api('db'), { type: 'POST', data: formData, dataType: 'json', @@ -77,7 +79,7 @@ var LabsController = Ember.Controller.extend(Ember.Evented, { sendTestEmail: function () { var self = this; - ic.ajax.request(this.get('ghostPaths.url').api('mail', 'test'), { + ajax(this.get('ghostPaths.url').api('mail', 'test'), { type: 'POST' }).then(function () { self.notifications.showSuccess('Check your email for the test message.'); @@ -91,5 +93,3 @@ var LabsController = Ember.Controller.extend(Ember.Evented, { } } }); - -export default LabsController; diff --git a/core/client/app/controllers/setup.js b/core/client/app/controllers/setup.js index 2d2ae3526b..e4827ae183 100644 --- a/core/client/app/controllers/setup.js +++ b/core/client/app/controllers/setup.js @@ -1,8 +1,8 @@ import Ember from 'ember'; -import ajax from 'ghost/utils/ajax'; +import {request as ajax} from 'ic-ajax'; import ValidationEngine from 'ghost/mixins/validation-engine'; -var SetupController = Ember.Controller.extend(ValidationEngine, { +export default Ember.Controller.extend(ValidationEngine, { blogTitle: null, name: null, email: null, @@ -48,5 +48,3 @@ var SetupController = Ember.Controller.extend(ValidationEngine, { } } }); - -export default SetupController; diff --git a/core/client/app/controllers/signin.js b/core/client/app/controllers/signin.js index c7aa1286ad..ae6774c9dc 100644 --- a/core/client/app/controllers/signin.js +++ b/core/client/app/controllers/signin.js @@ -1,8 +1,8 @@ import Ember from 'ember'; import ValidationEngine from 'ghost/mixins/validation-engine'; -import ajax from 'ghost/utils/ajax'; +import {request as ajax} from 'ic-ajax'; -var SigninController = Ember.Controller.extend(ValidationEngine, { +export default Ember.Controller.extend(ValidationEngine, { validationType: 'signin', submitting: false, @@ -63,5 +63,3 @@ var SigninController = Ember.Controller.extend(ValidationEngine, { } } }); - -export default SigninController; diff --git a/core/client/app/controllers/signup.js b/core/client/app/controllers/signup.js index 70b6d8f6c2..4d98d17017 100644 --- a/core/client/app/controllers/signup.js +++ b/core/client/app/controllers/signup.js @@ -1,8 +1,8 @@ import Ember from 'ember'; -import ajax from 'ghost/utils/ajax'; +import {request as ajax} from 'ic-ajax'; import ValidationEngine from 'ghost/mixins/validation-engine'; -var SignupController = Ember.Controller.extend(ValidationEngine, { +export default Ember.Controller.extend(ValidationEngine, { submitting: false, // ValidationEngine settings @@ -46,5 +46,3 @@ var SignupController = Ember.Controller.extend(ValidationEngine, { } } }); - -export default SignupController; diff --git a/core/client/app/mixins/pagination-controller.js b/core/client/app/mixins/pagination-controller.js index ca914e529a..5f68111aa7 100644 --- a/core/client/app/mixins/pagination-controller.js +++ b/core/client/app/mixins/pagination-controller.js @@ -1,7 +1,7 @@ import Ember from 'ember'; -import { getRequestErrorMessage } from 'ghost/utils/ajax'; +import getRequestErrorMessage from 'ghost/utils/ajax'; -var PaginationControllerMixin = Ember.Mixin.create({ +export default Ember.Mixin.create({ // set from PaginationRouteMixin paginationSettings: null, @@ -57,5 +57,3 @@ var PaginationControllerMixin = Ember.Mixin.create({ } } }); - -export default PaginationControllerMixin; diff --git a/core/client/app/mixins/validation-engine.js b/core/client/app/mixins/validation-engine.js index 37cd548471..073432185e 100644 --- a/core/client/app/mixins/validation-engine.js +++ b/core/client/app/mixins/validation-engine.js @@ -1,6 +1,6 @@ import Ember from 'ember'; import DS from 'ember-data'; -import {getRequestErrorMessage} from 'ghost/utils/ajax'; +import getRequestErrorMessage from 'ghost/utils/ajax'; import ValidatorExtensions from 'ghost/utils/validator-extensions'; import PostValidator from 'ghost/validators/post'; @@ -61,7 +61,7 @@ function formatErrors(errors, opts) { * It will be able to validate any properties on itself (or the model it passes to validate()) * with the use of a declared validator. */ -var ValidationEngine = Ember.Mixin.create({ +export default Ember.Mixin.create({ // these validators can be passed a model to validate when the class that // mixes in the ValidationEngine declares a validationType equal to a key on this object. // the model is either passed in via `this.validate({ model: object })` @@ -174,5 +174,3 @@ var ValidationEngine = Ember.Mixin.create({ }); } }); - -export default ValidationEngine; diff --git a/core/client/app/models/slug-generator.js b/core/client/app/models/slug-generator.js index fcd69f4410..2252421986 100644 --- a/core/client/app/models/slug-generator.js +++ b/core/client/app/models/slug-generator.js @@ -1,11 +1,15 @@ import Ember from 'ember'; -var SlugGenerator = Ember.Object.extend({ +import {request as ajax} from 'ic-ajax'; + +export default Ember.Object.extend({ ghostPaths: null, slugType: null, value: null, + toString: function () { return this.get('value'); }, + generateSlug: function (textToSlugify) { var self = this, url; @@ -16,14 +20,14 @@ var SlugGenerator = Ember.Object.extend({ url = this.get('ghostPaths.url').api('slugs', this.get('slugType'), encodeURIComponent(textToSlugify)); - return ic.ajax.request(url, { + return ajax(url, { type: 'GET' }).then(function (response) { var slug = response.slugs[0].slug; + self.set('value', slug); + return slug; }); } }); - -export default SlugGenerator; diff --git a/core/client/app/models/user.js b/core/client/app/models/user.js index bfffe029b7..7536942c49 100644 --- a/core/client/app/models/user.js +++ b/core/client/app/models/user.js @@ -1,9 +1,10 @@ import Ember from 'ember'; import DS from 'ember-data'; +import {request as ajax} from 'ic-ajax'; import ValidationEngine from 'ghost/mixins/validation-engine'; import SelectiveSaveMixin from 'ghost/mixins/selective-save'; -var User = DS.Model.extend(SelectiveSaveMixin, ValidationEngine, { +export default DS.Model.extend(SelectiveSaveMixin, ValidationEngine, { validationType: 'user', uuid: DS.attr('string'), @@ -49,7 +50,7 @@ var User = DS.Model.extend(SelectiveSaveMixin, ValidationEngine, { saveNewPassword: function () { var url = this.get('ghostPaths.url').api('users', 'password'); - return ic.ajax.request(url, { + return ajax(url, { type: 'PUT', data: { password: [{ @@ -69,7 +70,7 @@ var User = DS.Model.extend(SelectiveSaveMixin, ValidationEngine, { roles: fullUserData.roles }; - return ic.ajax.request(this.get('ghostPaths.url').api('users'), { + return ajax(this.get('ghostPaths.url').api('users'), { type: 'POST', data: JSON.stringify({users: [userData]}), contentType: 'application/json' @@ -102,5 +103,3 @@ var User = DS.Model.extend(SelectiveSaveMixin, ValidationEngine, { pending: Ember.computed.equal('status', 'invited-pending').property('status') }); - -export default User; diff --git a/core/client/app/routes/about.js b/core/client/app/routes/about.js index 6d58327953..11a0a74835 100644 --- a/core/client/app/routes/about.js +++ b/core/client/app/routes/about.js @@ -1,3 +1,4 @@ +import {request as ajax} from 'ic-ajax'; import AuthenticatedRoute from 'ghost/routes/authenticated'; import styleBody from 'ghost/mixins/style-body'; @@ -16,7 +17,7 @@ export default AuthenticatedRoute.extend(styleBody, { return cachedConfig; } - return ic.ajax.request(this.get('ghostPaths.url').api('configuration')) + return ajax(this.get('ghostPaths.url').api('configuration')) .then(function (configurationResponse) { var configKeyValues = configurationResponse.configuration; diff --git a/core/client/app/routes/setup.js b/core/client/app/routes/setup.js index b312590b93..d6a1fc19d7 100644 --- a/core/client/app/routes/setup.js +++ b/core/client/app/routes/setup.js @@ -1,8 +1,9 @@ import Ember from 'ember'; +import {request as ajax} from 'ic-ajax'; import Configuration from 'simple-auth/configuration'; import styleBody from 'ghost/mixins/style-body'; -var SetupRoute = Ember.Route.extend(styleBody, { +export default Ember.Route.extend(styleBody, { titleToken: 'Setup', classNames: ['ghost-setup'], @@ -20,7 +21,7 @@ var SetupRoute = Ember.Route.extend(styleBody, { } // If user is not logged in, check the state of the setup process via the API - return ic.ajax.request(this.get('ghostPaths.url').api('authentication/setup'), { + return ajax(this.get('ghostPaths.url').api('authentication/setup'), { type: 'GET' }).then(function (result) { var setup = result.setup[0].status; @@ -31,5 +32,3 @@ var SetupRoute = Ember.Route.extend(styleBody, { }); } }); - -export default SetupRoute; diff --git a/core/client/app/routes/signup.js b/core/client/app/routes/signup.js index 160d1643f2..bcf27656fb 100644 --- a/core/client/app/routes/signup.js +++ b/core/client/app/routes/signup.js @@ -1,8 +1,9 @@ import Ember from 'ember'; +import {request as ajax} from 'ic-ajax'; import Configuration from 'simple-auth/configuration'; import styleBody from 'ghost/mixins/style-body'; -var SignupRoute = Ember.Route.extend(styleBody, { +export default Ember.Route.extend(styleBody, { classNames: ['ghost-signup'], beforeModel: function () { @@ -32,7 +33,7 @@ var SignupRoute = Ember.Route.extend(styleBody, { model.set('email', email); model.set('token', params.token); - return ic.ajax.request({ + return ajax({ url: self.get('ghostPaths.url').api('authentication', 'invitation'), type: 'GET', dataType: 'json', @@ -60,5 +61,3 @@ var SignupRoute = Ember.Route.extend(styleBody, { this.controllerFor('signup').setProperties({email: '', password: '', token: ''}); } }); - -export default SignupRoute; diff --git a/core/client/app/utils/ajax.js b/core/client/app/utils/ajax.js index e194355ec2..d2218b8d93 100644 --- a/core/client/app/utils/ajax.js +++ b/core/client/app/utils/ajax.js @@ -1,13 +1,8 @@ import Ember from 'ember'; -/* global ic */ - -var ajax = function () { - return ic.ajax.request.apply(null, arguments); -}; // Used in API request fail handlers to parse a standard api error // response json for the message to display -function getRequestErrorMessage(request, performConcat) { +export default function getRequestErrorMessage(request, performConcat) { var message, msgDetail; @@ -47,6 +42,3 @@ function getRequestErrorMessage(request, performConcat) { return message; } - -export {getRequestErrorMessage, ajax}; -export default ajax; diff --git a/core/client/bower.json b/core/client/bower.json index f6ead37197..0e6e7ffcfa 100644 --- a/core/client/bower.json +++ b/core/client/bower.json @@ -10,7 +10,6 @@ "ember-simple-auth": "0.8.0-beta.2", "fastclick": "1.0.6", "google-caja": "5669.0.0", - "ic-ajax": "2.0.2", "jquery": "1.11.2", "jquery-file-upload": "9.5.6", "jquery-hammerjs": "1.0.1",