panmind-zendesk 1.0.1.3 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +7 -6
- data/Rakefile +5 -5
- data/lib/panmind/zendesk.rb +12 -9
- data/lib/panmind/zendesk/railtie.rb +24 -0
- data/rails/init.rb +2 -5
- metadata +8 -13
- data/lib/panmind/string_force_utf8_patch.rb +0 -29
data/README.md
CHANGED
@@ -13,9 +13,13 @@ and the necessary controller and routing code to implement
|
|
13
13
|
Installation
|
14
14
|
------------
|
15
15
|
|
16
|
-
|
16
|
+
Via RubyGems:
|
17
17
|
|
18
|
-
|
18
|
+
gem install panmind-zendesk
|
19
|
+
|
20
|
+
Or via Rails Plugin:
|
21
|
+
|
22
|
+
rails plugin install git://github.com/Panmind/zendesk.git
|
19
23
|
|
20
24
|
|
21
25
|
Configuration
|
@@ -117,8 +121,7 @@ assets, follow us on GitHub: we plan to release that code as well. :-)
|
|
117
121
|
Compatibility
|
118
122
|
-------------
|
119
123
|
|
120
|
-
Tested with Rails
|
121
|
-
running under Ruby 1.9.1-p378.
|
124
|
+
Tested with Rails 3.0.3 running under Ruby 1.9.2p0.
|
122
125
|
|
123
126
|
|
124
127
|
TODO
|
@@ -128,10 +131,8 @@ TODO
|
|
128
131
|
or redirects to Zendesk won't work: remove relying on this assumption. Cleanly.
|
129
132
|
* Clean up configuration by requiring less variables: *convention over configuration*!
|
130
133
|
* Configuration of the `logged_in?` method name
|
131
|
-
* Remove the `String#force_utf8` patch and its usage
|
132
134
|
* Allow options passing to the `zendesk_dropbox_link_to` helper
|
133
135
|
* Code documentation
|
134
|
-
* Gem
|
135
136
|
* Tests (yuck!)
|
136
137
|
|
137
138
|
Please fork the project and send us a pull request if you check off any of these items
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/rdoctask'
|
3
3
|
|
4
|
-
require 'lib/panmind/zendesk'
|
4
|
+
require './lib/panmind/zendesk'
|
5
5
|
|
6
6
|
begin
|
7
7
|
require 'jeweler'
|
@@ -13,8 +13,8 @@ begin
|
|
13
13
|
'Zendesk dropbox and the necessary controller and routing ' \
|
14
14
|
'code to implement remote authentication'
|
15
15
|
|
16
|
-
gemspec.authors = ['Marcello Barnaba']
|
17
|
-
gemspec.email = '
|
16
|
+
gemspec.authors = ['Fabrizio Regini','Marcello Barnaba']
|
17
|
+
gemspec.email = 'info@panmind.org'
|
18
18
|
gemspec.homepage = 'http://github.com/Panmind/zendesk'
|
19
19
|
|
20
20
|
gemspec.files = %w( README.md Rakefile rails/init.rb ) + Dir['lib/**/*']
|
@@ -22,11 +22,11 @@ begin
|
|
22
22
|
gemspec.has_rdoc = true
|
23
23
|
|
24
24
|
gemspec.version = Panmind::Zendesk::Version
|
25
|
-
gemspec.date = '
|
25
|
+
gemspec.date = '2011-05-16'
|
26
26
|
|
27
27
|
gemspec.require_path = 'lib'
|
28
28
|
|
29
|
-
gemspec.add_dependency('rails', '~>
|
29
|
+
gemspec.add_dependency('rails', '~> 3.0')
|
30
30
|
end
|
31
31
|
rescue LoadError
|
32
32
|
puts 'Jeweler not available. Install it with: gem install jeweler'
|
data/lib/panmind/zendesk.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'digest/md5'
|
2
|
+
require 'panmind/zendesk/railtie' if defined? Rails
|
2
3
|
|
3
4
|
module Panmind
|
4
5
|
# Zendesk remote authentication helper for Rails. Implements JS generation,
|
@@ -12,7 +13,7 @@ module Panmind
|
|
12
13
|
# - vjt Wed Jul 21 13:00:42 CEST 2010
|
13
14
|
#
|
14
15
|
module Zendesk
|
15
|
-
Version =
|
16
|
+
Version = '1.0.2'
|
16
17
|
|
17
18
|
class ConfigurationError < StandardError; end
|
18
19
|
|
@@ -57,8 +58,8 @@ module Panmind
|
|
57
58
|
end
|
58
59
|
|
59
60
|
private
|
60
|
-
def token=(token); @token = token.
|
61
|
-
def hostname=(hostname); @hostname = hostname.freeze
|
61
|
+
def token=(token); @token = token.freeze rescue nil end
|
62
|
+
def hostname=(hostname); @hostname = hostname.freeze end
|
62
63
|
end
|
63
64
|
|
64
65
|
module Helpers
|
@@ -96,7 +97,7 @@ module Panmind
|
|
96
97
|
end
|
97
98
|
|
98
99
|
def zendesk_login
|
99
|
-
name, email = instance_exec(&Zendesk.login)
|
100
|
+
name, email = instance_exec(&Zendesk.login)
|
100
101
|
|
101
102
|
now = params[:timestamp] || Time.now.to_i.to_s
|
102
103
|
hash = Digest::MD5.hexdigest(name + email + Zendesk.token + now)
|
@@ -108,7 +109,7 @@ module Panmind
|
|
108
109
|
'×tamp=' + now,
|
109
110
|
'&hash=' + hash,
|
110
111
|
'&return_to=' + back
|
111
|
-
].join
|
112
|
+
].join
|
112
113
|
|
113
114
|
redirect_to(Zendesk.auth_url + auth_params)
|
114
115
|
end
|
@@ -136,12 +137,14 @@ module Panmind
|
|
136
137
|
end
|
137
138
|
end
|
138
139
|
|
139
|
-
module
|
140
|
-
def zendesk(base, options)
|
140
|
+
module Routing
|
141
|
+
def zendesk(base, options = {})
|
141
142
|
return unless Zendesk.enabled?
|
142
143
|
|
143
|
-
|
144
|
-
|
144
|
+
scope base.to_s, :controller => options[:controller] do
|
145
|
+
get '', :action => :zendesk_login, :as => base.to_sym
|
146
|
+
get 'exit', :action => :zendesk_logout, :as => nil
|
147
|
+
end
|
145
148
|
end
|
146
149
|
end
|
147
150
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'panmind/zendesk'
|
2
|
+
|
3
|
+
module Panmind
|
4
|
+
module Zendesk
|
5
|
+
|
6
|
+
if defined? Rails::Railtie
|
7
|
+
class Railtie < Rails::Railtie
|
8
|
+
initializer 'panmind.zendesk.insert_into_action_view' do
|
9
|
+
ActiveSupport.on_load :action_view do
|
10
|
+
Panmind::Zendesk::Railtie.insert
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Railtie
|
17
|
+
def self.insert
|
18
|
+
ActionView::Base.instance_eval { include Panmind::Zendesk::Helpers }
|
19
|
+
ActionDispatch::Routing::Mapper.instance_eval { include Panmind::Zendesk::Routing }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/rails/init.rb
CHANGED
@@ -1,5 +1,2 @@
|
|
1
|
-
require 'panmind/zendesk'
|
2
|
-
|
3
|
-
|
4
|
-
ActionView::Base.instance_eval { include Panmind::Zendesk::Helpers }
|
5
|
-
ActionController::Routing::RouteSet::Mapper.instance_eval { include Panmind::Zendesk::Routes }
|
1
|
+
require 'panmind/zendesk/railtie'
|
2
|
+
Panmind::Zendesk::Railtie.insert
|
metadata
CHANGED
@@ -1,22 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panmind-zendesk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 93
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 1
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
|
11
|
-
version: 1.0.1.3
|
8
|
+
- 2
|
9
|
+
version: 1.0.2
|
12
10
|
platform: ruby
|
13
11
|
authors:
|
12
|
+
- Fabrizio Regini
|
14
13
|
- Marcello Barnaba
|
15
14
|
autorequire:
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date:
|
18
|
+
date: 2011-05-16 00:00:00 +02:00
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
@@ -27,16 +26,14 @@ dependencies:
|
|
27
26
|
requirements:
|
28
27
|
- - ~>
|
29
28
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 19
|
31
29
|
segments:
|
32
|
-
- 2
|
33
30
|
- 3
|
34
|
-
-
|
35
|
-
version:
|
31
|
+
- 0
|
32
|
+
version: "3.0"
|
36
33
|
type: :runtime
|
37
34
|
version_requirements: *id001
|
38
35
|
description: The plugin implements the HTML generation code for the Zendesk dropbox and the necessary controller and routing code to implement remote authentication
|
39
|
-
email:
|
36
|
+
email: info@panmind.org
|
40
37
|
executables: []
|
41
38
|
|
42
39
|
extensions: []
|
@@ -46,8 +43,8 @@ extra_rdoc_files:
|
|
46
43
|
files:
|
47
44
|
- README.md
|
48
45
|
- Rakefile
|
49
|
-
- lib/panmind/string_force_utf8_patch.rb
|
50
46
|
- lib/panmind/zendesk.rb
|
47
|
+
- lib/panmind/zendesk/railtie.rb
|
51
48
|
- rails/init.rb
|
52
49
|
has_rdoc: true
|
53
50
|
homepage: http://github.com/Panmind/zendesk
|
@@ -63,7 +60,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
60
|
requirements:
|
64
61
|
- - ">="
|
65
62
|
- !ruby/object:Gem::Version
|
66
|
-
hash: 3
|
67
63
|
segments:
|
68
64
|
- 0
|
69
65
|
version: "0"
|
@@ -72,7 +68,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
68
|
requirements:
|
73
69
|
- - ">="
|
74
70
|
- !ruby/object:Gem::Version
|
75
|
-
hash: 3
|
76
71
|
segments:
|
77
72
|
- 0
|
78
73
|
version: "0"
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# Adds a .force_utf8 to the String class: it forces the instance
|
2
|
-
# encoding to utf-8 and then normalizes in NFKC form.
|
3
|
-
#
|
4
|
-
# For now, we're using ActiveSupport because it has proven to be
|
5
|
-
# 33% faster than UnicodeUtils.. but in the future you can never
|
6
|
-
# know whether the AS::Multibyte::Chars class will be supported.
|
7
|
-
#
|
8
|
-
# Please read http://www.cl.cam.ac.uk/~mgk25/unicode.html#ucsutf
|
9
|
-
# for more information about Unicode Normalization Forms.
|
10
|
-
#
|
11
|
-
# - vjt Wed Jul 21 16:51:25 CEST 2010
|
12
|
-
#
|
13
|
-
unless 'the string'.respond_to?(:force_utf8)
|
14
|
-
class String
|
15
|
-
if '1.9'.respond_to?(:force_encoding)
|
16
|
-
#require 'unicode_utils/nfkc'
|
17
|
-
|
18
|
-
def force_utf8
|
19
|
-
#force_encoding('UTF-8')
|
20
|
-
#replace UnicodeUtils.nfkc(self)
|
21
|
-
replace ActiveSupport::Multibyte::Chars.new(self).normalize(:kc)
|
22
|
-
end
|
23
|
-
else
|
24
|
-
def force_utf8
|
25
|
-
replace mb_chars.normalize(:kc)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|