Module: Panmind::Zendesk
- Defined in:
- lib/panmind/zendesk.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, Routes Classes: ConfigurationError
Constant Summary collapse
- Version =
1.0
Class Attribute Summary collapse
-
.assets_name ⇒ Object
TODO these should become attr_readers and we set @variables directly.
-
.assets_path ⇒ Object
TODO these should become attr_readers and we set @variables directly.
-
.dropbox ⇒ Object
TODO these should become attr_readers and we set @variables directly.
-
.hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
.login ⇒ Object
TODO these should become attr_readers and we set @variables directly.
-
.login_url ⇒ Object
TODO these should become attr_readers and we set @variables directly.
-
.token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
- .auth_url ⇒ Object
- .enabled? ⇒ Boolean
- .return_url ⇒ Object
- .set(options) ⇒ Object
- .support_url ⇒ Object
Class Attribute Details
.assets_name ⇒ Object
TODO these should become attr_readers and we set @variables directly
27 28 29 |
# File 'lib/panmind/zendesk.rb', line 27 def assets_name @assets_name end |
.assets_path ⇒ Object
TODO these should become attr_readers and we set @variables directly
27 28 29 |
# File 'lib/panmind/zendesk.rb', line 27 def assets_path @assets_path end |
.dropbox ⇒ Object
TODO these should become attr_readers and we set @variables directly
27 28 29 |
# File 'lib/panmind/zendesk.rb', line 27 def dropbox @dropbox end |
.hostname ⇒ Object
Returns the value of attribute hostname.
20 21 22 |
# File 'lib/panmind/zendesk.rb', line 20 def hostname @hostname end |
.login ⇒ Object
TODO these should become attr_readers and we set @variables directly
27 28 29 |
# File 'lib/panmind/zendesk.rb', line 27 def login @login end |
.login_url ⇒ Object
TODO these should become attr_readers and we set @variables directly
27 28 29 |
# File 'lib/panmind/zendesk.rb', line 27 def login_url @login_url end |
.token ⇒ Object
Returns the value of attribute token.
20 21 22 |
# File 'lib/panmind/zendesk.rb', line 20 def token @token end |
Class Method Details
.auth_url ⇒ Object
22 |
# File 'lib/panmind/zendesk.rb', line 22 def auth_url; @auth_url ||= "http://#{hostname}/access/remote/".freeze end |
.enabled? ⇒ Boolean
51 52 53 |
# File 'lib/panmind/zendesk.rb', line 51 def enabled? Rails.env.production? end |
.return_url ⇒ Object
23 |
# File 'lib/panmind/zendesk.rb', line 23 def return_url; @return_url ||= "http://#{hostname}/login".freeze end |
.set(options) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/panmind/zendesk.rb', line 29 def set() self.token, self.hostname, self.login, self.login_url = .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 self.dropbox = ([:dropbox] || {}).reverse_merge( :tab_id => 'feedback', :tab_color => 'black', :title => 'Support', :text => "How may we help you? Please fill in details below, and we'll get back to you as soon as possible.", :url => Zendesk.hostname ).freeze # TODO better configuration self.assets_path = [:assets_path] || '//assets0.zendesk.com/external/zenbox' self.assets_name = [:assets_name] || 'overlay' end |
.support_url ⇒ Object
24 |
# File 'lib/panmind/zendesk.rb', line 24 def support_url; @support_url ||= "http://#{hostname}/home".freeze end |