include an iframe route, for posts, and a magic body padding removal for screens with small widths (for some reason, smaller than 770

This commit is contained in:
Maxwell Salzberg 2012-04-17 22:27:10 -07:00
parent 4d95c52960
commit 90a2f05515
5 changed files with 28 additions and 1 deletions

View file

@ -5,6 +5,12 @@
.icon-green { background-image: image_url("img/glyphicons-halflings-green.png"); }
.icon-blue { background-image: image_url("img/glyphicons-halflings-blue.png"); }
@media (max-width: 770px) { //why is 770 a magic number?
body {
padding: 0;
}
}
.photoset {
@include center(horizontal);
width: 100%;

View file

@ -5,7 +5,9 @@
require Rails.root.join("app", "presenters", "post_presenter")
class PostsController < ApplicationController
before_filter :authenticate_user!, :except => :show
include PostsHelper
before_filter :authenticate_user!, :except => [:show, :iframe]
before_filter :set_format_if_malformed_from_status_net, :only => :show
layout 'post'
@ -53,6 +55,10 @@ class PostsController < ApplicationController
end
end
def iframe
render :text => post_iframe_url(params[:id]), :layout => false
end
def destroy
@post = current_user.posts.where(:id => params[:id]).first
if @post

View file

@ -16,4 +16,10 @@ module PostsHelper
end
end
end
def post_iframe_url(post_id, opts={})
opts[:width] ||= 516
opts[:height] ||= 315
"<iframe src='#{post_url(post_id)}' width='#{opts[:width]}px' height='#{opts[:height]}px' frameBorder='0'></iframe>".html_safe
end
end

View file

@ -19,6 +19,8 @@ Diaspora::Application.routes.draw do
match "/framer" => redirect("/posts/new")
get 'p/:id' => 'posts#show', :as => 'short_post'
get 'p/:id/iframe' => 'posts#iframe', :as => 'iframe'
# roll up likes into a nested resource above
resources :comments, :only => [:create, :destroy] do
resources :likes, :only => [:create, :destroy, :index]

View file

@ -112,6 +112,13 @@ describe PostsController do
end
end
end
describe 'iframe' do
it 'contains an iframe' do
get :iframe, :id => @message.id
response.body.should match /iframe/
end
end
describe '#destroy' do
before do