Class: Admin::Atreides::DropboxController

Inherits:
Atreides::ApplicationController
  • Object
show all
Includes:
DropboxHelper
Defined in:
app/controllers/admin/atreides/dropbox_controller.rb

Instance Method Summary collapse

Instance Method Details

#listObject



20
21
22
23
24
25
26
# File 'app/controllers/admin/atreides/dropbox_controller.rb', line 20

def list
  @dropbox_path = request[:path] || '/'
  ls = dropbox_client.(@dropbox_path)['contents']
  @dirs = ls.select { |item| item['is_dir'] }
  @imgs = ls.select { |item| !item['is_dir'] && item['mime_type'] =~ /image/ }
  @imgs = @imgs.delete_if { |item| ['image/x-icon', 'image/x-photoshop'].include? item['mime_type'] }
end

#thumbObject



28
29
30
31
32
# File 'app/controllers/admin/atreides/dropbox_controller.rb', line 28

def thumb
  @path = request[:path]
  headers['Content-Type'] = 'image/jpeg'
  self.response_body = dropbox_client.thumbnail(URI.escape(@path))
end


15
16
17
18
# File 'app/controllers/admin/atreides/dropbox_controller.rb', line 15

def unlink
  session[:dropbox_session] = nil
  redirect_to(request.referer.gsub(/\?.+/,"?add_content[]=photos"))
end