diff --git a/app/assets/javascripts/discourse/lib/highlight.js b/app/assets/javascripts/discourse/lib/highlight.js
index f35e8546fc..0a6b9e0b27 100644
--- a/app/assets/javascripts/discourse/lib/highlight.js
+++ b/app/assets/javascripts/discourse/lib/highlight.js
@@ -70,7 +70,7 @@ jQuery.extend({
});
jQuery.fn.unhighlight = function (options) {
- var settings = { className: 'highlight', element: 'span' };
+ var settings = { className: 'highlight-strong', element: 'span' };
jQuery.extend(settings, options);
return this.find(settings.element + "." + settings.className).each(function () {
@@ -81,7 +81,7 @@ jQuery.fn.unhighlight = function (options) {
};
jQuery.fn.highlight = function (words, options) {
- var settings = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false };
+ var settings = { className: 'highlight-strong', element: 'span', caseSensitive: false, wordsOnly: false };
jQuery.extend(settings, options);
if (words.constructor === String) {
diff --git a/app/assets/javascripts/discourse/views/post_view.js b/app/assets/javascripts/discourse/views/post_view.js
index f316af35ef..bc7fe08f8a 100644
--- a/app/assets/javascripts/discourse/views/post_view.js
+++ b/app/assets/javascripts/discourse/views/post_view.js
@@ -289,7 +289,7 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, {
if(this._highlighted){
cooked.unhighlight();
}
- cooked.highlight(highlight);
+ cooked.highlight(highlight.split(/\s+/));
this._highlighted = true;
} else if(this._highlighted){
diff --git a/app/assets/javascripts/discourse/views/search-results-type.js.es6 b/app/assets/javascripts/discourse/views/search-results-type.js.es6
index 1ed3d355e2..e914d2ceb8 100644
--- a/app/assets/javascripts/discourse/views/search-results-type.js.es6
+++ b/app/assets/javascripts/discourse/views/search-results-type.js.es6
@@ -4,5 +4,11 @@ export default Ember.CollectionView.extend({
tagName: 'li',
classNameBindings: ['selected'],
templateName: Discourse.computed.fmt('parentView.displayType', "search/%@_result")
- })
+ }),
+ didInsertElement: function(){
+ var term = this.get('controller.term');
+ if(!_.isEmpty(term)) {
+ this.$().highlight(term.split(/\s+/));
+ }
+ }
});
diff --git a/app/assets/stylesheets/common/base/header.scss b/app/assets/stylesheets/common/base/header.scss
index d043a989d7..506cc036c6 100644
--- a/app/assets/stylesheets/common/base/header.scss
+++ b/app/assets/stylesheets/common/base/header.scss
@@ -335,3 +335,7 @@
padding: 4px 6px;
margin-left: 6px;
}
+
+.highlight-strong {
+ background-color: dark-light-diff($highlight, $secondary, 40%, -50%);
+}
diff --git a/lib/search/grouped_search_results.rb b/lib/search/grouped_search_results.rb
index 574e827df5..742b1493b6 100644
--- a/lib/search/grouped_search_results.rb
+++ b/lib/search/grouped_search_results.rb
@@ -30,13 +30,7 @@ class Search
terms = @term.split(/\s+/)
blurb = TextHelper.excerpt(cooked, terms.first, radius: 100)
blurb = TextHelper.truncate(cooked, length: 200) if blurb.blank?
- blurb = Sanitize.clean(blurb)
-
- terms.each do |term|
- blurb.gsub!(Regexp.new("(#{Regexp.escape(term)})", Regexp::IGNORECASE), "\\1")
- end
-
- blurb
+ Sanitize.clean(blurb)
end
def add(object)
diff --git a/spec/components/search_spec.rb b/spec/components/search_spec.rb
index 0ac9a78c38..f47698c4c5 100644
--- a/spec/components/search_spec.rb
+++ b/spec/components/search_spec.rb
@@ -145,7 +145,7 @@ describe Search do
p = result.posts[0]
p.topic.id.should == topic.id
p.id.should == reply.id
- result.blurb(p).should == "this reply has no quotes"
+ result.blurb(p).should == "this reply has no quotes"
end
end
diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb
index a0e075a4a6..5d4d9e2930 100644
--- a/spec/controllers/search_controller_spec.rb
+++ b/spec/controllers/search_controller_spec.rb
@@ -15,7 +15,7 @@ describe SearchController do
response.should be_success
data = JSON.parse(response.body)
data['posts'][0]['id'].should == my_post.id
- data['posts'][0]['blurb'].should == 'this is my really awesome post'
+ data['posts'][0]['blurb'].should == 'this is my really awesome post'
data['topics'][0]['id'].should == my_post.topic_id
end
end