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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d79c37f74c305dac432eda99b48e3aef685df27
4
- data.tar.gz: e820408788e33fb70bc4a4248a689b404ef741d3
3
+ metadata.gz: 2e4917eea5c0043645dc91bf4d083b9a8becdca9
4
+ data.tar.gz: 22959e8f4154b95f3bbd1bf057cefd01ebbdfed6
5
5
  SHA512:
6
- metadata.gz: 87c233f41023ff63184d1a402d7dbafffe9c5123745a2fdb4e670e552d0bdcb70c05e7f42e025d12a92f441693563e5cff6e04a278dc241ee83d3d05fb6008f7
7
- data.tar.gz: 3432ef3b0a80f8d2749d69c57dee8febf0208ec59dc214812d94e04260438cbc086d079c0946b650c75cf2d7af43ea11271d62d6e0b17a733b5141a0b3519936
6
+ metadata.gz: 36d809bc138f09b82332dccf891d2433cace69f0982d8199b304d0219329cd59d2a12a0e7f79528b9d70aaa94150631da200aa10993be6c37d5eb8f58b482dc6
7
+ data.tar.gz: 305c60fa6b1b9562c6d8c0288f1ffaabcff65c27089730e536c587eeef2a8d6b0df3b70ba22826c09bec668836b4248ee7e75e06ca8f312d00c61dc06155741d
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ *.DS_Store
data/README.md CHANGED
@@ -24,7 +24,7 @@ place your API key in application.rb
24
24
 
25
25
  place render method where you want in view.
26
26
 
27
- <%= ZompimRails.init %>
27
+ <%= zopim_init %>
28
28
 
29
29
  ## Contributing
30
30
 
@@ -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,12 @@
1
+ # coding: utf-8
2
+
3
+ require 'zopim_rails/rails/view_helpers'
4
+
5
+ module ZopimRails::Rails
6
+ # @private
7
+ class Railtie < ::Rails::Railtie
8
+ initializer "zopim_rails" do
9
+ ActionView::Base.send :include, ViewHelpers
10
+ end
11
+ end
12
+ 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
@@ -1,3 +1,3 @@
1
1
  module ZopimRails
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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
- !api_key.blank? || api_key == PLACEHOLDER_KEY ? false : true
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.1
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-12 00:00:00.000000000 Z
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