Permalink
Browse files

Merge branch '2-0-stable'

Conflicts:
	refinerycms-search.gemspec
  • Loading branch information...
2 parents 84da4e7 + 41cc12a commit df4c1dd88b4c94df8e7b344dd59cbefeb95df5d3 @parndt parndt committed Sep 12, 2012
@@ -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
@@ -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>
View
@@ -0,0 +1,10 @@
+sk:
+ refinery:
+ plugins:
+ refinerycms_search:
+ title: Hľadať
+ description: Extra spôsob vyhľadávania pre Refinery CMS
+ search:
+ show:
+ search_results_for: Výsledok vyhľadávania pre '%{what}'
+
@@ -1,7 +1,7 @@
require "refinerycms-core"
module Refinery
- autoload :SearchGenerator, File.expand_path('../generators/refinery/search_generator', __FILE__)
+ autoload :SearchGenerator, 'generators/refinery/search_generator'
module Search
require "refinery/search/engine"
@@ -3,6 +3,9 @@ module Search
class Engine < Rails::Engine
include Refinery::Engine
+ isolate_namespace Refinery
+ engine_name :refinery_search
+
initializer "register refinery_search plugin" do
Refinery::Plugin.register do |plugin|
plugin.name = 'refinery_search'

0 comments on commit df4c1dd

Please sign in to comment.