zopim_rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/lib/zopim_rails/chatbox.rb +13 -0
- data/lib/zopim_rails/rails/railtie.rb +12 -0
- data/lib/zopim_rails/rails/view_helpers.rb +21 -0
- data/lib/zopim_rails/version.rb +1 -1
- data/lib/zopim_rails.rb +5 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e4917eea5c0043645dc91bf4d083b9a8becdca9
|
4
|
+
data.tar.gz: 22959e8f4154b95f3bbd1bf057cefd01ebbdfed6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36d809bc138f09b82332dccf891d2433cace69f0982d8199b304d0219329cd59d2a12a0e7f79528b9d70aaa94150631da200aa10993be6c37d5eb8f58b482dc6
|
7
|
+
data.tar.gz: 305c60fa6b1b9562c6d8c0288f1ffaabcff65c27089730e536c587eeef2a8d6b0df3b70ba22826c09bec668836b4248ee7e75e06ca8f312d00c61dc06155741d
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module ZopimRails
|
4
|
+
class Chatbox
|
5
|
+
|
6
|
+
def render_script
|
7
|
+
<<-JAVASCRIPT
|
8
|
+
<script type="text/javascript">window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set._.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');$.src='//v2.zopim.com/?#{ZopimRails.api_key}';z.t=+new Date;$.type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');</script>
|
9
|
+
JAVASCRIPT
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'active_support/core_ext/string/output_safety'
|
4
|
+
require 'active_support/core_ext/object/blank'
|
5
|
+
|
6
|
+
module ZopimRails::Rails
|
7
|
+
|
8
|
+
module ViewHelpers
|
9
|
+
|
10
|
+
def zopim_init
|
11
|
+
|
12
|
+
unless ZopimRails.valid_api_key?
|
13
|
+
raise ArgumentError, "API key for Zopim chat is missing."
|
14
|
+
end
|
15
|
+
|
16
|
+
queue = ZopimRails::Chatbox.new
|
17
|
+
queue.render_script.html_safe
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/zopim_rails/version.rb
CHANGED
data/lib/zopim_rails.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
2
|
+
require 'zopim_rails/chatbox'
|
3
|
+
require 'zopim_rails/rails/railtie'
|
3
4
|
require "zopim_rails/version"
|
4
5
|
|
5
6
|
module ZopimRails
|
@@ -19,9 +20,10 @@ module ZopimRails
|
|
19
20
|
|
20
21
|
# @return [Boolean]
|
21
22
|
def self.valid_api_key?
|
22
|
-
|
23
|
+
api_key.nil? || api_key == "" || api_key == PLACEHOLDER_KEY ? false : true
|
23
24
|
end
|
24
25
|
|
26
|
+
#To be removed
|
25
27
|
def self.render
|
26
28
|
<<-JAVASCRIPT
|
27
29
|
<script type="text/javascript">window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set._.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');$.src='//v2.zopim.com/?#{self.api_key}';z.t=+new Date;$.type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');</script>
|
@@ -32,3 +34,4 @@ module ZopimRails
|
|
32
34
|
end
|
33
35
|
|
34
36
|
end
|
37
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zopim_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wittawas Wisarnkanchana
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -51,6 +51,9 @@ files:
|
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
53
|
- lib/zopim_rails.rb
|
54
|
+
- lib/zopim_rails/chatbox.rb
|
55
|
+
- lib/zopim_rails/rails/railtie.rb
|
56
|
+
- lib/zopim_rails/rails/view_helpers.rb
|
54
57
|
- lib/zopim_rails/version.rb
|
55
58
|
- zopim_rails.gemspec
|
56
59
|
homepage: https://github.com/wittawasw/zopim_rails
|