mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
FEATURE: onebox internal audio or video files
This commit is contained in:
@ -16,6 +16,8 @@ module Onebox
|
||||
begin
|
||||
route = Rails.application.routes.recognize_path(uri.path)
|
||||
case route[:controller]
|
||||
when 'uploads'
|
||||
super
|
||||
when 'topics'
|
||||
# super will use matches_regexp to match the domain name
|
||||
super
|
||||
@ -38,6 +40,16 @@ module Onebox
|
||||
|
||||
# Figure out what kind of onebox to show based on the URL
|
||||
case route[:controller]
|
||||
when 'uploads'
|
||||
|
||||
url.gsub!("http:", "https:") if SiteSetting.use_https
|
||||
if File.extname(uri.path) =~ /^.(mov|mp4|webm|ogv)$/
|
||||
return "<video width='100%' height='100%' controls><source src='#{url}'><a href='#{url}'>#{url}</a></video>"
|
||||
elsif File.extname(uri.path) =~ /^.(mp3|ogg|wav)$/
|
||||
return "<audio controls><source src='#{url}'><a href='#{url}'>#{url}</a></audio>"
|
||||
else
|
||||
return false
|
||||
end
|
||||
when 'topics'
|
||||
|
||||
linked = "<a href='#{url}'>#{url}</a>"
|
||||
|
Reference in New Issue
Block a user