Skip to content

Commit 4ec3b5c

Browse files
author
Matt Swanson
committed
start first run experience.
1 parent 4be883e commit 4ec3b5c

12 files changed

Lines changed: 197 additions & 17 deletions

File tree

app/commands/users/create_user.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class CreateUser
2+
def initialize(repository = User)
3+
@repo = repository
4+
end
5+
6+
def create(password)
7+
@repo.create(password: password, password_confirmation: password)
8+
end
9+
end

app/controllers/first_run_controller.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require_relative "../commands/feeds/import_from_opml"
2+
require_relative "../commands/users/create_user"
23

34
class Stringer < Sinatra::Base
45
get "/import" do
@@ -10,4 +11,28 @@ class Stringer < Sinatra::Base
1011

1112
redirect to("/")
1213
end
14+
15+
get "/password" do
16+
erb :"first_run/password"
17+
end
18+
19+
post "/password" do
20+
if no_password(params) or password_mismatch?(params)
21+
flash.now[:error] = "Hey, your password confirmation didn't match. Try again."
22+
erb :"first_run/password"
23+
else
24+
CreateUser.new.create(params[:password])
25+
26+
redirect to("/import")
27+
end
28+
end
29+
30+
private
31+
def no_password(params)
32+
params[:password].nil? || params[:password] == ""
33+
end
34+
35+
def password_mismatch?(params)
36+
params[:password] != params[:password_confirmation]
37+
end
1338
end

app/models/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class User < ActiveRecord::Base
2-
attr_accessible :email, :password, :password_confirmation
2+
attr_accessible :password, :password_confirmation
33
has_secure_password
44
end

app/public/css/styles.css

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ body {
77
background-color: #FAF2E5;
88
}
99

10+
hr {
11+
border-bottom: 0px;
12+
border-top: 1px solid #e5e5e5;
13+
width: 100%;
14+
margin: 20px auto;
15+
}
16+
1017
.container {
1118
width: 720px;
1219
margin: 0 auto;
@@ -88,17 +95,22 @@ li.story {
8895
color: #484948;
8996
}
9097

91-
li.story .story-body a {
98+
li.story .story-body a, .setup a {
9299
color: #F67100;
93100
text-decoration: none;
94101
border-bottom: 1px dotted #F67100;
95102
}
96103

97-
li.story .story-body a:hover {
104+
li.story .story-body a:hover, .setup a:hover {
98105
color: #F59745;
99106
border-bottom: 1px dotted #F59745;
100107
}
101108

109+
a.btn, a.btn:hover {
110+
border-bottom: 0px;
111+
color: white;
112+
}
113+
102114
li.story.read {
103115
opacity: 0.5;
104116
}
@@ -216,4 +228,32 @@ li.story.open .story-preview {
216228
#zen #gtfo {
217229
color: #F59745;
218230
font-weight: bold;
231+
}
232+
233+
.orange {
234+
color: #F67100;
235+
}
236+
237+
.setup {
238+
width: 350px;
239+
margin: 0 auto;
240+
padding-top: 50px;
241+
}
242+
243+
.setup h1 {
244+
text-align: center;
245+
}
246+
247+
.setup h2 {
248+
text-align: center;
249+
font-size: 18px;
250+
line-height: 22px;
251+
}
252+
253+
.setup p {
254+
text-align: justify;
255+
}
256+
257+
.setup .control-group input {
258+
width: 336px;
219259
}

app/views/first_run/password.erb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<div class="setup" id="password-setup">
2+
<h1>Stringer is <span class="orange">anti-social</span>.</h1>
3+
<h2>There is only one user: you.</h2>
4+
<hr />
5+
<p>Let's setup a password so only you can read your stories.</p>
6+
<hr />
7+
<form id="password_setup" method="POST" action="/password">
8+
<div class="control-group">
9+
<label for="password">Password</label>
10+
<input type="password" name="password" id="password" />
11+
</div>
12+
<div class="control-group">
13+
<label for="password">Confirm Password</label>
14+
<input type="password" name="password_confirmation" id="password_confirmation" />
15+
</div>
16+
17+
<input type="submit" id="submit" class="btn btn-primary pull-right" value="Next"/>
18+
</form>
19+
</div>

app/views/import.erb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22
<script src="/js/bootstrap.file-input.js"></script>
33
<% end %>
44

5+
<div class="setup" id="feed-setup">
6+
<h1>Stringer can <span class="orange">import</span>.</h1>
7+
<h2>Let's setup your feeds.</h2>
8+
9+
<hr />
10+
<p>Use this <a href="#">guide</a> to export your feeds from Google Reader.</p>
11+
<hr />
512

6-
<form id="import" method="POST" action="/import" enctype="multipart/form-data">
7-
<input id="opml_file" name="opml_file" type="file" title="Browse" class="btn-primary" />
8-
</form>
13+
<form id="import" method="POST" action="/import" enctype="multipart/form-data">
14+
<input id="opml_file" name="opml_file" type="file" title="Import OPML" class="btn-primary" />
15+
<a id="skip" class="btn pull-right">Not now</a>
16+
</form>
17+
</div>
918

1019
<script type="text/javascript">
1120
$(document).ready(function() {

app/views/index.erb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,16 @@
1818
</div>
1919
<% else %>
2020
<%= render_partial :zen %>
21+
<% end %>
22+
23+
<% content_for :footer do %>
24+
<div class="container">
25+
<div class="row-fluid">
26+
<div class="span12">
27+
<p class="pull-right">
28+
<b>Hey!</b> Get back to work, slacker!
29+
</p>
30+
</div>
31+
</div>
32+
</div>
2133
<% end %>

app/views/layout.erb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,7 @@
3434
</div>
3535

3636
<div id="footer">
37-
<div class="container">
38-
<div class="row-fluid">
39-
<div class="span12">
40-
<p class="pull-right">
41-
<b>Hey!</b> Get back to work, slacker!
42-
</p>
43-
</div>
44-
</div>
45-
</div>
37+
<%= yield_content :footer %>
4638
</div>
4739
</body>
4840
</html>

app/views/partials/_flash.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<% if flash.has_key? :success %>
2-
<div class="alert alert-success">
2+
<div class="alert alert-success success">
33
<%= flash[:success] %>
44
</div>
55
<% end %>
66

77
<% if flash.has_key? :error %>
8-
<div class="alert alert-error">
8+
<div class="alert alert-error error">
99
<%= flash[:error] %>
1010
</div>
1111
<% end %>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class DropEmailFromUser < ActiveRecord::Migration
2+
def change
3+
remove_column :users, :email
4+
end
5+
end

0 commit comments

Comments
 (0)