mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Add disable_onebox_media_download_controls hidden site setting (#12208)
Uses discourse/onebox@ff9ec90 Adds a hidden site setting called disable_onebox_media_download_controls which will add controlslist="nodownload" to video and audio oneboxes, and also to the local video and audio oneboxes within Discourse.
This commit is contained in:
parent
e3e8fd4f7c
commit
13c2a4886f
@ -1591,6 +1591,9 @@ security:
|
|||||||
send_old_credential_reminder_days:
|
send_old_credential_reminder_days:
|
||||||
default: 0
|
default: 0
|
||||||
hidden: true
|
hidden: true
|
||||||
|
disable_onebox_media_download_controls:
|
||||||
|
default: false
|
||||||
|
hidden: true
|
||||||
|
|
||||||
onebox:
|
onebox:
|
||||||
enable_flash_video_onebox: false
|
enable_flash_video_onebox: false
|
||||||
|
@ -5,9 +5,14 @@ module Onebox
|
|||||||
module Config
|
module Config
|
||||||
DISCOURSE_ONEBOX ||=
|
DISCOURSE_ONEBOX ||=
|
||||||
Sanitize::Config.freeze_config(
|
Sanitize::Config.freeze_config(
|
||||||
Sanitize::Config.merge(Sanitize::Config::ONEBOX,
|
Sanitize::Config.merge(
|
||||||
attributes: Sanitize::Config.merge(Sanitize::Config::ONEBOX[:attributes],
|
Sanitize::Config::ONEBOX,
|
||||||
'aside' => [:data])))
|
attributes: Sanitize::Config.merge(
|
||||||
|
Sanitize::Config::ONEBOX[:attributes],
|
||||||
|
'aside' => [:data]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -221,18 +221,25 @@ module Oneboxer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.local_upload_html(url)
|
def self.local_upload_html(url)
|
||||||
|
additional_controls = \
|
||||||
|
if SiteSetting.disable_onebox_media_download_controls
|
||||||
|
"controlslist='nodownload'"
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
|
||||||
case File.extname(URI(url).path || "")
|
case File.extname(URI(url).path || "")
|
||||||
when VIDEO_REGEX
|
when VIDEO_REGEX
|
||||||
<<~HTML
|
<<~HTML
|
||||||
<div class="onebox video-onebox">
|
<div class="onebox video-onebox">
|
||||||
<video width="100%" height="100%" controls="">
|
<video #{additional_controls} width="100%" height="100%" controls="">
|
||||||
<source src='#{url}'>
|
<source src='#{url}'>
|
||||||
<a href='#{url}'>#{url}</a>
|
<a href='#{url}'>#{url}</a>
|
||||||
</video>
|
</video>
|
||||||
</div>
|
</div>
|
||||||
HTML
|
HTML
|
||||||
when AUDIO_REGEX
|
when AUDIO_REGEX
|
||||||
"<audio controls><source src='#{url}'><a href='#{url}'>#{url}</a></audio>"
|
"<audio #{additional_controls} controls><source src='#{url}'><a href='#{url}'>#{url}</a></audio>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -385,6 +392,7 @@ module Oneboxer
|
|||||||
allowed_iframe_origins: allowed_iframe_origins,
|
allowed_iframe_origins: allowed_iframe_origins,
|
||||||
hostname: GlobalSetting.hostname,
|
hostname: GlobalSetting.hostname,
|
||||||
facebook_app_access_token: SiteSetting.facebook_app_access_token,
|
facebook_app_access_token: SiteSetting.facebook_app_access_token,
|
||||||
|
disable_media_download_controls: SiteSetting.disable_onebox_media_download_controls
|
||||||
}
|
}
|
||||||
|
|
||||||
options[:cookie] = fd.cookie if fd.cookie
|
options[:cookie] = fd.cookie if fd.cookie
|
||||||
|
Loading…
Reference in New Issue
Block a user