Permalink
Browse files

Play with alternate file contents display

  • Loading branch information...
1 parent 6213278 commit 3ed1db319a4de52659f26249e743dd8fe9bc6eb3 @rwdaigle committed Oct 11, 2012
Showing with 14 additions and 11 deletions.
  1. +7 −0 app/helpers/gists_helper.rb
  2. +1 −1 app/models/gist.rb
  3. +6 −10 app/views/gists/search.html.haml
@@ -5,4 +5,11 @@ def search_result_link(result)
text = "<em>Untitled</em>".html_safe if text.blank?
link_to(text, result.url)
end
+
+ def files_display(result)
+ # tag(:script, :src => "#{result.url}.js").html_safe
+ result.files.collect do |file|
+ content_tag(:script, nil, :src => "#{result.url}.js?file=#{file.filename}")
+ end.join("<br/>").html_safe
+ end
end
View
@@ -78,7 +78,7 @@ def reindex
end
def search_cache_key(user, q)
- "#{CACHE_VERSION}-user_id:#{user.id}-updated_at:#{user.last_gh_fetch ? user.last_gh_fetch.to_i : "never"}-#{q}"
+ "#{Rails.env.production? ? CACHE_VERSION : SecureRandom.hex}-user_id:#{user.id}-updated_at:#{user.last_gh_fetch ? user.last_gh_fetch.to_i : "never"}-#{q}"
end
end
@@ -8,16 +8,12 @@
- if @results.size > 0
%ul
- for result in @results
- / # %p= result.inspect
- - if result.highlight
- %li
- %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(' . . . ')
- - else
- %li
- %p= search_result_link(result)
+ %li
+ %p= search_result_link(result)
+ / %p.files= files_display(result)
+ / - if(result.highlight && result.highlight[:'files.content'])
+ / - highlights = result.highlight[:'files.content']
+ / %span.matches= highlights[0..(highlights.size < 2 ? -1 : 1)].join(' . . . ')
- else
%p= "No results found for \"#{params[:q]}\""

0 comments on commit 3ed1db3

Please sign in to comment.