diff options
| author | mo kareem <email@mokhan.ca> | 2011-05-26 21:30:21 -0600 |
|---|---|---|
| committer | mo kareem <email@mokhan.ca> | 2011-05-26 21:30:21 -0600 |
| commit | 51118147c2ab5593bfea475f2b16d848a1913559 (patch) | |
| tree | 751d7fd363e50ca43da183dd6870dac7ad2569d1 | |
| parent | 6977869c296fe003554b250b888c954d7474331d (diff) | |
add search controller and hookup the search from to search controller.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | app/controllers/creations_controller.rb | 1 | ||||
| -rw-r--r-- | app/controllers/search_controller.rb | 6 | ||||
| -rw-r--r-- | app/helpers/search_helper.rb | 2 | ||||
| -rw-r--r-- | app/views/layouts/application.html.erb | 10 | ||||
| -rw-r--r-- | app/views/search/index.html.erb | 44 | ||||
| -rw-r--r-- | config/routes.rb | 2 | ||||
| -rw-r--r-- | log/searchd.development.pid | 1 | ||||
| -rw-r--r-- | spec/controllers/search_controller_spec.rb | 12 | ||||
| -rw-r--r-- | spec/helpers/search_helper_spec.rb | 15 | ||||
| -rw-r--r-- | spec/views/search/index.html.erb_spec.rb | 5 |
11 files changed, 96 insertions, 3 deletions
@@ -4,3 +4,4 @@ log/*.log tmp/**/* *.swp public/uploads/ +db/sphinx/development/* diff --git a/app/controllers/creations_controller.rb b/app/controllers/creations_controller.rb index ce7cbf0e..2d46e391 100644 --- a/app/controllers/creations_controller.rb +++ b/app/controllers/creations_controller.rb @@ -3,7 +3,6 @@ class CreationsController < ApplicationController # GET /creations # GET /creations.xml def index - # @creations = Creation.search params[:search], :include => :user, :match_mode => :boolean @creations = Creation.all respond_to do |format| diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb new file mode 100644 index 00000000..96855ed4 --- /dev/null +++ b/app/controllers/search_controller.rb @@ -0,0 +1,6 @@ +class SearchController < ApplicationController + def index + @creations = Creation.search params[:search], :include => :user, :match_mode => :boolean + end + +end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb new file mode 100644 index 00000000..b3ce20ac --- /dev/null +++ b/app/helpers/search_helper.rb @@ -0,0 +1,2 @@ +module SearchHelper +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index f163165a..c9ca7972 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -19,8 +19,14 @@ <div id="header"><!-- Header starts here --> <div class="searchBar"> <div class="search"> - <div class="txt"><input type="text" /></div> - <div class="searchBt"><input type="button" value="search" /></div> + <% form_tag(search_index_path, :method => "get") do %> + <div class="txt"> + <%= text_field_tag(:search) %> + </div> + <div class="searchBt"> + <%= submit_tag("search") %> + </div> + <% end %> </div> <% if user_signed_in? %> <div class="signOut"> diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb new file mode 100644 index 00000000..57aed383 --- /dev/null +++ b/app/views/search/index.html.erb @@ -0,0 +1,44 @@ +<div class="welcomeHolder"> + <div class="welcome"> + <h1>Search Results</h1> + <p><em>What time is it? Nana, nana, naaaaana caake time!</em></p> + <p>Check out our communities most recent cake work.</p> + <p align="right"> + <a href="<%= url_for my_creations_path %>"><input type="button" value="MY CREATIONS" class="view" /></a> + </p> + <div class="clear"></div> + </div> + <div class="welcomeBottom"></div> +</div> + +<div class="heading">The most recent creations</div> + +<div class="organic"> +<% @creations.reverse.each_with_index do |creation, index| %> + <div class="organicHolder"> + <div class="organicContent"> + <a href="<%= url_for creation %>"> + <%= image_tag creation.image_url.to_s, :width => "285px", :height => "140px", :class => "photo", :alt => creation.name %> + </a> + <h2><%= creation.name %></h2> + <p><%= creation.story %> <%= link_to 'more...', creation %></p> + </div> + </div> + <% if (index +1) % 3 == 0 %> +</div> + +<div class="space"></div> +<div class="organic"> + + <% end %> + +<% end %> +</div> + + +<div class="space"></div> + +<div class="clear"></div> + +<div class="hr"></div> +<div class="space"></div> diff --git a/config/routes.rb b/config/routes.rb index 8bc288ce..1f68fea6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ Cake::Application.routes.draw do + get "search/index" + resources :creations resources :authentications get "home/index" diff --git a/log/searchd.development.pid b/log/searchd.development.pid new file mode 100644 index 00000000..7593b893 --- /dev/null +++ b/log/searchd.development.pid @@ -0,0 +1 @@ +3794 diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb new file mode 100644 index 00000000..0c7439fa --- /dev/null +++ b/spec/controllers/search_controller_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe SearchController do + + describe "GET 'index'" do + it "should be successful" do + get 'index' + response.should be_success + end + end + +end diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb new file mode 100644 index 00000000..fabfe99d --- /dev/null +++ b/spec/helpers/search_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the SearchHelper. For example: +# +# describe SearchHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe SearchHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/search/index.html.erb_spec.rb b/spec/views/search/index.html.erb_spec.rb new file mode 100644 index 00000000..e8ed1b6e --- /dev/null +++ b/spec/views/search/index.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe "search/index.html.erb" do + pending "add some examples to (or delete) #{__FILE__}" +end |
