diff --git a/core/client/app/controllers/setup.js b/core/client/app/controllers/setup.js index 84e4e891ec..ebd05ef2ff 100644 --- a/core/client/app/controllers/setup.js +++ b/core/client/app/controllers/setup.js @@ -1,54 +1,15 @@ import Ember from 'ember'; -import {request as ajax} from 'ic-ajax'; -import ValidationEngine from 'ghost/mixins/validation-engine'; - -export default Ember.Controller.extend(ValidationEngine, { - blogTitle: null, - name: null, - email: null, - password: null, - submitting: false, - - // ValidationEngine settings - validationType: 'setup', +export default Ember.Controller.extend({ + appController: Ember.inject.controller('application'), ghostPaths: Ember.inject.service('ghost-paths'), - notifications: Ember.inject.service(), - actions: { - setup: function () { - var self = this, - data = self.getProperties('blogTitle', 'name', 'email', 'password'), - notifications = this.get('notifications'); + showBackLink: Ember.computed.match('appController.currentRouteName', /^setup\.(two|three)$/), - notifications.closePassive(); + backRoute: Ember.computed('appController.currentRouteName', function () { + var appController = this.get('appController'), + currentRoute = Ember.get(appController, 'currentRouteName'); - this.toggleProperty('submitting'); - this.validate({format: false}).then(function () { - ajax({ - url: self.get('ghostPaths.url').api('authentication', 'setup'), - type: 'POST', - data: { - setup: [{ - name: data.name, - email: data.email, - password: data.password, - blogTitle: data.blogTitle - }] - } - }).then(function () { - self.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', { - identification: self.get('email'), - password: self.get('password') - }); - }).catch(function (resp) { - self.toggleProperty('submitting'); - notifications.showAPIError(resp); - }); - }).catch(function (errors) { - self.toggleProperty('submitting'); - notifications.showErrors(errors); - }); - } - } + return currentRoute === 'setup.two' ? 'setup.one' : 'setup.two'; + }) }); diff --git a/core/client/app/controllers/setup/three.js b/core/client/app/controllers/setup/three.js index e05006227e..29dd0df2a2 100644 --- a/core/client/app/controllers/setup/three.js +++ b/core/client/app/controllers/setup/three.js @@ -1,6 +1,6 @@ import Ember from 'ember'; -var SetupThreeController = Ember.Controller.extend({ +export default Ember.Controller.extend({ notifications: Ember.inject.service(), users: '', usersArray: Ember.computed('users', function () { @@ -133,4 +133,3 @@ var SetupThreeController = Ember.Controller.extend({ } }); -export default SetupThreeController; diff --git a/core/client/app/controllers/setup/two.js b/core/client/app/controllers/setup/two.js index 251d873470..400e4c0efb 100644 --- a/core/client/app/controllers/setup/two.js +++ b/core/client/app/controllers/setup/two.js @@ -9,7 +9,6 @@ export default Ember.Controller.extend(ValidationEngine, { email: '', password: null, image: null, - submitting: false, blogCreated: false, ghostPaths: Ember.inject.service('ghost-paths'), @@ -52,9 +51,8 @@ export default Ember.Controller.extend(ValidationEngine, { data = self.getProperties('blogTitle', 'name', 'email', 'password', 'image'), notifications = this.get('notifications'), config = this.get('config'), - method = (this.get('blogCreated')) ? 'PUT' : 'POST'; + method = this.get('blogCreated') ? 'PUT' : 'POST'; - this.toggleProperty('submitting'); this.validate().then(function () { self.set('showError', false); ajax({ @@ -72,14 +70,12 @@ export default Ember.Controller.extend(ValidationEngine, { config.set('blogTitle', data.blogTitle); // Don't call the success handler, otherwise we will be redirected to admin self.get('application').set('skipAuthSuccessHandler', true); - self.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', { identification: self.get('email'), password: self.get('password') }).then(function () { self.set('password', ''); self.set('blogCreated', true); - if (data.image) { self.sendImage(result.users[0]) .then(function () { @@ -92,11 +88,9 @@ export default Ember.Controller.extend(ValidationEngine, { } }); }).catch(function (resp) { - self.toggleProperty('submitting'); notifications.showAPIError(resp); }); }).catch(function () { - self.toggleProperty('submitting'); self.set('showError', true); }); }, diff --git a/core/client/app/routes/setup/three.js b/core/client/app/routes/setup/three.js new file mode 100644 index 0000000000..aa59dc20c3 --- /dev/null +++ b/core/client/app/routes/setup/three.js @@ -0,0 +1,9 @@ +import Ember from 'ember'; + +export default Ember.Route.extend({ + beforeModel: function () { + if (!this.controllerFor('setup.two').get('blogCreated')) { + this.transitionTo('setup.two'); + } + } +}); diff --git a/core/client/app/templates/setup.hbs b/core/client/app/templates/setup.hbs index f86f04cb95..a0153448ee 100644 --- a/core/client/app/templates/setup.hbs +++ b/core/client/app/templates/setup.hbs @@ -1,8 +1,9 @@
-
- {{outlet}} +
+ {{outlet}} +
diff --git a/core/client/app/templates/setup/one.hbs b/core/client/app/templates/setup/one.hbs index b519e58b9f..5e54df43d3 100644 --- a/core/client/app/templates/setup/one.hbs +++ b/core/client/app/templates/setup/one.hbs @@ -1,14 +1,12 @@ -
-
-

Welcome to Ghost!

-

So far there have been {{model.count}} Ghost blogs made by people all over the world. Today we’re making yours.

-
+
+

Welcome to Ghost!

+

So far there have been {{model.count}} Ghost blogs made by people all over the world. Today we’re making yours.

+
-
- Ghost screenshot -
+
+ Ghost screenshot +
- {{#link-to "setup.two" classNames="btn btn-green btn-lg"}} - Create your account - {{/link-to}} -
+{{#link-to "setup.two" classNames="btn btn-green btn-lg"}} + Create your account +{{/link-to}} diff --git a/core/client/app/templates/setup/three.hbs b/core/client/app/templates/setup/three.hbs index 49af9a8b0c..9b57f21eae 100644 --- a/core/client/app/templates/setup/three.hbs +++ b/core/client/app/templates/setup/three.hbs @@ -1,20 +1,18 @@ -
-
-

Invite your team

-

Ghost works best when shared with others. Collaborate, get feedback on your posts & work together on ideas.

-
+
+

Invite your team

+

Ghost works best when shared with others. Collaborate, get feedback on your posts & work together on ideas.

+
- + -
- - {{textarea class="gh-input" name="users" value=users required="required"}} -
+
+ + {{textarea class="gh-input" name="users" value=users required="required"}} +
- - {{#link-to "posts" class="gh-flow-skip"}} - I'll do this later, take me to my blog! - {{/link-to}} -
+ +{{#link-to "posts" class="gh-flow-skip"}} + I'll do this later, take me to my blog! +{{/link-to}} diff --git a/core/client/app/templates/setup/two.hbs b/core/client/app/templates/setup/two.hbs index 5a647e94c7..dfc262d538 100644 --- a/core/client/app/templates/setup/two.hbs +++ b/core/client/app/templates/setup/two.hbs @@ -1,12 +1,11 @@ -
-
-

Create your account

-
+
+

Create your account

+
-
- {{!-- Horrible hack to prevent Chrome from incorrectly auto-filling inputs --}} - - + + {{!-- Horrible hack to prevent Chrome from incorrectly auto-filling inputs --}} + + {{gh-profile-image fileStorage=config.fileStorage email=email setImage="setImage"}} {{#gh-form-group errors=errors property="email"}} @@ -46,8 +45,5 @@ {{/gh-form-group}}
- - {{#if showError}} -

{{invalidMessage}}

- {{/if}} -
+ +

{{#if showError}}{{invalidMessage}}{{/if}}