Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

A simple search page.

  • Loading branch information...
commit 19510e6f4604a9bca8dadd0c334adbfe2191c3df 1 parent 6f4d982
@bamnet bamnet authored August Fietkau committed
View
2  Gemfile
@@ -21,3 +21,5 @@ gem "paperclip"
gem "acts_as_list"
gem "friendly_id"
#gem 'will_paginate', '~> 3.0.beta'
+
+gem "tanker"
View
3  Gemfile.lock
@@ -106,6 +106,8 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (!= 1.3.0, ~> 1.1)
+ tanker (1.1.4)
+ json (>= 1.5.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
@@ -130,4 +132,5 @@ DEPENDENCIES
paperclip
rails (= 3.1.0)
sass-rails (~> 3.1.0)
+ tanker
uglifier
View
8 app/controllers/help_pages_controller.rb
@@ -100,4 +100,12 @@ def destroy
format.json { head :ok }
end
end
+
+ def search
+ @help_pages = HelpPage.search_tank(params[:query], :paginate => false)
+ respond_to do |format|
+ format.html
+ end
+ end
+
end
View
13 app/models/help_page.rb
@@ -1,4 +1,17 @@
class HelpPage < ActiveRecord::Base
acts_as_list
belongs_to :category
+
+ # just include the Tanker module
+ include Tanker
+ tankit 'concerto_signage' do
+ indexes :name
+ indexes :content do
+ content.gsub(/<\/?[^>]*>/, "")
+ end
+ indexes :tags
+ indexes :category, :category => true do
+ category.name
+ end
+ end
end
View
4 app/views/help_pages/search_results_inpage.html.erb → app/views/help_pages/search.html.erb
@@ -1,8 +1,8 @@
-<h2>You searched for: <b><%= params[:id] %></b></h2>
+<h2>You searched for: <b><%= params[:query] %></b></h2>
<br /><h3>Matched Help Pages:</h3>
<ol>
<% for help_page in @help_pages %>
- <li><%= link_to h(help_page.name), :controller => "help_pages", :action=>"show", :id => help_page %></li>
+ <li><%= link_to help_page.name, help_page %></li>
<% end %>
</ol>
<br /><br />
View
1  config/initializers/tanker.rb
@@ -0,0 +1 @@
+Rails.application.config.index_tank_url = "http://secret_stuff.api.indextank.com"
View
7 config/routes.rb
@@ -14,7 +14,12 @@
match "register", :to => "users#new", :as => "signup"
match "help_pages/send_email", :to => "help_pages#send_email"
- resources :help_pages
+ resources :help_pages do
+ collection do
+ get :search
+ post :search
+ end
+ end
resources :categories
Please sign in to comment.
Something went wrong with that request. Please try again.