From f90dca555247651c580f879a22d932f378a34ce9 Mon Sep 17 00:00:00 2001 From: hukl Date: Sun, 6 Sep 2009 19:35:12 +0200 Subject: added public search controller with corresponding view --- app/controllers/search_controller.rb | 11 +++++++++++ app/helpers/search_helper.rb | 2 ++ app/views/search/index.html.erb | 19 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 app/controllers/search_controller.rb create mode 100644 app/helpers/search_helper.rb create mode 100644 app/views/search/index.html.erb (limited to 'app') diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb new file mode 100644 index 0000000..97ecdfd --- /dev/null +++ b/app/controllers/search_controller.rb @@ -0,0 +1,11 @@ +class SearchController < ApplicationController + def index + @page = Page.new + search_term = params[:search_term] + if search_term and not search_term.empty? + nodes = Node.search(params[:search_term]) + @results = nodes.map {|node| node.head} + end + end + +end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb new file mode 100644 index 0000000..b3ce20a --- /dev/null +++ b/app/helpers/search_helper.rb @@ -0,0 +1,2 @@ +module SearchHelper +end diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb new file mode 100644 index 0000000..2e46d20 --- /dev/null +++ b/app/views/search/index.html.erb @@ -0,0 +1,19 @@ +

Suche

+ +<% form_tag search_path, :method => 'get' do %> + <%= text_field_tag :search_term %> + <%= submit_tag "Suchen" %> +<% end %> + + +<% if params[:search_term] %> +

Suchergebnisse für Suchbegriff: <%= params[:search_term] %>

+<% end %> + +<%= + render( + :partial => 'custom/partials/article', + :collection => @results, + :as => :page + ) +%> \ No newline at end of file -- cgit v1.3