discourse/lib/onebox/engine/mixcloud_onebox.rb
jbrw 9874fe3fb3
FIX: Improve mixcloud oneboxing (#17237)
- Sets `https://www.mixcloud.com` as a `requires_iframe_origins` to allow the iframe content to be displayed
- Attempts to render something approximating the Mixcloud content in the preview pane of the Composer, rather than just displaying a large version of the artwork associated with the link
2022-06-27 08:32:24 +10:00

36 lines
880 B
Ruby

# frozen_string_literal: true
module Onebox
module Engine
class MixcloudOnebox
include Engine
include StandardEmbed
matches_regexp(/^https?:\/\/www\.mixcloud\.com\//)
always_https
requires_iframe_origins "https://www.mixcloud.com"
def placeholder_html
oembed = get_oembed
<<-HTML
<aside class="onebox mixcloud-preview">
<article class="onebox-body">
<img src="#{oembed.image}">
<div class="video-icon"></div>
<div class="mixcloud-text">
<h3><a href="#{oembed.url}" target="_blank" rel="nofollow ugc noopener">#{oembed.title}</a></h3>
<h4>#{oembed.author_name}</h4>
</div>
</article>
</aside>
HTML
end
def to_html
get_oembed.html
end
end
end
end