summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/search_controller.rb11
-rw-r--r--app/helpers/search_helper.rb2
-rw-r--r--app/views/layouts/application.html.erb10
-rw-r--r--app/views/search/index.html.erb15
-rw-r--r--config/routes.rb1
-rw-r--r--public/images/search_button.pngbin0 -> 4272 bytes
-rw-r--r--public/images/search_field.pngbin0 -> 2941 bytes
-rw-r--r--public/stylesheets/ccc.css30
-rw-r--r--test/functional/search_controller_test.rb8
-rw-r--r--test/unit/helpers/search_helper_test.rb4
10 files changed, 80 insertions, 1 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/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 69db939..0b32673 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -14,6 +14,16 @@
14 <div id="header"> 14 <div id="header">
15 <%= image_tag "header.png" %> 15 <%= image_tag "header.png" %>
16 </div> 16 </div>
17 <div id="search">
18 <table>
19 <% form_tag search_path, :method => 'get' do %>
20 <tr>
21 <td><%= text_field_tag :search_term %></td>
22 <td style="padding-top: 2px"><%= image_submit_tag("search_button.png") %></td>
23 </tr>
24 <% end %>
25 </table>
26 </div>
17 <div id="left_column"> 27 <div id="left_column">
18 <%= main_menu %> 28 <%= main_menu %>
19 29
diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb
new file mode 100644
index 0000000..28764bf
--- /dev/null
+++ b/app/views/search/index.html.erb
@@ -0,0 +1,15 @@
1<h2>Suche</h2>
2
3
4
5<% if params[:search_term] %>
6 <h3>Suchergebnisse für Suchbegriff: <%= params[:search_term] %></h3>
7<% end %>
8
9<%=
10 render(
11 :partial => 'custom/partials/article',
12 :collection => @results,
13 :as => :page
14 )
15%> \ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index c3b2e84..1706dad 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -18,6 +18,7 @@ ActionController::Routing::Routes.draw do |map|
18 map.logout '/logout', :controller => 'sessions', :action => 'destroy' 18 map.logout '/logout', :controller => 'sessions', :action => 'destroy'
19 map.login '/login', :controller => 'sessions', :action => 'new' 19 map.login '/login', :controller => 'sessions', :action => 'new'
20 map.admin_search 'admin/search', :controller => 'admin', :action => 'search' 20 map.admin_search 'admin/search', :controller => 'admin', :action => 'search'
21 map.search 'search', :controller => "search", :action => 'index'
21 map.resources :users 22 map.resources :users
22 map.resources :menu_items, :member => {:sort => :post} 23 map.resources :menu_items, :member => {:sort => :post}
23 map.resource :session 24 map.resource :session
diff --git a/public/images/search_button.png b/public/images/search_button.png
new file mode 100644
index 0000000..9a59f04
--- /dev/null
+++ b/public/images/search_button.png
Binary files differ
diff --git a/public/images/search_field.png b/public/images/search_field.png
new file mode 100644
index 0000000..1ee523d
--- /dev/null
+++ b/public/images/search_field.png
Binary files differ
diff --git a/public/stylesheets/ccc.css b/public/stylesheets/ccc.css
index beb16f0..6a9458f 100644
--- a/public/stylesheets/ccc.css
+++ b/public/stylesheets/ccc.css
@@ -107,7 +107,7 @@ div#left_column {
107div#center_column { 107div#center_column {
108 position: absolute; 108 position: absolute;
109 background-color: #ffffff; 109 background-color: #ffffff;
110 left: 185px; 110 left: 200px;
111 width: 460px; 111 width: 460px;
112 padding-left: 15px; 112 padding-left: 15px;
113 padding-right: 15px; 113 padding-right: 15px;
@@ -139,4 +139,32 @@ div.article_partial h2 a {
139 139
140div.article_partial p.excerpt { 140div.article_partial p.excerpt {
141 color: #404040; 141 color: #404040;
142}
143
144div#search {
145 position: absolute;
146 top: 145px;
147 left: 676px;
148 height: 1000px;
149 vertical-align: top;
150}
151
152div#search input[type=button] {
153 display: block;
154 height: 20px;
155}
156
157div#search input[type=text] {
158 display: block;
159 padding: 0px;
160 margin: 0px;
161 height: 20px;
162 width: 132px;
163 line-height: 20px;
164 border: none;
165 background-image: url(/images/search_field.png);
166 background-repeat:no-repeat;
167 padding-right: 5px;
168 margin-right: 5px;
169 background-position: top top;
142} \ No newline at end of file 170} \ No newline at end of file
diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb
new file mode 100644
index 0000000..49bb14f
--- /dev/null
+++ b/test/functional/search_controller_test.rb
@@ -0,0 +1,8 @@
1require 'test_helper'
2
3class SearchControllerTest < ActionController::TestCase
4 # Replace this with your real tests.
5 test "the truth" do
6 assert true
7 end
8end
diff --git a/test/unit/helpers/search_helper_test.rb b/test/unit/helpers/search_helper_test.rb
new file mode 100644
index 0000000..3034163
--- /dev/null
+++ b/test/unit/helpers/search_helper_test.rb
@@ -0,0 +1,4 @@
1require 'test_helper'
2
3class SearchHelperTest < ActionView::TestCase
4end