Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow nil description gists

  • Loading branch information...
commit e8aba4ae15532b410e870a22a14a035000c83037 1 parent 96cdbed
Ryan Daigle authored
Showing with 10 additions and 2 deletions.
  1. +8 −0 app/helpers/gists_helper.rb
  2. +2 −2 app/views/gists/search.html.haml
8 app/helpers/gists_helper.rb
View
@@ -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
4 app/views/gists/search.html.haml
View
@@ -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(' . . . ')
Please sign in to comment.
Something went wrong with that request. Please try again.