kinda ugly hack for ports in url with iframes
This commit is contained in:
parent
c9e3852de8
commit
ab48ca260b
3 changed files with 21 additions and 3 deletions
|
|
@ -56,8 +56,12 @@ class PostsController < ApplicationController
|
||||||
def oembed
|
def oembed
|
||||||
post_id = OEmbedPresenter.id_from_url(params.delete(:url))
|
post_id = OEmbedPresenter.id_from_url(params.delete(:url))
|
||||||
post = find_by_guid_or_id_with_current_user(post_id)
|
post = find_by_guid_or_id_with_current_user(post_id)
|
||||||
oembed = OEmbedPresenter.new(post, params.slice(:format, :maxheight, :minheight))
|
if post.present?
|
||||||
render :json => oembed
|
oembed = OEmbedPresenter.new(post, params.slice(:format, :maxheight, :minheight))
|
||||||
|
render :json => oembed
|
||||||
|
else
|
||||||
|
render :nothing => true, :status => 404
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ module PostsHelper
|
||||||
def post_iframe_url(post_id, opts={})
|
def post_iframe_url(post_id, opts={})
|
||||||
opts[:width] ||= 516
|
opts[:width] ||= 516
|
||||||
opts[:height] ||= 315
|
opts[:height] ||= 315
|
||||||
"<iframe src='#{Rails.application.routes.url_helpers.post_url(post_id, :host => AppConfig[:pod_uri].host)}' width='#{opts[:width]}px' height='#{opts[:height]}px' frameBorder='0'></iframe>".html_safe
|
host = AppConfig[:pod_uri].port ==80 ? AppConfig[:pod_uri].host : "#{AppConfig[:pod_uri].host}:#{AppConfig[:pod_uri].port}"
|
||||||
|
"<iframe src='#{Rails.application.routes.url_helpers.post_url(post_id, :host => host)}' width='#{opts[:width]}px' height='#{opts[:height]}px' frameBorder='0'></iframe>".html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,19 @@ describe PostsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'oembed' do
|
||||||
|
it 'works when you can see it' do
|
||||||
|
sign_in alice
|
||||||
|
get :oembed, :url => "/posts/#{@message.id}"
|
||||||
|
response.body.should match /iframe/
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns a 404 response when the post is not found' do
|
||||||
|
get :oembed, :url => "/posts/#{@message.id}"
|
||||||
|
response.should_not be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#destroy' do
|
describe '#destroy' do
|
||||||
before do
|
before do
|
||||||
sign_in alice
|
sign_in alice
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue