Class: PostsController

Inherits:
ApplicationController show all
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

Instance Method Details

#destroyObject


59
60
61
62
63
64
65
# File 'app/controllers/posts_controller.rb', line 59

def destroy
  post_service.destroy(params[:id])
  respond_to do |format|
    format.json { head :no_content }
    format.any { redirect_to stream_path }
  end
end

#mentionableObject


44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/posts_controller.rb', line 44

def mentionable
  respond_to do |format|
    format.json {
      if params[:id].present? && params[:q].present?
        render json: post_service.mentionable_in_comment(params[:id], params[:q])
      else
        head :no_content
      end
    }
    format.any { head :not_acceptable }
  end
rescue ActiveRecord::RecordNotFound
  head :not_found
end

#oembedObject


35
36
37
38
39
40
41
42
# File 'app/controllers/posts_controller.rb', line 35

def oembed
  post_id = OEmbedPresenter.id_from_url(params.delete(:url))
  post = post_service.find!(post_id)
  oembed = params.slice(:format, :maxheight, :minheight)
  render json: OEmbedPresenter.new(post, oembed)
rescue
  head :not_found
end

#showObject


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

def show
  post = post_service.find!(params[:id])
  post_service.mark_user_notifications(post.id)
  presenter = PostPresenter.new(post, current_user)
  respond_to do |format|
    format.html do
      gon.post = presenter.with_initial_interactions
      render locals: {post: presenter}
    end
    format.mobile { render locals: {post: post} }
    format.json { render json: presenter.with_interactions }
  end
end