OSDN Git Service

Search engine:
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 15 Oct 2007 16:15:20 +0000 (16:15 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 15 Oct 2007 16:15:20 +0000 (16:15 +0000)
* results are now displayed using different colors for tokens highlighting
* added label tag around "all words" checkbox

git-svn-id: http://redmine.rubyforge.org/svn/trunk@841 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/search_helper.rb
app/views/search/index.rhtml
public/stylesheets/application.css

index 75412c7..ed2f40b 100644 (file)
@@ -26,7 +26,12 @@ module SearchHelper
         result << '...'
         break
       end
-      result << (i.even? ? h(words.length > 100 ? "#{words[0..44]} ... #{words[-45..-1]}" : words) : content_tag('span', h(words), :class => 'highlight'))
+      if i.even?
+        result << h(words.length > 100 ? "#{words[0..44]} ... #{words[-45..-1]}" : words)
+      else
+        t = (tokens.index(words.downcase) || 0) % 4
+        result << content_tag('span', h(words), :class => "highlight token-#{t}")
+      end
     end
     result
   end
index 4dc26af..4bf80f0 100644 (file)
@@ -9,7 +9,7 @@
 <label><%= check_box_tag t, 1, @scope.include?(t) %> <%= l("label_#{t.singularize}_plural")%></label>\r
 <% end %>\r
 <br />\r
-<%= check_box_tag 'all_words', 1, @all_words %> <%= l(:label_all_words) %></p>\r
+<label><%= check_box_tag 'all_words', 1, @all_words %> <%= l(:label_all_words) %></label></p>\r
 <%= submit_tag l(:button_submit), :name => 'submit' %>\r
 <% end %>\r
 </div>\r
index 9bae7bc..1ae2041 100644 (file)
@@ -83,6 +83,9 @@ table p {margin:0;}
 .even {background-color: #fff;}
 
 .highlight { background-color: #FCFD8D;}
+.highlight.token-1 { background-color: #faa;}
+.highlight.token-2 { background-color: #afa;}
+.highlight.token-3 { background-color: #aaf;}
 
 .box{
 padding:6px;