diff --git a/app/assets/stylesheets/new_styles/_base.scss b/app/assets/stylesheets/new_styles/_base.scss index f60d86350..c28c53997 100644 --- a/app/assets/stylesheets/new_styles/_base.scss +++ b/app/assets/stylesheets/new_styles/_base.scss @@ -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%; diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 04dfa14ad..5dee5bb46 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -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 diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index 1944752df..35e981a1c 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -16,4 +16,10 @@ module PostsHelper end end end + + def post_iframe_url(post_id, opts={}) + opts[:width] ||= 516 + opts[:height] ||= 315 + "".html_safe + end end diff --git a/config/routes.rb b/config/routes.rb index dab1d6454..a50712307 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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] diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 8ab8d8493..2a53a661b 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -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