Class: Ckeditor::AttachmentFile
- Inherits:
-
Asset
- Object
- ActiveRecord::Base
- Asset
- Ckeditor::AttachmentFile
show all
- Defined in:
- lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb,
lib/generators/ckeditor/migration/templates/models/attachment_fu/attachment_file.rb
Instance Method Summary
collapse
Methods inherited from Asset
#content_type, #filename, #format_created_at, #geometry, #has_dimensions?, #image?, #path, #public_filename, #size, #styles, #to_xml
Instance Method Details
#file_name_for(asset = nil) ⇒ Object
20
21
22
23
|
# File 'lib/generators/ckeditor/migration/templates/models/attachment_fu/attachment_file.rb', line 20
def file_name_for(asset = nil)
extension = filename.scan(/\.\w+$/)
return "#{asset}_#{filename}"
end
|
#full_filename(thumbnail = nil) ⇒ Object
15
16
17
18
|
# File 'lib/generators/ckeditor/migration/templates/models/attachment_fu/attachment_file.rb', line 15
def full_filename(thumbnail = nil)
file_system_path = self.attachment_options[:path_prefix]
Rails.root.join(file_system_path, file_name_for(self.id))
end
|
#swf_uploaded_data=(data) ⇒ Object
10
11
12
13
|
# File 'lib/generators/ckeditor/migration/templates/models/attachment_fu/attachment_file.rb', line 10
def swf_uploaded_data=(data)
data.content_type = MIME::Types.type_for(data.original_filename)
self.uploaded_data = data
end
|
#to_json(options = {}) ⇒ Object
34
35
36
37
38
39
|
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb', line 34
def to_json(options = {})
options[:methods] ||= []
options[:methods] << :url_content
options[:methods] << :url_thumb
super options
end
|
#url(*args) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb', line 8
def url(*args)
if [:thumb, :content].include?(args.first)
send("url_#{args.first}")
else
data.url(*args)
end
end
|
#url_content ⇒ Object
16
17
18
|
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb', line 16
def url_content
data.url
end
|
#url_thumb ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb', line 20
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
|