Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes #16 by adding support for Refinery 2.0.4 so that we can use rou…

…te_for_model which resolves namespaces as expected.
  • Loading branch information...
commit 004f63b0d9b0f833a3cbb35fc08086921882af17 1 parent 5aef6f9
Philip Arndt parndt authored
14 app/helpers/refinery/search_helper.rb
View
@@ -1,10 +1,22 @@
module Refinery
module SearchHelper
+ def result_title(result)
+ result.title.gsub /(#{Regexp.escape(params[:query])})/i, '<mark>\1</mark>'
+ end
+
+ def result_type(result)
+ result.class.to_s.titleize.gsub('Refinery/', '').gsub '/', '::'
+ end
+
# this is where you register your result URLs based on the
# type of result we're dealing with
def result_url(result)
- result.respond_to?(:url) ? refinery.url_for(result.url) : refinery.url_for(result)
+ if result.respond_to? :url
+ refinery.url_for result.url
+ else
+ refinery.url_for send(Refinery.route_for_model(result.class, :admin => false), result)
+ end
end
end
4 app/views/refinery/search/show.html.erb
View
@@ -7,9 +7,9 @@
<% @results.each do |result| %>
<li>
<span class='result_type'>
- <%= result.class.to_s.titleize %>
+ <%= result_type result %>
</span>
- <%= link_to raw(result.title.gsub(/(#{Regexp.escape(params[:query])})/i, '<mark>\1</mark>')), result_url(result) %>
+ <%= link_to result_title(result).html_safe, result_url(result) %>
</li>
<% end %>
</ul>
2  refinerycms-search.gemspec
View
@@ -12,5 +12,5 @@ Gem::Specification.new do |s|
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- spec/*`.split("\n")
- s.add_dependency 'refinerycms-core', '~> 2.0.0'
+ s.add_dependency 'refinerycms-core', '~> 2.0.4'
end
Please sign in to comment.
Something went wrong with that request. Please try again.