Revert "FIX: Incorrect search blurb when advanced search filters are used."

This change was causing advanced search filters to disappear from the search input

This reverts commit 2e1eafae06.
This commit is contained in:
David Taylor
2020-07-09 16:19:18 +01:00
parent 8d5750d90a
commit cb1f891392
3 changed files with 10 additions and 27 deletions

View File

@@ -30,14 +30,12 @@ class Search
attr_accessor :search_log_id
BLURB_LENGTH = 200
def initialize(type_filter, term, search_context, include_blurbs, blurb_length)
@type_filter = type_filter
@term = term
@search_context = search_context
@include_blurbs = include_blurbs
@blurb_length = blurb_length || BLURB_LENGTH
@blurb_length = blurb_length || 200
@posts = []
@categories = []
@users = []
@@ -74,7 +72,7 @@ class Search
end
end
def self.blurb_for(cooked, term = nil, blurb_length = BLURB_LENGTH)
def self.blurb_for(cooked, term = nil, blurb_length = 200)
blurb = nil
cooked = SearchIndexer.scrub_html_for_search(cooked)
@@ -93,11 +91,14 @@ class Search
end
if term
if term =~ Regexp.new(Search::PHRASE_MATCH_REGEXP_PATTERN)
term = Regexp.last_match[1]
terms = term.split(/\s+/)
phrase = terms.first
if phrase =~ Regexp.new(Search::PHRASE_MATCH_REGEXP_PATTERN)
phrase = Regexp.last_match[1]
end
blurb = TextHelper.excerpt(cooked, term,
blurb = TextHelper.excerpt(cooked, phrase,
radius: blurb_length / 2
)
end