FEATURE: onebox internal audio or video files

This commit is contained in:
Arpit Jalan
2015-12-25 01:52:14 +05:30
parent 14a86dd125
commit 3a28bafc0f
4 changed files with 36 additions and 1 deletions

View File

@ -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>"