Permalink
Browse files

Limit to 2 highlight snippets per match

  • Loading branch information...
1 parent c8e30fb commit abf93d964d4499c8dba92b86d7ce2d673b9a9406 @rwdaigle committed Oct 9, 2012
Showing with 3 additions and 4 deletions.
  1. +1 −1 app/models/gist.rb
  2. +2 −3 app/views/gists/search.html.haml
View
@@ -55,7 +55,7 @@ def search(user, q)
query { string q }
sort { by :gh_created_at, 'desc' }
filter :term, :user_id => user.id
- highlight :description, :'files.content'
+ highlight :description, :'files.content', :options => { :tag => "<b>" }
size 15
end
end
@@ -13,9 +13,8 @@
%li
%p= link_to((result.highlight.description ? result.highlight['description'].first.html_safe : result.description), result.url)
- if(result.highlight[:'files.content'])
- - result.highlight[:'files.content'].each do |highlight|
- %p
- %code= highlight
+ - highlights = result.highlight[:'files.content']
+ %span.matches= highlights[0..(highlights.size < 2 ? -1 : 1)].join(' . . . ')
- else
%li
%p= link_to(result.description, result.url)

0 comments on commit abf93d9

Please sign in to comment.