DEV: Remove lazy-yt and replace with lazy-videos (#20722)

- Refactors the old plugin to remove jquery usage
- Adds support for Vimeo videos (default on) and Tiktok (experimental and default off)
This commit is contained in:
Jan Cernik
2023-03-29 12:54:25 -03:00
committed by GitHub
parent 86f5abfa18
commit afe3e36363
41 changed files with 672 additions and 510 deletions

View File

@ -1019,12 +1019,30 @@ RSpec.describe PrettyText do
expect(extract_urls(html)).to eq(["https://example.com"])
end
it "should lazyYT videos" do
expect(
extract_urls(
"<div class=\"lazyYT\" data-youtube-id=\"yXEuEUQIP3Q\" data-youtube-title=\"Mister Rogers defending PBS to the US Senate\" data-width=\"480\" data-height=\"270\" data-parameters=\"feature=oembed&amp;wmode=opaque\"></div>",
),
).to eq(["https://www.youtube.com/watch?v=yXEuEUQIP3Q"])
context "when lazy-videos" do
it "should extract youtube url" do
expect(
extract_urls(
"<div class=\"lazy-video-container\" data-video-id=\"yXEuEUQIP3Q\" data-video-title=\"Mister Rogers defending PBS to the US Senate\" data-provider-name=\"youtube\"></div>",
),
).to eq(["https://www.youtube.com/watch?v=yXEuEUQIP3Q"])
end
it "should extract vimeo url" do
expect(
extract_urls(
"<div class=\"lazy-video-container\" data-video-id=\"786646692\" data-video-title=\"Dear Rich\" data-provider-name=\"vimeo\"></div>",
),
).to eq(["https://vimeo.com/786646692"])
end
it "should extract tiktok url" do
expect(
extract_urls(
"<div class=\"lazy-video-container\" data-video-id=\"6718335390845095173\" data-video-title=\"Scramble up ur name &amp;amp; I’ll try to guess it😍❤️ #foryoupage #petsoftiktok...\" data-provider-name=\"tiktok\"></div>",
),
).to eq(["https://m.tiktok.com/v/6718335390845095173"])
end
end
it "should extract links to posts" do