Sha256: b2707d9ebdb9c801f9cad7f5e6fb356381bd15adf5e3d724be284f222cf2dc5b

Contents?: true

Size: 1.65 KB

Versions: 20

Compression:

Stored size: 1.65 KB

Contents

class DocumentsController < ApplicationController
  include SocialStream::Controllers::Objects

  before_filter :profile_subject!, :only => :index

  def index
    respond_to do |format|
      format.html {
        collection

        if params[:no_layout].present?
          render :layout => false
        end
      }

      format.json { render :json => collection }
    end
  end
  
  def create
    super do |format|
      format.json { render :json => resource }
      format.js
      format.all {redirect_to request.referer || home_path}
    end
  end

  def update
    update! do |success, failure|
      failure.html { render :action => :show }
      success.html { render :action => :show }
    end
  end

  def show
    respond_to do |format|
      format.json {render :json => resource }
      format.html {render :action => :show}
      format.any {
        path = resource.file.path(params[:style] || params[:format])

        head(:not_found) and return unless File.exist?(path)

        send_file path,
                 :filename => resource.file_file_name,
                 :disposition => "inline",
                 :type => request.format
      }
    end
  end

  #TODO: we have to add the mimetype as in videos_controller
  def download
    path = @document.file.path(params[:style])

    head(:not_found) and return unless File.exist?(path)

    send_file_options = {
      :filename => @document.file_file_name,
      :type => @document.file_content_type
    }

    send_file(path, send_file_options)
  end

  private

  def allowed_params
    [:file]
  end

  class << self
    def index_object_type
      [ :Audio, :Video, :Picture, :Document ]
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
social_stream-1.1.12 documents/app/controllers/documents_controller.rb
social_stream-documents-1.1.4 app/controllers/documents_controller.rb
social_stream-1.1.11 documents/app/controllers/documents_controller.rb
social_stream-documents-1.1.3 app/controllers/documents_controller.rb
social_stream-1.1.10 documents/app/controllers/documents_controller.rb
social_stream-documents-1.1.2 app/controllers/documents_controller.rb
social_stream-1.1.9 documents/app/controllers/documents_controller.rb
social_stream-1.1.8 documents/app/controllers/documents_controller.rb
social_stream-1.1.7 documents/app/controllers/documents_controller.rb
social_stream-1.1.6 documents/app/controllers/documents_controller.rb
social_stream-1.1.5 documents/app/controllers/documents_controller.rb
social_stream-1.1.4 documents/app/controllers/documents_controller.rb
social_stream-documents-1.1.1 app/controllers/documents_controller.rb
social_stream-1.1.3 documents/app/controllers/documents_controller.rb
social_stream-1.1.2 documents/app/controllers/documents_controller.rb
social_stream-1.1.1 documents/app/controllers/documents_controller.rb
social_stream-1.1.0 documents/app/controllers/documents_controller.rb
social_stream-documents-1.1.0 app/controllers/documents_controller.rb
social_stream-1.0.1 documents/app/controllers/documents_controller.rb
social_stream-documents-1.0.0 app/controllers/documents_controller.rb