tawk_rails 1.0.2 → 1.2.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +10 -4
- data/lib/tawk_rails/chatbox.rb +5 -2
- data/lib/tawk_rails/rails/view_helpers.rb +2 -7
- data/lib/tawk_rails/version.rb +1 -1
- data/spec/tawk_rails/chatbox_spec.rb +12 -2
- data/spec/tawk_rails/configuration_spec.rb +1 -3
- data/spec/tawk_rails/version_spec.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b16a7692773500ca09d11f5f7a0c9d5815ee756e
|
4
|
+
data.tar.gz: 8def385ff13ab3528d3e5ab1e71907e82f096d28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f2cffa58cfa96fb106c86d3aeb2e503ecb8a78b7137a6414e0eca56538a5781335cf5d8b6debdd0b7abaf7609b953d29857dfb0c28cb6c4754e86a5ed879ede
|
7
|
+
data.tar.gz: f37ac24a8e7232d12636ef7e56985a3424ec53e5126b69b63a966054c4ca25f46a65299aded3c1eb27db50e42c3cd581876e756eaac0f6dee0df60f928a2b265
|
data/.travis.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
language: ruby
|
data/README.md
CHANGED
@@ -20,16 +20,22 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
Create file `tawk.rb` in `config/
|
23
|
+
Create file `tawk.rb` in `config/initializers/tawk.rb` and add
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
```ruby
|
26
|
+
TawkRails.configure do |config|
|
27
|
+
config.id_site = 'replace-me-with-your-id_site'
|
28
|
+
end
|
29
|
+
```
|
28
30
|
|
29
31
|
place render method where you want in view.
|
30
32
|
|
31
33
|
<%= tawk_init %>
|
32
34
|
|
35
|
+
you can pass js methods as string to the helper https://www.tawk.to/javascript-api/
|
36
|
+
|
37
|
+
<%= tawk_init "Tawk_API.onStatusChange = function(status){console.log(status);}; Tawk_API.visitor = {name : 'Name', email : 'email@email.com'};" %>
|
38
|
+
|
33
39
|
## Contributing
|
34
40
|
|
35
41
|
1. Fork it ( https://github.com/luizpicolo/tawk_rails/fork )
|
data/lib/tawk_rails/chatbox.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
3
2
|
module TawkRails
|
4
3
|
class Chatbox
|
4
|
+
def initialize(params = nil)
|
5
|
+
@params = params
|
6
|
+
end
|
7
|
+
|
5
8
|
def render_script
|
6
9
|
<<-JAVASCRIPT
|
7
|
-
<script type="text/javascript">window.$_Tawk = undefined; var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date()
|
10
|
+
<script type="text/javascript">window.$_Tawk = undefined; var Tawk_API=Tawk_API||{}, Tawk_LoadStart=new Date();#{@params}(function(){var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];s1.async=true;s1.src='https://embed.tawk.to/#{TawkRails.configuration.id_site}/default';s1.charset='UTF-8';s1.setAttribute('crossorigin','*');s0.parentNode.insertBefore(s1,s0);})();</script>
|
8
11
|
JAVASCRIPT
|
9
12
|
end
|
10
13
|
end
|
@@ -1,17 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
3
2
|
require 'active_support/core_ext/string/output_safety'
|
4
3
|
require 'active_support/core_ext/object/blank'
|
5
4
|
|
6
5
|
module TawkRails::Rails
|
7
|
-
|
8
6
|
module ViewHelpers
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
queue = TawkRails::Chatbox.new
|
7
|
+
def tawk_init(params = nil)
|
8
|
+
queue = TawkRails::Chatbox.new(params)
|
13
9
|
queue.render_script.html_safe
|
14
|
-
|
15
10
|
end
|
16
11
|
end
|
17
12
|
end
|
data/lib/tawk_rails/version.rb
CHANGED
@@ -9,10 +9,20 @@ describe TawkRails::Chatbox do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
it "should return javascript correctly within params" do
|
13
|
+
chatbox = TawkRails::Chatbox.new()
|
14
|
+
expect(chatbox.render_script).to be_a_kind_of(String)
|
15
|
+
end
|
13
16
|
|
14
|
-
it "should return javascript correctly" do
|
17
|
+
it "should return javascript correctly with params" do
|
18
|
+
params = "Tawk_API.onStatusChange = function(status){console.log(status);}; Tawk_API.visitor = {name : 'Name', email : 'email@email.com'};"
|
19
|
+
chatbox = TawkRails::Chatbox.new(params)
|
15
20
|
expect(chatbox.render_script).to be_a_kind_of(String)
|
21
|
+
expect(chatbox.render_script).to include(params)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return JS within version" do
|
25
|
+
chatbox = TawkRails::Chatbox.new()
|
16
26
|
expect(chatbox.render_script).to include('replace-me-with-your-id_site')
|
17
27
|
end
|
18
28
|
end
|
@@ -2,7 +2,6 @@ require 'spec_helper'
|
|
2
2
|
require_relative '../../lib/tawk_rails/configuration'
|
3
3
|
|
4
4
|
describe TawkRails::Configuration do
|
5
|
-
|
6
5
|
before do
|
7
6
|
TawkRails.configure do |config|
|
8
7
|
config.id_site = 'replace-me-with-your-id_site'
|
@@ -16,7 +15,6 @@ describe TawkRails::Configuration do
|
|
16
15
|
|
17
16
|
it "should return version correctly" do
|
18
17
|
expect(TawkRails.configuration.version).to be_a_kind_of(String)
|
19
|
-
expect(TawkRails.configuration.version).to eq '
|
18
|
+
expect(TawkRails.configuration.version).to eq '1.2.0'
|
20
19
|
end
|
21
|
-
|
22
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tawk_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luiz Picolo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -61,6 +61,7 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- ".gitignore"
|
63
63
|
- ".rspec"
|
64
|
+
- ".travis.yml"
|
64
65
|
- Gemfile
|
65
66
|
- LICENSE.txt
|
66
67
|
- README.md
|