diff options
| author | hukl <contact@smyck.org> | 2009-09-06 21:51:31 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-09-06 21:51:31 +0200 |
| commit | 8f2dc36616548650000308ebc8b1f9e2947c0ef9 (patch) | |
| tree | 79f1226c6f7646b1bbe57634c848e44d426bd01f | |
| parent | 5c90701cdf3ad475840a76f096f1b74ff68fbd0f (diff) | |
| parent | d555e1b27df1096e8899f2e50c8d6421f4c1cca3 (diff) | |
Merge branch 'public_search'
| -rw-r--r-- | app/controllers/search_controller.rb | 11 | ||||
| -rw-r--r-- | app/helpers/search_helper.rb | 2 | ||||
| -rw-r--r-- | app/views/layouts/application.html.erb | 10 | ||||
| -rw-r--r-- | app/views/search/index.html.erb | 15 | ||||
| -rw-r--r-- | config/routes.rb | 1 | ||||
| -rw-r--r-- | public/images/search_button.png | bin | 0 -> 4272 bytes | |||
| -rw-r--r-- | public/images/search_field.png | bin | 0 -> 2941 bytes | |||
| -rw-r--r-- | public/stylesheets/ccc.css | 30 | ||||
| -rw-r--r-- | test/functional/search_controller_test.rb | 8 | ||||
| -rw-r--r-- | test/unit/helpers/search_helper_test.rb | 4 |
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 @@ | |||
| 1 | class 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 | |||
| 11 | 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 @@ | |||
| 1 | module SearchHelper | ||
| 2 | end | ||
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 { | |||
| 107 | div#center_column { | 107 | div#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 | ||
| 140 | div.article_partial p.excerpt { | 140 | div.article_partial p.excerpt { |
| 141 | color: #404040; | 141 | color: #404040; |
| 142 | } | ||
| 143 | |||
| 144 | div#search { | ||
| 145 | position: absolute; | ||
| 146 | top: 145px; | ||
| 147 | left: 676px; | ||
| 148 | height: 1000px; | ||
| 149 | vertical-align: top; | ||
| 150 | } | ||
| 151 | |||
| 152 | div#search input[type=button] { | ||
| 153 | display: block; | ||
| 154 | height: 20px; | ||
| 155 | } | ||
| 156 | |||
| 157 | div#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 @@ | |||
| 1 | require 'test_helper' | ||
| 2 | |||
| 3 | class SearchControllerTest < ActionController::TestCase | ||
| 4 | # Replace this with your real tests. | ||
| 5 | test "the truth" do | ||
| 6 | assert true | ||
| 7 | end | ||
| 8 | end | ||
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 @@ | |||
| 1 | require 'test_helper' | ||
| 2 | |||
| 3 | class SearchHelperTest < ActionView::TestCase | ||
| 4 | end | ||
