Class: Alchemy::Custom::Model::ElFinder::Volumes::AlchemyImages
- Inherits:
-
AlchemyFile
- Object
- Base
- AlchemyFile
- Alchemy::Custom::Model::ElFinder::Volumes::AlchemyImages
show all
- Defined in:
- lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb
Instance Attribute Summary
Attributes inherited from Base
#id, #name, #root, #url
Instance Method Summary
collapse
Methods inherited from AlchemyFile
#copy, #cwd, #path_info, #pathname, #rm, #upload_max_size_in_bytes
Methods inherited from Base
#contains?, #cwd, #encode, #pathname
#acm_t
Constructor Details
#initialize(options = {root: '/images', name: acm_t("volume",scope:'elfinder.alchemy_images'), id: 'alchemy_library_images', url: '/'}) ⇒ AlchemyImages
Returns a new instance of AlchemyImages.
5
6
7
|
# File 'lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb', line 5
def initialize(options = {root: '/images', name: acm_t("volume",scope:'elfinder.alchemy_images'), id: 'alchemy_library_images', url: '/'})
super
end
|
Instance Method Details
#decode(hash) ⇒ Object
13
14
15
16
17
|
# File 'lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb', line 13
def decode(hash)
super do |path|
Paths::Image.new(@root, path, volume: self)
end
end
|
#disabled_commands ⇒ Object
38
39
40
41
42
|
# File 'lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb', line 38
def disabled_commands
super + ['rm']
end
|
#duplicable?(target) ⇒ Boolean
58
59
60
|
# File 'lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb', line 58
def duplicable?(target)
true
end
|
#duplicate(t) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb', line 44
def duplicate(t)
new_path = Rails.root.join('tmp', "copy_#{File.basename(t.name)}")
::FileUtils.cp(t.file.path, new_path)
img = ::Alchemy::Picture.new(
image_file: new_path
)
img.name = img.humanized_name
img.save
root_path.build_file_path(img)
end
|
#files(target = '.') ⇒ Object
9
10
11
|
# File 'lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb', line 9
def files(target = '.')
super(root_path)
end
|
#root_path ⇒ Object
63
64
65
|
# File 'lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb', line 63
def root_path
Paths::Images.new(@root, '.', volume: self)
end
|
#search(type:, q:) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb', line 30
def search(type:, q:)
super do
search_query_build(klass: ::Alchemy::Picture, type: type, q: q, mime_attribute: :file_mime_type)
end
end
|
#upload(target, upload) ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb', line 19
def upload(target, upload)
super do |file|
img = ::Alchemy::Picture.new(
image_file: file
)
img.name = img.humanized_name
img.save!
root_path.build_file_path(img)
end
end
|