Skip to content

Commit 0d35500

Browse files
committed
Cleaning up whitespace.
I used to think tabs were better than spaces, but it seems like everyone else uses expandtab set to two spaces. Fine by me, now that I have a rake task to make sure that it's all good.
1 parent 8a69b21 commit 0d35500

32 files changed

Lines changed: 729 additions & 729 deletions

configure.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,34 @@
1010

1111
#this method will set up our database connection for any environment
1212
def setup_db environ
13-
if environ == :production
14-
#we want to connect to mongohq
15-
MongoMapper.connection = Mongo::Connection.new(ENV['MONGOHQ_HOST'], ENV['MONGOHQ_PORT'])
16-
MongoMapper.database = ENV['MONGOHQ_DATABASE']
17-
MongoMapper.database.authenticate(ENV['MONGOHQ_USER'],ENV['MONGOHQ_PASSWORD'])
18-
else
19-
MongoMapper.connection = Mongo::Connection.new('localhost')
20-
MongoMapper.database = "hackety-#{environ}"
21-
end
13+
if environ == :production
14+
#we want to connect to mongohq
15+
MongoMapper.connection = Mongo::Connection.new(ENV['MONGOHQ_HOST'], ENV['MONGOHQ_PORT'])
16+
MongoMapper.database = ENV['MONGOHQ_DATABASE']
17+
MongoMapper.database.authenticate(ENV['MONGOHQ_USER'],ENV['MONGOHQ_PASSWORD'])
18+
else
19+
MongoMapper.connection = Mongo::Connection.new('localhost')
20+
MongoMapper.database = "hackety-#{environ}"
21+
end
2222
end
2323

2424
#these configure blocks only run in one environment
2525
#right now the only configuration we do special is set up the databse
2626
#I'm sure these can be condensed into one block, I just havn't done it yet.
2727
configure :test do
28-
setup_db(:test)
28+
setup_db(:test)
2929
end
3030

3131
configure :development do
32-
setup_db(:development)
32+
setup_db(:development)
3333
end
3434

3535
configure :production do
36-
setup_db(:production)
36+
setup_db(:production)
3737
end
3838

3939
#for all environments,
4040
configure do
41-
#require all of our models!
42-
require_directory "models"
41+
#require all of our models!
42+
require_directory "models"
4343
end

controllers/forums.rb

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
11
#you can view the forums at /forums
22
get "/forums" do
33

4-
#render that template!
5-
haml :"forums/index"
4+
#render that template!
5+
haml :"forums/index"
66
end
77

88
#you can view an individual forum here!
99
get "/forums/:forum" do
10-
11-
#we use this in the view
12-
@forum = params[:forum]
10+
11+
#we use this in the view
12+
@forum = params[:forum]
1313

14-
#gotta find all the discussions in this forum
15-
@discussions = Discussion.all(:forum => params[:forum]).sort{|a,b| a.updated_at <=> b.updated_at}.reverse
14+
#gotta find all the discussions in this forum
15+
@discussions = Discussion.all(:forum => params[:forum]).sort{|a,b| a.updated_at <=> b.updated_at}.reverse
1616

17-
#render the template!
18-
haml :"forums/show"
17+
#render the template!
18+
haml :"forums/show"
1919
end
2020

2121
get "/forums/:forum/discussions/new" do
22-
@forum = params[:forum]
23-
haml :"discussions/new"
22+
@forum = params[:forum]
23+
haml :"discussions/new"
2424
end
2525

2626
post "/forums/:forum/discussions" do
27-
params[:author] = current_user.username
28-
params[:author_email] = current_user.email
29-
@discussion = Discussion.create(params)
30-
flash[:notice] = "Discussion created!"
31-
redirect "/forums/#{params[:forum]}/#{@discussion.slug}"
27+
params[:author] = current_user.username
28+
params[:author_email] = current_user.email
29+
@discussion = Discussion.create(params)
30+
flash[:notice] = "Discussion created!"
31+
redirect "/forums/#{params[:forum]}/#{@discussion.slug}"
3232
end
3333

3434
#you view a discussion here
3535
get "/forums/:forum/:discussion" do
36-
@discussion = Discussion.first(:forum => params[:forum], :slug => params[:discussion])
37-
haml :"discussions/show"
36+
@discussion = Discussion.first(:forum => params[:forum], :slug => params[:discussion])
37+
haml :"discussions/show"
3838
end
3939

4040
get "/forums/reply/to/:forum/:discussion" do
41-
@forum = params[:forum]
42-
@discussion = params[:discussion]
43-
@discussion_title = Discussion.first(:forum => params[:forum], :slug => params[:discussion]).title
41+
@forum = params[:forum]
42+
@discussion = params[:discussion]
43+
@discussion_title = Discussion.first(:forum => params[:forum], :slug => params[:discussion]).title
4444

45-
haml :"forums/reply"
45+
haml :"forums/reply"
4646
end
4747

4848
post "/forums/reply/to/:forum/:discussion" do
49-
@discussion = Discussion.first(:forum => params[:forum], :slug => params[:discussion])
50-
params[:reply][:author] = current_user.username
51-
params[:reply][:author_email] = current_user.email
52-
@discussion.replies << Reply.new(params[:reply])
53-
@discussion.save
54-
55-
flash[:notice] = "Replied!"
56-
redirect "/forums/#{params[:forum]}/#{params[:discussion]}"
49+
@discussion = Discussion.first(:forum => params[:forum], :slug => params[:discussion])
50+
params[:reply][:author] = current_user.username
51+
params[:reply][:author_email] = current_user.email
52+
@discussion.replies << Reply.new(params[:reply])
53+
@discussion.save
54+
55+
flash[:notice] = "Replied!"
56+
redirect "/forums/#{params[:forum]}/#{params[:discussion]}"
5757
end

controllers/hacker.rb

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3,103 +3,103 @@
33

44
# An individual Hacker's page
55
get '/hackers/:name' do
6-
#find the hacker with the given name
7-
@hacker = Hacker.first(:username => params[:name])
6+
#find the hacker with the given name
7+
@hacker = Hacker.first(:username => params[:name])
88

9-
#render the template
10-
haml :"hackers/show"
9+
#render the template
10+
haml :"hackers/show"
1111
end
1212

1313
#update a hacker's information
1414
post '/hackers/update' do
15-
#you have to be logged in to update your info
16-
require_login! :return => "/hackers/update"
17-
18-
#do they want to update their password
19-
unless params[:password].nil?
20-
if params[:password][:new] == params[:password][:confirm]
21-
current_user.password = params[:password][:new]
22-
current_user.save
23-
flash[:notice] = "Password updated!"
24-
else
25-
flash[:notice] = "Password confirmation didn't match!"
26-
end
27-
else
28-
current_user.update_attributes(:about => params[:hacker][:about])
29-
current_user.save
30-
flash[:notice] = "About information updated!"
31-
end
32-
33-
redirect "/hackers/#{current_user.username}"
34-
15+
#you have to be logged in to update your info
16+
require_login! :return => "/hackers/update"
17+
18+
#do they want to update their password
19+
unless params[:password].nil?
20+
if params[:password][:new] == params[:password][:confirm]
21+
current_user.password = params[:password][:new]
22+
current_user.save
23+
flash[:notice] = "Password updated!"
24+
else
25+
flash[:notice] = "Password confirmation didn't match!"
26+
end
27+
else
28+
current_user.update_attributes(:about => params[:hacker][:about])
29+
current_user.save
30+
flash[:notice] = "About information updated!"
31+
end
32+
33+
redirect "/hackers/#{current_user.username}"
34+
3535
end
3636

3737
#this lets you follow a Hacker
3838
get '/hackers/:name/follow' do
39-
#we have to be logged in to follow someone
40-
require_login! :return => "/hackers/#{params[:name]}/follow"
39+
#we have to be logged in to follow someone
40+
require_login! :return => "/hackers/#{params[:name]}/follow"
4141

42-
#find the hacker with the given name
43-
@hacker = Hacker.first(:username => params[:name])
42+
#find the hacker with the given name
43+
@hacker = Hacker.first(:username => params[:name])
4444

45-
#make sure we're not following them already
46-
if current_user.following? @hacker
47-
flash[:notice] = "You're already following #{params[:name]}."
48-
redirect "/hackers/#{current_user.username}"
49-
return
50-
end
45+
#make sure we're not following them already
46+
if current_user.following? @hacker
47+
flash[:notice] = "You're already following #{params[:name]}."
48+
redirect "/hackers/#{current_user.username}"
49+
return
50+
end
5151

52-
#follow them!
53-
current_user.follow! @hacker
52+
#follow them!
53+
current_user.follow! @hacker
5454

55-
#set a message
56-
flash[:notice] = "Now following #{params[:name]}."
55+
#set a message
56+
flash[:notice] = "Now following #{params[:name]}."
5757

58-
#redirect back to your page!
59-
redirect "/hackers/#{current_user.username}"
58+
#redirect back to your page!
59+
redirect "/hackers/#{current_user.username}"
6060

6161
end
6262

6363
#this lets you unfollow a Hacker
6464
get '/hackers/:name/unfollow' do
65-
#we have to be logged in to unfollow someone
66-
require_login! :return => "/hackers/#{params[:name]}/unfollow"
65+
#we have to be logged in to unfollow someone
66+
require_login! :return => "/hackers/#{params[:name]}/unfollow"
6767

68-
#find the hacker with the given name
69-
@hacker = Hacker.first(:username => params[:name])
70-
71-
#make sure we're not following them already
72-
unless current_user.following? @hacker
73-
flash[:notice] = "You're already not following #{params[:name]}."
74-
redirect "/hackers/#{current_user.username}"
75-
return
76-
end
68+
#find the hacker with the given name
69+
@hacker = Hacker.first(:username => params[:name])
70+
71+
#make sure we're not following them already
72+
unless current_user.following? @hacker
73+
flash[:notice] = "You're already not following #{params[:name]}."
74+
redirect "/hackers/#{current_user.username}"
75+
return
76+
end
7777

78-
#unfollow them!
79-
current_user.unfollow! @hacker
78+
#unfollow them!
79+
current_user.unfollow! @hacker
8080

81-
#set a message
82-
flash[:notice] = "No longer following #{params[:name]}."
81+
#set a message
82+
flash[:notice] = "No longer following #{params[:name]}."
8383

84-
#redirect back to your page!
85-
redirect "/hackers/#{current_user.username}"
84+
#redirect back to your page!
85+
redirect "/hackers/#{current_user.username}"
8686

8787
end
8888

8989
#this lets us see followers
9090
get '/hackers/:name/followers' do
91-
#find the hacker with the given name
92-
@hacker = Hacker.first(:username => params[:name])
91+
#find the hacker with the given name
92+
@hacker = Hacker.first(:username => params[:name])
9393

94-
#render our page
95-
haml :"hackers/followers"
94+
#render our page
95+
haml :"hackers/followers"
9696
end
9797

9898
#this lets us see following
9999
get '/hackers/:name/following' do
100-
#find the hacker with the given name
101-
@hacker = Hacker.first(:username => params[:name])
100+
#find the hacker with the given name
101+
@hacker = Hacker.first(:username => params[:name])
102102

103-
#render our page
104-
haml :"hackers/following"
103+
#render our page
104+
haml :"hackers/following"
105105
end

controllers/help.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#this is where we can go to get help
22
get "/help" do
3-
haml :"help/index"
3+
haml :"help/index"
44
end

controllers/messages.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
#people can get a form to send messages here
22
get "/messages/new/to/:username" do
3-
#gotta be logged in!
4-
require_login!
3+
#gotta be logged in!
4+
require_login!
55

6-
#we've got to save the username to put it in the view
7-
@username = params[:username]
6+
#we've got to save the username to put it in the view
7+
@username = params[:username]
88

9-
#render the template
10-
haml :"messages/new"
9+
#render the template
10+
haml :"messages/new"
1111
end
1212

1313
#this is where the form POSTs to
1414
post "/messages" do
15-
#gotta be logged in!
16-
require_login!
15+
#gotta be logged in!
16+
require_login!
1717

18-
params[:message][:sender] = current_user.username
18+
params[:message][:sender] = current_user.username
1919

20-
#make a new message with our params
21-
message = Message.create(params[:message])
20+
#make a new message with our params
21+
message = Message.create(params[:message])
2222

23-
#set a friendly message
24-
flash[:notice] = "Message sent."
23+
#set a friendly message
24+
flash[:notice] = "Message sent."
2525

26-
#render the page of the recipient
27-
redirect "/hackers/#{message.recipient}"
26+
#render the page of the recipient
27+
redirect "/hackers/#{message.recipient}"
2828
end
2929

3030
#this is the page where you can see your messages
3131
get "/messages" do
32-
require_login!
33-
@messages = Message.all({"recipient" => current_user.username})
34-
haml :"messages/index"
32+
require_login!
33+
@messages = Message.all({"recipient" => current_user.username})
34+
haml :"messages/index"
3535
end

0 commit comments

Comments
 (0)