Module: Panmind::Zendesk

Defined in:
lib/panmind/zendesk.rb,
lib/panmind/zendesk/railtie.rb

Overview

Zendesk remote authentication helper for Rails. Implements JS generation, controller actions and route helpers. Have a look at the code, because it is more explanatory than a thousand words :-)

Kudos to the Zendesk staff for such a simple and effective interface.

© 2010 Panmind, Released under the terms of the Ruby License.

- vjt  Wed Jul 21 13:00:42 CEST 2010

Defined Under Namespace

Modules: Controller, Helpers, Routing Classes: ConfigurationError, Railtie

Constant Summary collapse

Version =
'1.1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.css_asset_nameObject

TODO these should become attr_readers and we set @variables directly



28
29
30
# File 'lib/panmind/zendesk.rb', line 28

def css_asset_name
  @css_asset_name
end

.css_asset_pathObject

TODO these should become attr_readers and we set @variables directly



28
29
30
# File 'lib/panmind/zendesk.rb', line 28

def css_asset_path
  @css_asset_path
end

.dropboxObject

TODO these should become attr_readers and we set @variables directly



28
29
30
# File 'lib/panmind/zendesk.rb', line 28

def dropbox
  @dropbox
end

.hostnameObject

Returns the value of attribute hostname.



21
22
23
# File 'lib/panmind/zendesk.rb', line 21

def hostname
  @hostname
end

.js_asset_nameObject

TODO these should become attr_readers and we set @variables directly



28
29
30
# File 'lib/panmind/zendesk.rb', line 28

def js_asset_name
  @js_asset_name
end

.js_asset_pathObject

TODO these should become attr_readers and we set @variables directly



28
29
30
# File 'lib/panmind/zendesk.rb', line 28

def js_asset_path
  @js_asset_path
end

.loginObject

TODO these should become attr_readers and we set @variables directly



28
29
30
# File 'lib/panmind/zendesk.rb', line 28

def 
  @login
end

.login_urlObject

TODO these should become attr_readers and we set @variables directly



28
29
30
# File 'lib/panmind/zendesk.rb', line 28

def 
  @login_url
end

.tokenObject

Returns the value of attribute token.



21
22
23
# File 'lib/panmind/zendesk.rb', line 21

def token
  @token
end

Class Method Details

.auth_urlObject



23
# File 'lib/panmind/zendesk.rb', line 23

def auth_url;    @auth_url    ||= "http://#{hostname}/access/remoteauth/".freeze end

.enabled?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/panmind/zendesk.rb', line 56

def enabled?
  Rails.env.production? || Rails.env.development? 
end

.return_urlObject



24
# File 'lib/panmind/zendesk.rb', line 24

def return_url;  @return_url  ||= "http://#{hostname}/login".freeze          end

.set(options) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/panmind/zendesk.rb', line 30

def set(options)
  self.token, self.hostname, self., self. =
    options.values_at(:token, :hostname, :login, :login_url)

  if %w( token hostname login login_url ).any? {|conf| send(conf).blank?}
    raise ConfigurationError, "Zendesk requires the API token, an hostname a proc to infer the user name "\
                              "and e-mail and the login route helper name" # TODO don't require all these things
  end

  if options[:dropbox].nil? or options[:dropbox][:dropboxID].blank? 
    raise ConfigurationError, "DropboxID is a required param in zenbox-2.0. Please configure options[:dropbox][:dropboxID]."
  end 

  # Dropbox specific customizations, defaults in place
  self.dropbox = (options[:dropbox] || {}).reverse_merge(
    :tabID       => 'feedback',
    :url         => Zendesk.hostname
  ).freeze

  # Path and name for css and asset required for zenbox 2.0
  self.js_asset_path  = options[:js_asset_path]  || '//assets0.zendesk.com/external/zenbox'
  self.js_asset_name  = options[:js_asset_name]  || 'zenbox-2.0'
  self.css_asset_path = options[:css_asset_path] || '//assets0.zendesk.com/external/zenbox'
  self.css_asset_name = options[:css_asset_name] || 'zenbox-2.0'
end

.support_urlObject



25
# File 'lib/panmind/zendesk.rb', line 25

def support_url; @support_url ||= "http://#{hostname}/home".freeze           end