Module: Admin::Atreides::DropboxHelper
- Includes:
- Atreides::Extendable
- Included in:
- DropboxController, PhotosController
- Defined in:
- app/helpers/admin/atreides/dropbox_helper.rb
Instance Method Summary collapse
- #basename(path) ⇒ Object
- #dropbox_authorize_link ⇒ Object
- #dropbox_client ⇒ Object
- #dropbox_session ⇒ Object
- #new_dropbox_session ⇒ Object
Instance Method Details
#basename(path) ⇒ Object
37 38 39 |
# File 'app/helpers/admin/atreides/dropbox_helper.rb', line 37 def basename(path) path.sub(@dropbox_path, '').sub(/^\//, '') end |
#dropbox_authorize_link ⇒ Object
33 34 35 |
# File 'app/helpers/admin/atreides/dropbox_helper.rb', line 33 def dropbox_session.(request.url) end |
#dropbox_client ⇒ Object
20 21 22 |
# File 'app/helpers/admin/atreides/dropbox_helper.rb', line 20 def dropbox_client DropboxClient.new(dropbox_session, :dropbox) if dropbox_session. end |
#dropbox_session ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/admin/atreides/dropbox_helper.rb', line 2 def dropbox_session @dropbox_session ||= begin previous = session[:dropbox_session] if session[:dropbox_session].present? if previous && previous. previous elsif previous && params[:oauth_token] puts "Trying to authorize an existing dropbox session..." previous.get_access_token session[:dropbox_session] = previous # re-serialize the authenticated session else puts "Creating a new Dropbox session..." new_dropbox_session.tap do |dropbox_session| session[:dropbox_session] = dropbox_session end end end end |