Class: PostsController

Inherits:
ApplicationController show all
Includes:
PostsHelper
Defined in:
app/controllers/posts_controller.rb

Overview

Copyright © 2010-2011, Diaspora Inc. This file is

licensed under the Affero General Public License version 3 or later.  See
the COPYRIGHT file.

Instance Method Summary collapse

Methods included from PostsHelper

#post_iframe_url, #post_page_title

Instance Method Details

#destroyObject


55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/posts_controller.rb', line 55

def destroy
  find_current_user_post(params[:id])
  current_user.retract(@post)

  respond_to do |format|
    format.js { render 'destroy',:layout => false, :format => :js }
    format.json { render :nothing => true, :status => 204 }
    format.any { redirect_to stream_path }
  end
end

#iframeObject


36
37
38
# File 'app/controllers/posts_controller.rb', line 36

def iframe
  render :text => post_iframe_url(params[:id]), :layout => false
end

#interactionsObject


51
52
53
# File 'app/controllers/posts_controller.rb', line 51

def interactions
  respond_with(PostInteractionPresenter.new(@post, current_user))
end

#oembedObject


40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/posts_controller.rb', line 40

def oembed
  post_id = OEmbedPresenter.id_from_url(params.delete(:url))
  post = Post.find_by_guid_or_id_with_user(post_id, current_user)
  if post.present?
    oembed = OEmbedPresenter.new(post, params.slice(:format, :maxheight, :minheight))
    render :json => oembed
  else
    render :nothing => true, :status => 404
  end
end

#showObject


25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/posts_controller.rb', line 25

def show
  mark_corresponding_notifications_read if user_signed_in?

  respond_to do |format|
    format.html{ gon.post = PostPresenter.new(@post, current_user); render 'posts/show', layout: 'with_header_with_footer' }
    format.xml{ render :xml => @post.to_diaspora_xml }
    format.mobile{render 'posts/show' }
    format.json{ render :json => PostPresenter.new(@post, current_user) }
  end
end

#updateObject


66
67
68
69
70
71
# File 'app/controllers/posts_controller.rb', line 66

def update
  find_current_user_post(params[:id])
  @post.favorite = !@post.favorite
  @post.save
  render :nothing => true, :status => 202
end