Sha256: f1e1d7d6fc471d3428ba611af3135bfd6d7aeeee9090edf3c6ea9fee22cd39e8

Contents?: true

Size: 1.16 KB

Versions: 28

Compression:

Stored size: 1.16 KB

Contents

class Ckeditor::AttachmentFile < Ckeditor::Asset
  has_attached_file :data,
                    :url => "/ckeditor_assets/attachments/:id/:filename",
                    :path => ":rails_root/public/ckeditor_assets/attachments/:id/:filename"
  
  validates_attachment_size :data, :less_than=>100.megabytes
  
  def url(*args)
    if [:thumb, :content].include?(args.first)
      send("url_#{args.first}")
    else
      data.url(*args)
    end
  end
  
  def url_content
	  data.url
	end
	
	def url_thumb
	  extname = File.extname(filename)
    
    case extname.to_s
      when '.swf' then '/javascripts/ckeditor/images/swf.gif'
      when '.pdf' then '/javascripts/ckeditor/images/pdf.gif'
      when '.doc', '.txt' then '/javascripts/ckeditor/images/doc.gif'
      when '.mp3' then '/javascripts/ckeditor/images/mp3.gif'
      when '.rar', '.zip', '.tg' then '/javascripts/ckeditor/images/rar.gif'
      when '.xls' then '/javascripts/ckeditor/images/xls.gif'
      else '/javascripts/ckeditor/images/ckfnothumb.gif'
    end
	end
	
	def to_json(options = {})
	  options[:methods] ||= []
	  options[:methods] << :url_content
	  options[:methods] << :url_thumb
	  super options
  end
end

Version data entries

28 entries across 28 versions & 6 rubygems

Version Path
deluxe_publisher-0.0.6 app/models/ckeditor/attachment_file.rb
deluxe_publisher-0.0.5 app/models/ckeditor/attachment_file.rb
deluxe_publisher-0.0.4 app/models/ckeditor/attachment_file.rb
deluxe_publisher-0.0.3 app/models/ckeditor/attachment_file.rb
ckeditor-3.5.4 lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb
ckeditor-3.5.3 lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb
ckeditor-3.5.2 lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb
ckeditor-3.5.1 lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb
dust-ckeditor-3.5.0 lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb
hifi-ckeditor-3.5.2 lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb
hifi-ckeditor-3.5.1 lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb
artemk-ckeditor-3.5.5 generators/ckeditor_migration/templates/models/paperclip/attachment_file.rb
ckeditor-jess-3.4.3 generators/ckeditor_migration/templates/models/paperclip/attachment_file.rb
ckeditor-3.5.0 lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb
artemk-ckeditor-3.5.4 generators/ckeditor_migration/templates/models/paperclip/attachment_file.rb
artemk-ckeditor-3.4.4 generators/ckeditor_migration/templates/models/paperclip/attachment_file.rb
artemk-ckeditor-3.4.3 generators/ckeditor_migration/templates/models/paperclip/attachment_file.rb
ckeditor-3.4.3.pre lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb
ckeditor-3.4.3 generators/ckeditor_migration/templates/models/paperclip/attachment_file.rb
ckeditor-3.4.2.pre lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb