-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass at user onboarding screens
refs #5315 - split setup into 3 screens - add gravatar fetching - add download counter - add button handling for invite users
- Loading branch information
Showing
24 changed files
with
352 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Ember from 'ember'; | ||
import ajax from 'ghost/utils/ajax'; | ||
|
||
var SetupOneController = Ember.Controller.extend({ | ||
|
||
count: 'many, many', | ||
|
||
downloadCounter: function () { | ||
var self = this, | ||
interval = 3000; | ||
|
||
Ember.run.later(this, function () { | ||
ajax({ | ||
url: self.get('ghostPaths.count'), | ||
type: 'GET' | ||
}).then(function (data) { | ||
self.set('count', data.count.toLocaleString()); | ||
}).catch(function () { | ||
self.set('count', 'many, many'); | ||
}); | ||
|
||
this.downloadCounter(); | ||
}, interval); | ||
}.on('init') | ||
}); | ||
|
||
export default SetupOneController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import Ember from 'ember'; | ||
import ValidationEngine from 'ghost/mixins/validation-engine'; | ||
|
||
var SetupThreeController = Ember.Controller.extend(ValidationEngine, { | ||
users: '', | ||
usersArray: Ember.computed('users', function () { | ||
return this.get('users').split('\n').filter(function (user) { | ||
return validator.isEmail(user); | ||
}); | ||
}), | ||
numUsers: Ember.computed('usersArray', function () { | ||
return this.get('usersArray').length; | ||
}), | ||
buttonText: Ember.computed('numUsers', function () { | ||
var user = this.get('numUsers') === 1 ? 'user' : 'users'; | ||
return this.get('numUsers') > 0 ? | ||
'Invite ' + this.get('numUsers') + ' ' + user : 'I\'ll do this later, take me to my blog!'; | ||
}), | ||
buttonClass: Ember.computed('numUsers', function () { | ||
return this.get('numUsers') > 0 ? 'btn-green' : 'btn-minor'; | ||
}), | ||
actions: { | ||
invite: function () { | ||
console.log('inviting', this.get('usersArray')); | ||
|
||
if (this.get('numUsers') === 0) { | ||
this.sendAction('signin'); | ||
} | ||
|
||
// TODO: do invites | ||
}, | ||
signin: function () { | ||
var self = this; | ||
|
||
this.get('session').authenticate('simple-auth-authenticator:oauth2-password-grant', { | ||
identification: self.get('email'), | ||
password: self.get('password') | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
export default SetupThreeController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* global md5 */ | ||
import Ember from 'ember'; | ||
import ajax from 'ghost/utils/ajax'; | ||
import ValidationEngine from 'ghost/mixins/validation-engine'; | ||
|
||
var SetupTwoController = Ember.Controller.extend(ValidationEngine, { | ||
size: 90, | ||
blogTitle: null, | ||
name: null, | ||
email: '', | ||
password: null, | ||
image: null, | ||
submitting: false, | ||
|
||
gravatarUrl: Ember.computed('email', function () { | ||
var email = this.get('email'), | ||
size = this.get('size'); | ||
|
||
return 'http://www.gravatar.com/avatar/' + md5(email) + '?s=' + size + '&d=blank'; | ||
}), | ||
|
||
userImage: Ember.computed('gravatarUrl', function () { | ||
return this.get('image') || this.get('gravatarUrl'); | ||
}), | ||
|
||
userImageBackground: Ember.computed('userImage', function () { | ||
return 'background-image: url(' + this.get('userImage') + ')'; | ||
}), | ||
|
||
// ValidationEngine settings | ||
validationType: 'setup', | ||
|
||
actions: { | ||
setup: function () { | ||
var self = this, | ||
data = self.getProperties('blogTitle', 'name', 'email', 'password'); | ||
|
||
self.notifications.closePassive(); | ||
|
||
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'); | ||
self.notifications.showAPIError(resp); | ||
}); | ||
}).catch(function (errors) { | ||
self.toggleProperty('submitting'); | ||
self.notifications.showErrors(errors); | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
export default SetupTwoController; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Ember from 'ember'; | ||
|
||
var SetupRoute = Ember.Route.extend({ | ||
beforeModel: function () { | ||
this.transitionTo('setup.one'); | ||
} | ||
}); | ||
|
||
export default SetupRoute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Ember from 'ember'; | ||
import ajax from 'ghost/utils/ajax'; | ||
|
||
var SetupOneRoute = Ember.Route.extend({ | ||
titleToken: 'Setup', | ||
beforeModel: function () { | ||
var self = this, | ||
ctrl = this.controllerFor('setup.one'); | ||
|
||
if (!ctrl) { | ||
this.generateController('setup.one'); | ||
ctrl = this.controllerFor('setup.one'); | ||
} | ||
|
||
return ajax({ | ||
url: self.get('ghostPaths.count'), | ||
type: 'GET' | ||
}).then(function (data) { | ||
ctrl.set('count', data.count.toLocaleString()); | ||
}).catch(function () { /* Do nothing */ }); | ||
} | ||
}); | ||
|
||
export default SetupOneRoute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Ember from 'ember'; | ||
|
||
var SetupTwoRoute = Ember.Route.extend({ | ||
titleToken: 'Setup' | ||
}); | ||
|
||
export default SetupTwoRoute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Ember from 'ember'; | ||
|
||
var SetupTwoRoute = Ember.Route.extend({ | ||
titleToken: 'Setup' | ||
}); | ||
|
||
export default SetupTwoRoute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/client/app/templates/components/gh-activating-list-item.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{{#link-to route alternateActive=active}}{{title}}{{yield}}{{/link-to}} | ||
{{#link-to route alternateActive=active classNameBindings="linkClasses"}}{{title}}{{yield}}{{/link-to}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,27 @@ | ||
<section class="setup-box js-setup-box fade-in"> | ||
<div class="vertical"> | ||
<form id="setup" class="setup-form" method="post" novalidate="novalidate"> | ||
<div class="gh-flow"> | ||
|
||
{{!-- Horrible hack to prevent Chrome from incorrectly auto-filling inputs --}} | ||
<input style="display:none;" type="text" name="fakeusernameremembered"/> | ||
<input style="display:none;" type="password" name="fakepasswordremembered"/> | ||
<header class="gh-flow-head"> | ||
<nav class="gh-flow-nav"> | ||
{{!-- TODO: this should only appear on screens 2 & 3 --}} | ||
<a class="gh-flow-back" href="#"><i class="icon-arrow-left"></i> Back</a> | ||
<ol> | ||
{{#gh-activating-list-item route="setup.one" linkClass="step"}} | ||
<i class="icon-check"></i><span class="num">1</span> | ||
{{/gh-activating-list-item}} | ||
<li class="divider"></li> | ||
{{#gh-activating-list-item route="setup.two" linkClass="step"}} | ||
<i class="icon-check"></i><span class="num">2</span> | ||
{{/gh-activating-list-item}} | ||
<li class="divider"></li> | ||
{{#gh-activating-list-item route="setup.three" linkClass="step"}} | ||
<i class="icon-check"></i><span class="num">3</span> | ||
{{/gh-activating-list-item}} | ||
</ol> | ||
</nav> | ||
</header> | ||
|
||
<header> | ||
<h1>Welcome to your new Ghost blog</h1> | ||
<h2>Let's get a few things set up so you can get started.</h2> | ||
</header> | ||
<div class="form-group"> | ||
<label for="blog-title">Blog Title</label> | ||
{{input type="text" name="blog-title" autofocus="autofocus" autocorrect="off" value=blogTitle }} | ||
<p>What would you like to call your blog?</p> | ||
</div> | ||
<div class="form-group"> | ||
<label for="name">Full Name</label> | ||
{{input type="text" name="name" autofocus="autofocus" autocorrect="off" value=name }} | ||
<p>The name that you will sign your posts with</p> | ||
</div> | ||
<div class="form-group"> | ||
<label for="email">Email Address</label> | ||
{{input type="email" name="email" autofocus="autofocus" autocorrect="off" value=email }} | ||
<p>Used for important notifications</p> | ||
</div> | ||
<div class="form-group"> | ||
<label for="password">Password</label> | ||
{{input type="password" name="password" autofocus="autofocus" autocorrect="off" value=password }} | ||
<p>Must be at least 8 characters</p> | ||
</div> | ||
<footer> | ||
<button type="submit" class="btn btn-green btn-lg" {{action "setup"}} disabled={{submitting}}>Ok, Let's Do This</button> | ||
</footer> | ||
</form> | ||
<div class="gh-flow-content-wrap"> | ||
{{outlet}} | ||
</div> | ||
</section> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<section class="gh-flow-content"> | ||
<header> | ||
<h1>Welcome to <strong>Ghost</strong>!</h1> | ||
<p>So far there have been <em>{{count}}</em> Ghost blogs made by people all over the world. Today we’re making yours.</p> | ||
</header> | ||
|
||
<img class="gh-flow-screenshot" src="{{gh-path 'admin' 'img/install-welcome.png'}}" alt="Ghost screenshot" /> | ||
|
||
{{#link-to "setup.two" classNames="btn btn-green btn-lg"}} | ||
Create your account <i class="icon-chevron"></i> | ||
{{/link-to}} | ||
</section> |
Oops, something went wrong.