mirror of
https://github.com/discourse/discourse.git
synced 2025-04-02 05:42:30 +08:00
FEATURE: index YouTube titles in search
Previously we omitted the titles for videos that YouTube provided
This commit is contained in:
parent
55179efdb9
commit
6676bbd38b
@ -196,6 +196,11 @@ class SearchIndexer
|
|||||||
scrubbed << attributes["title"]
|
scrubbed << attributes["title"]
|
||||||
scrubbed << " "
|
scrubbed << " "
|
||||||
end
|
end
|
||||||
|
if attributes["data-youtube-title"]
|
||||||
|
scrubbed << " "
|
||||||
|
scrubbed << attributes["data-youtube-title"]
|
||||||
|
scrubbed << " "
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def characters(string)
|
def characters(string)
|
||||||
|
@ -13,6 +13,14 @@ describe SearchIndexer do
|
|||||||
expect(raw_data.split(' ').length).to eq(2)
|
expect(raw_data.split(' ').length).to eq(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'extract youtube title' do
|
||||||
|
html = "<div class=\"lazyYT\" data-youtube-id=\"lmFgeFh2nlw\" data-youtube-title=\"Metallica Mixer Explains Missing Bass on 'And Justice for All' [Exclusive]\" data-width=\"480\" data-height=\"270\" data-parameters=\"feature=oembed&wmode=opaque\"></div>"
|
||||||
|
|
||||||
|
scrubbed = SearchIndexer::HtmlScrubber.scrub(html)
|
||||||
|
|
||||||
|
expect(scrubbed).to eq(" Metallica Mixer Explains Missing Bass on 'And Justice for All' [Exclusive] ")
|
||||||
|
end
|
||||||
|
|
||||||
it 'correctly indexes a post according to version' do
|
it 'correctly indexes a post according to version' do
|
||||||
# Preparing so that they can be indexed to right version
|
# Preparing so that they can be indexed to right version
|
||||||
SearchIndexer.update_posts_index(post_id, "dummy", "", nil, nil)
|
SearchIndexer.update_posts_index(post_id, "dummy", "", nil, nil)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user