Sha256: a109e6c15e97ba1c70e6046fbb96f11b4b5dbdfdb14b502e85f61d55ae68130b

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

class Muck::TinyMceController < ApplicationController
  
  layout 'tiny_mce'
  
  before_filter :get_parent
  
  def tiny_mce_files
    @body_tag = 'advfile'
    @load_files_path = files_for_content_url(make_parent_params(@parent).merge(:format => 'json'))
    respond_to do |format|
      format.html { render :template => 'tiny_mce/files'}
    end
  end
  
  def tiny_mce_images
    @body_tag = 'advimage'
    @load_files_path = images_for_content_url(make_parent_params(@parent).merge(:format => 'json'))
    respond_to do |format|
      format.html { render :template => 'tiny_mce/images'}
    end
  end
  
  def tiny_mce_links
    @body_tag = 'advlink'
    @load_files_path = files_for_content_url(make_parent_params(@parent).merge(:format => 'json'))
    respond_to do |format|
      format.html { render :template => 'tiny_mce/links'}
    end
  end
  
  def images_for_content
    @parent = current_user if @parent.blank?
    @images = @parent.uploads.images.paginate(:page => @page, :per_page => @per_page, :order => 'created_at desc')
    respond_to do |format|
      format.json { render :json => make_json(@images) }
    end
  end
  
  def files_for_content
    @parent = current_user if @parent.blank?
    @files = @parent.uploads.files.paginate(:page => @page, :per_page => @per_page, :order => 'created_at desc')
    respond_to do |format|
      format.json { render :json => make_json(@files) }
    end
  end

  protected
    def make_json(uploads)
      return [] if uploads.blank?
      uploads.collect {|f| f.as_json(json_options)}
    end
  
    def json_options
      { :only => [:id], :methods => [:icon, :thumb, :file_name] }
    end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
muck-contents-0.2.6 app/controllers/muck/tiny_mce_controller.rb
muck-contents-0.2.5 app/controllers/muck/tiny_mce_controller.rb
muck-contents-0.2.4 app/controllers/muck/tiny_mce_controller.rb