From 4c510f91db7adba4f465802c223ad2d7e07ffbaa Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 5 Aug 2011 11:28:11 -0400 Subject: [PATCH] search by username --- app/controllers/users_controller.rb | 11 +++++++++++ app/stylesheets/outfits/_new.sass | 2 ++ app/views/outfits/new.html.haml | 5 ++++- config/routes.rb | 2 +- public/stylesheets/compiled/screen.css | 6 +++++- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7a7d7750..e8b69d32 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,17 @@ class UsersController < ApplicationController before_filter :find_and_authorize_user!, :only => [:update] + def index # search, really + name = params[:name] + @user = User.find_by_name(name) + if @user + redirect_to user_closet_hangers_path(@user) + else + flash[:alert] = "We don't have a user named \"#{name}\". Did you spell it correctly?" + redirect_to root_path + end + end + def top_contributors @users = User.top_contributors.paginate :page => params[:page], :per_page => 20 end diff --git a/app/stylesheets/outfits/_new.sass b/app/stylesheets/outfits/_new.sass index 38d55196..7a315c40 100644 --- a/app/stylesheets/outfits/_new.sass +++ b/app/stylesheets/outfits/_new.sass @@ -134,6 +134,8 @@ body.outfits-new margin-left: .5em &:hover +opacity(1) + p + min-height: 4.5em #read-more float: right diff --git a/app/views/outfits/new.html.haml b/app/views/outfits/new.html.haml index 1baa4804..3b949f3a 100644 --- a/app/views/outfits/new.html.haml +++ b/app/views/outfits/new.html.haml @@ -37,6 +37,9 @@ %p Make lists of the items you own and want, and share them with the world. + = form_tag users_path, :method => 'get' do + = text_field_tag 'name', '', :placeholder => raw('find a user…'), :type => 'search' + = submit_tag 'search' %li %a{:href => items_path} @@ -49,7 +52,7 @@ %p Take a look through our wearables database! = form_tag items_path, :method => 'get' do - = text_field_tag 'q', '', :placeholder => raw('search items…'), :type => 'search' + = text_field_tag 'q', '', :placeholder => raw('find an item…'), :type => 'search' = submit_tag 'search' %li#blog-preview %a{:href => "http://blog.openneo.net"} diff --git a/config/routes.rb b/config/routes.rb index 64be32bb..4cdbe6c8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -49,7 +49,7 @@ OpenneoImpressItems::Application.routes.draw do |map| match '/logout' => 'sessions#destroy', :as => :logout match '/users/authorize' => 'sessions#create' - resources :users, :path => 'user', :only => [:update] do + resources :users, :path => 'user', :only => [:index, :update] do resources :contributions, :only => [:index] resources :closet_hangers, :only => [:index], :path => 'closet' do collection do diff --git a/public/stylesheets/compiled/screen.css b/public/stylesheets/compiled/screen.css index 2aa3b274..82958d06 100644 --- a/public/stylesheets/compiled/screen.css +++ b/public/stylesheets/compiled/screen.css @@ -3598,10 +3598,14 @@ body.outfits-new #sections img:hover { -khtml-opacity: 1; } /* line 137, ../../../app/stylesheets/outfits/_new.sass */ +body.outfits-new #sections p { + min-height: 4.5em; +} +/* line 139, ../../../app/stylesheets/outfits/_new.sass */ body.outfits-new #read-more { float: right; } -/* line 142, ../../../app/stylesheets/outfits/_new.sass */ +/* line 144, ../../../app/stylesheets/outfits/_new.sass */ body.outfits-new #your-items-module h3:after { color: red; content: "new!";