summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-09-06 19:35:12 +0200
committerhukl <contact@smyck.org>2009-09-06 19:35:12 +0200
commitf90dca555247651c580f879a22d932f378a34ce9 (patch)
tree9804d294a92a32a38e5ac5cb3a6ced8ab1c5729e /app
parent54543aeb8a1cebdffa96a6ac4b98baa6c1b8747d (diff)
added public search controller with corresponding view
Diffstat (limited to 'app')
-rw-r--r--app/controllers/search_controller.rb11
-rw-r--r--app/helpers/search_helper.rb2
-rw-r--r--app/views/search/index.html.erb19
3 files changed, 32 insertions, 0 deletions
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 @@
1class SearchController < ApplicationController
2 def index
3 @page = Page.new
4 search_term = params[:search_term]
5 if search_term and not search_term.empty?
6 nodes = Node.search(params[:search_term])
7 @results = nodes.map {|node| node.head}
8 end
9 end
10
11end
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 @@
1module SearchHelper
2end
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 @@
1<h2>Suche</h2>
2
3<% form_tag search_path, :method => 'get' do %>
4 <%= text_field_tag :search_term %>
5 <%= submit_tag "Suchen" %>
6<% end %>
7
8
9<% if params[:search_term] %>
10 <h3>Suchergebnisse für Suchbegriff: <%= params[:search_term] %></h3>
11<% end %>
12
13<%=
14 render(
15 :partial => 'custom/partials/article',
16 :collection => @results,
17 :as => :page
18 )
19%> \ No newline at end of file