Skip to content

Commit

Permalink
always use params[:username]
Browse files Browse the repository at this point in the history
  • Loading branch information
burningTyger committed Mar 29, 2011
1 parent 9b546d3 commit f8cfcb5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
31 changes: 14 additions & 17 deletions controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Rstatus
redirect "/forgot_password"
end
end


# Submitted passwords are checked for length and confirmation. If the user
# does not have an email address they are required to provide one. Once the
Expand All @@ -34,7 +35,6 @@ class Rstatus
redirect "/users/password_reset"
return
end
# end

if current_user.email.nil?
if params[:email].empty?
Expand Down Expand Up @@ -119,10 +119,10 @@ class Rstatus
end

# show user profile
get "/users/:slug" do
get "/users/:username" do
set_params_page

user = User.first :username => params[:slug]
user = User.first :username => params[:username]
if user.nil?
raise Sinatra::NotFound
end
Expand Down Expand Up @@ -158,26 +158,23 @@ class Rstatus
else
flash[:notice] = "Profile could not be saved!"
end
redirect "/users/#{params[:username]}"

else
redirect "/users/#{params[:username]}"
end
redirect "/users/#{params[:username]}"
end

# an alias for the route of the feed
get "/users/:name/feed" do
feed = User.first(:username => params[:name]).feed
get "/users/:username/feed" do
feed = User.first(:username => params[:username]).feed
redirect "/feeds/#{feed.id}.atom"
end

# This lets us see who is following.
get '/users/:name/following' do
get '/users/:username/following' do
set_params_page

feeds = User.first(:username => params[:name]).following
feeds = User.first(:username => params[:username]).following

@user = User.first(:username => params[:name])
@user = User.first(:username => params[:username])
@users = feeds.paginate(:page => params[:page], :per_page => params[:per_page], :order => :id.desc).map{|f| f.author.user}

set_next_prev_page
Expand All @@ -190,20 +187,20 @@ class Rstatus
haml :"users/list", :locals => {:title => title}
end

get '/users/:name/following.json' do
get '/users/:username/following.json' do
set_params_page

users = User.first(:username => params[:name]).following
users = User.first(:username => params[:username]).following
authors = users.map { |user| user.author }
authors.to_a.to_json
end

get '/users/:name/followers' do
get '/users/:username/followers' do
set_params_page

feeds = User.first(:username => params[:name]).followers
feeds = User.first(:username => params[:username]).followers

@user = User.first(:username => params[:name])
@user = User.first(:username => params[:username])
@users = feeds.paginate(:page => params[:page], :per_page => params[:per_page], :order => :id.desc).map{|f| f.author.user}

set_next_prev_page
Expand Down
10 changes: 5 additions & 5 deletions rstatus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
# that we use. This is pretty easy, since we're using **bundler**. Just do
# this:
#
# $ gem install bundler
# $ bundle install
# $ gem install bundler
# $ bundle install
#
# That'll set it all up! Then, you need to make sure you're running MongoDB.
# I have to open up another tab in my terminal and type
#
# $ mongod
# $ mongod
#
# to get this to happen. When you're done hacking, you can hit ^-c to stop
# `mongod` from running.
#
# To actually start up the site, just
#
# $ rackup
# $ rackup
#
# and then visit [http://localhost:9292/](http://localhost:9292). You're good
# to go!
Expand Down Expand Up @@ -169,4 +169,4 @@ class Rstatus
haml :dashboard
end

end
end

0 comments on commit f8cfcb5

Please sign in to comment.