class Alchemy::Custom::Model::ElFinder::Volumes::AlchemyImages

Public Class Methods

new(options = {root: '/images', name: acm_t("volume",scope:'elfinder.alchemy_images'), id: 'alchemy_library_images', url: '/'}) click to toggle source
# 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

Public Instance Methods

decode(hash) click to toggle source
# 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() click to toggle source
Calls superclass method
# File lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb, line 38
def disabled_commands

  super + ['rm']

end
duplicable?(target) click to toggle source
# File lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb, line 58
def duplicable?(target)
  true
end
duplicate(t) click to toggle source
# 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 = '.') click to toggle source
# File lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb, line 9
def files(target = '.')
  super(root_path)
end
root_path() click to toggle source
# File lib/alchemy/custom/model/el_finder/volumes/alchemy_images.rb, line 63
def root_path
  Paths::Images.new(@root, '.', volume: self)
end
upload(target, upload) click to toggle source
# 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