Files
discourse/lib/onebox/engine/audio_onebox.rb
David Taylor f5c2a4dbbd DEV: Drop experimental enable_diffhtml_preview setting (#31306)
This was intended to provide a better UX for interactive elements in the
composer preview. However, the morphing strategy has irreconcilable
conflicts with our `decorateCooked` API, and so we have been unable to
enable this by default.

Going forward, we're focussing efforts on the WYSIWYG composer to
provide this kind of smooth UX, so we're dropping the
`enable_diffhtml_preview` approach.
2025-02-12 15:58:30 +00:00

31 lines
757 B
Ruby

# frozen_string_literal: true
module Onebox
module Engine
class AudioOnebox
include Engine
matches_regexp(%r{^(https?:)?//.*\.(mp3|ogg|opus|wav|m4a)(\?.*)?$}i)
def always_https?
AllowlistedGenericOnebox.host_matches(uri, AllowlistedGenericOnebox.https_hosts)
end
def to_html
escaped_url = ::Onebox::Helpers.normalize_url_for_output(@url)
<<-HTML
<audio controls #{@options[:disable_media_download_controls] ? 'controlslist="nodownload"' : ""}>
<source src="#{escaped_url}">
<a href="#{escaped_url}">#{@url}</a>
</audio>
HTML
end
def placeholder_html
::Onebox::Helpers.audio_placeholder_html
end
end
end
end