diff options
| -rw-r--r-- | app/controllers/search_controller.rb | 3 | ||||
| -rw-r--r-- | app/views/search/_search_result.html.erb | 4 | ||||
| -rw-r--r-- | app/views/search/index.html.erb | 8 |
3 files changed, 8 insertions, 7 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 97ecdfd..ea545b7 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb | |||
| @@ -3,8 +3,7 @@ class SearchController < ApplicationController | |||
| 3 | @page = Page.new | 3 | @page = Page.new |
| 4 | search_term = params[:search_term] | 4 | search_term = params[:search_term] |
| 5 | if search_term and not search_term.empty? | 5 | if search_term and not search_term.empty? |
| 6 | nodes = Node.search(params[:search_term]) | 6 | @results = Node.search(params[:search_term], :include => :head) |
| 7 | @results = nodes.map {|node| node.head} | ||
| 8 | end | 7 | end |
| 9 | end | 8 | end |
| 10 | 9 | ||
diff --git a/app/views/search/_search_result.html.erb b/app/views/search/_search_result.html.erb new file mode 100644 index 0000000..b480f89 --- /dev/null +++ b/app/views/search/_search_result.html.erb | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | <div class="article_partial"> | ||
| 2 | <h2 class="headline"><%= link_to node.head.title, content_path(node.unique_path) %></h2> | ||
| 3 | <p class="excerpt"><%= node.head.abstract %></p> | ||
| 4 | </div> \ No newline at end of file | ||
diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb index 4c609a3..9824b8f 100644 --- a/app/views/search/index.html.erb +++ b/app/views/search/index.html.erb | |||
| @@ -1,13 +1,11 @@ | |||
| 1 | <h2>Suche</h2> | ||
| 2 | |||
| 3 | <% if params[:search_term] %> | 1 | <% if params[:search_term] %> |
| 4 | <h3>Suchergebnisse für Suchbegriff: <%=h params[:search_term] %></h3> | 2 | <h2>Suchergebnisse für Suchbegriff: <%=h params[:search_term] %></h2> |
| 5 | <% end %> | 3 | <% end %> |
| 6 | 4 | ||
| 7 | <%= | 5 | <%= |
| 8 | render( | 6 | render( |
| 9 | :partial => 'custom/partials/article', | 7 | :partial => 'search_result', |
| 10 | :collection => @results, | 8 | :collection => @results, |
| 11 | :as => :page | 9 | :as => :node |
| 12 | ) | 10 | ) |
| 13 | %> \ No newline at end of file | 11 | %> \ No newline at end of file |
