Permalink
Browse files

Allow nil description gists

  • Loading branch information...
rwdaigle committed Oct 10, 2012
1 parent 96cdbed commit e8aba4ae15532b410e870a22a14a035000c83037
Showing with 10 additions and 2 deletions.
  1. +8 −0 app/helpers/gists_helper.rb
  2. +2 −2 app/views/gists/search.html.haml
@@ -0,0 +1,8 @@
+module GistsHelper
+
+ def search_result_link(result)
+ text = result.highlight.description ? result.highlight['description'].first.html_safe : result.description
+ text = "<em>Untitled</em>".html_safe if text.blank?
+ link_to(text, result.url)
+ end
+end
@@ -8,10 +8,10 @@
- if @results.size > 0
%ul
- for result in @results
- / %p= result.inspect
+ / # %p= result.inspect
- if result.highlight
%li
- %p= link_to((result.highlight.description ? result.highlight['description'].first.html_safe : result.description), result.url)
+ %p= search_result_link(result)
- if(result.highlight[:'files.content'])
- highlights = result.highlight[:'files.content']
%span.matches= highlights[0..(highlights.size < 2 ? -1 : 1)].join(' . . . ')

0 comments on commit e8aba4a

Please sign in to comment.