arborist_chat_rails 0.3.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 +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +77 -0
- data/README.md +24 -0
- data/Rakefile +10 -0
- data/arborist_chat_rails.gemspec +33 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/arborist_chat_rails.rb +6 -0
- data/lib/arborist_chat_rails/install_generator.rb +35 -0
- data/lib/arborist_chat_rails/railtie.rb +35 -0
- data/lib/arborist_chat_rails/tags_helper.rb +42 -0
- data/lib/arborist_chat_rails/version.rb +3 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ec07aaa2050ba8a2d708b2583528dee15c56cefd6312af6330920cf3a2b296a4
|
4
|
+
data.tar.gz: 26bc881711d43a51af13fae4e5173b6dbb2b43c6e36d12bd55689093345bb986
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e3e567e11899577f2b01c5c019b167bfb20b028bd62aade1d77f1ba6576cc6e6682b500dd49211364951de0ec160dbc428ca0aeb07d5520f7c41a784cdefc19b
|
7
|
+
data.tar.gz: cdcc2cdb2fc21d392db9199855abb167b81569b255b350781fe58574a07da14572a45289232af6049524c083c9fc82639aee75395c6a6b7dddecdf27120ec420
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
File without changes
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
arborist_chat_rails (0.3.0)
|
5
|
+
actionview (> 5.0)
|
6
|
+
activesupport (> 5.0)
|
7
|
+
jwt (> 2.0)
|
8
|
+
railties (> 3.0)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actionpack (6.0.3.2)
|
14
|
+
actionview (= 6.0.3.2)
|
15
|
+
activesupport (= 6.0.3.2)
|
16
|
+
rack (~> 2.0, >= 2.0.8)
|
17
|
+
rack-test (>= 0.6.3)
|
18
|
+
rails-dom-testing (~> 2.0)
|
19
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
20
|
+
actionview (6.0.3.2)
|
21
|
+
activesupport (= 6.0.3.2)
|
22
|
+
builder (~> 3.1)
|
23
|
+
erubi (~> 1.4)
|
24
|
+
rails-dom-testing (~> 2.0)
|
25
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
26
|
+
activesupport (6.0.3.2)
|
27
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
28
|
+
i18n (>= 0.7, < 2)
|
29
|
+
minitest (~> 5.1)
|
30
|
+
tzinfo (~> 1.1)
|
31
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
32
|
+
builder (3.2.4)
|
33
|
+
concurrent-ruby (1.1.6)
|
34
|
+
crass (1.0.6)
|
35
|
+
erubi (1.9.0)
|
36
|
+
i18n (1.8.5)
|
37
|
+
concurrent-ruby (~> 1.0)
|
38
|
+
jwt (2.2.1)
|
39
|
+
loofah (2.6.0)
|
40
|
+
crass (~> 1.0.2)
|
41
|
+
nokogiri (>= 1.5.9)
|
42
|
+
method_source (1.0.0)
|
43
|
+
mini_portile2 (2.4.0)
|
44
|
+
minitest (5.14.1)
|
45
|
+
nokogiri (1.10.10)
|
46
|
+
mini_portile2 (~> 2.4.0)
|
47
|
+
rack (2.2.3)
|
48
|
+
rack-test (1.1.0)
|
49
|
+
rack (>= 1.0, < 3)
|
50
|
+
rails-dom-testing (2.0.3)
|
51
|
+
activesupport (>= 4.2.0)
|
52
|
+
nokogiri (>= 1.6)
|
53
|
+
rails-html-sanitizer (1.3.0)
|
54
|
+
loofah (~> 2.3)
|
55
|
+
railties (6.0.3.2)
|
56
|
+
actionpack (= 6.0.3.2)
|
57
|
+
activesupport (= 6.0.3.2)
|
58
|
+
method_source
|
59
|
+
rake (>= 0.8.7)
|
60
|
+
thor (>= 0.20.3, < 2.0)
|
61
|
+
rake (13.0.1)
|
62
|
+
thor (1.0.1)
|
63
|
+
thread_safe (0.3.6)
|
64
|
+
tzinfo (1.2.7)
|
65
|
+
thread_safe (~> 0.1)
|
66
|
+
zeitwerk (2.4.0)
|
67
|
+
|
68
|
+
PLATFORMS
|
69
|
+
ruby
|
70
|
+
|
71
|
+
DEPENDENCIES
|
72
|
+
arborist_chat_rails!
|
73
|
+
minitest (> 5.0)
|
74
|
+
rake (> 12.0)
|
75
|
+
|
76
|
+
BUNDLED WITH
|
77
|
+
2.1.4
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Arborist Rails
|
2
|
+
adds arborists live chat widget to your rails app
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
```ruby
|
8
|
+
gem 'arborist-rails'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then run:
|
12
|
+
- `bundle install`
|
13
|
+
- `bin/rails g arborist-rails:install --app_id=<app_id> --app_secret=<app_secret>`
|
14
|
+
|
15
|
+
## Development
|
16
|
+
|
17
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
18
|
+
|
19
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/arborist-software/arborist-rails.
|
24
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# require_relative %q{lib/arborist_chat_rails/version}
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.authors = %w{Leon Pearce}
|
5
|
+
spec.description = %q{adds Arborist live chat to your web app}
|
6
|
+
spec.email = %w{leonp1991@gmail.com}
|
7
|
+
spec.homepage = %q{http://github.com/arborist-software/arborist-chat-rails}
|
8
|
+
spec.name = %q{arborist_chat_rails}
|
9
|
+
spec.required_ruby_version = Gem::Requirement.new(%q{>= 2.3.0})
|
10
|
+
spec.summary = %q{adds Arborist live chat to your web app}
|
11
|
+
spec.version = %q{0.3.0} # ArboristChatRails::VERSION
|
12
|
+
|
13
|
+
spec.metadata.store %q{allowed_push_host}, %q{https://rubygems.org}
|
14
|
+
spec.metadata.store %q{changelog_uri}, %q{http://github.com/arborist-software/arborist-chat-rails/CHANGELOG.md}
|
15
|
+
spec.metadata.store %q{homepage_uri}, spec.homepage
|
16
|
+
spec.metadata.store %q{source_code_uri}, %q{http://github.com/arborist-software/arborist-chat-rails}
|
17
|
+
|
18
|
+
# specify which files should be added to the gem when it is released.
|
19
|
+
# the `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path(%q{..}, __FILE__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.add_dependency %q{actionview}, %q{> 5.0}
|
25
|
+
spec.add_dependency %q{activesupport}, %q{> 5.0}
|
26
|
+
spec.add_dependency %q{jwt}, %q{> 2.0}
|
27
|
+
spec.add_dependency %q{railties}, %q{> 3.0}
|
28
|
+
|
29
|
+
|
30
|
+
spec.bindir = %q{exe}
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = %w[lib]
|
33
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require %q{bundler/setup}
|
4
|
+
require %q{arborist-rails}
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require %q{irb}
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require %q{rails/generators}
|
2
|
+
|
3
|
+
class ArboristChatRails::InstallGenerator < Rails::Generators::Base
|
4
|
+
APP_ID = %q{app_id}
|
5
|
+
APP_SECRET = %q{app_secret}
|
6
|
+
|
7
|
+
class_option APP_ID,
|
8
|
+
default: %q{APP_ID},
|
9
|
+
desc: %q{You application ID},
|
10
|
+
type: :string
|
11
|
+
|
12
|
+
class_option APP_SECRET,
|
13
|
+
default: %q{APP_SECRET},
|
14
|
+
desc: %q{Your application secret},
|
15
|
+
type: :string
|
16
|
+
|
17
|
+
def create_initializer
|
18
|
+
initializer %q{arborist.rb}, <<~FILE
|
19
|
+
Rails.application.configure do
|
20
|
+
# specifies which product in arborist to connect
|
21
|
+
# the rails application to
|
22
|
+
config.arborist.app_id = '#{options.dig(APP_ID)}'
|
23
|
+
config.arborist.app_secret = '#{options.dig(APP_SECRET)}'
|
24
|
+
|
25
|
+
# used to resolve which fields to send to
|
26
|
+
# arborist to identify a user
|
27
|
+
config.arborist.current_user = lambda do
|
28
|
+
current_user&.as_json(only: %i[email id]) || begin
|
29
|
+
{ id: session[:arborist_id] ||= SecureRandom.uuid }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
FILE
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
class ArboristChatRails::Railtie < Rails::Railtie
|
4
|
+
railtie_name :arborist
|
5
|
+
|
6
|
+
config.arborist = ActiveSupport::OrderedOptions.new
|
7
|
+
|
8
|
+
generators do
|
9
|
+
require %q{arborist/install_generator.rb}
|
10
|
+
end
|
11
|
+
|
12
|
+
initializer %q{arborist} do |app|
|
13
|
+
app.config.arborist.dev_mode ||= false
|
14
|
+
|
15
|
+
ActiveSupport.on_load :action_controller do
|
16
|
+
include ::ArboristChatRails::TagsHelper
|
17
|
+
|
18
|
+
after_action :include_arborist_livechat
|
19
|
+
define_method :include_arborist_livechat do
|
20
|
+
next unless response.media_type == %q{text/html}
|
21
|
+
|
22
|
+
widget = arborist_widget_tag(app.config.arborist).to_s
|
23
|
+
styles = arborist_styles_tag(app.config.arborist).to_s unless app.config.arborist.dev_mode
|
24
|
+
script = arborist_script_tag(app.config.arborist).to_s
|
25
|
+
|
26
|
+
insert_index = response.body.rindex(%q{</body>})
|
27
|
+
response.body = response.body.insert(insert_index, [
|
28
|
+
widget,
|
29
|
+
styles,
|
30
|
+
script,
|
31
|
+
].compact.join(%q{}))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require %q{action_view}
|
2
|
+
require %q{active_support}
|
3
|
+
|
4
|
+
module ArboristChatRails::TagsHelper
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
include ::ActionView::Helpers::AssetTagHelper
|
8
|
+
include ::ActionView::Helpers::TagHelper
|
9
|
+
|
10
|
+
def arborist_script_tag(config)
|
11
|
+
javascript_include_tag(url(config, %q{widget/bundle.js}), defer: true)
|
12
|
+
end
|
13
|
+
|
14
|
+
def arborist_styles_tag(config)
|
15
|
+
stylesheet_link_tag(url(config, %q{widget/styles.css}))
|
16
|
+
end
|
17
|
+
|
18
|
+
def arborist_widget_tag(config)
|
19
|
+
content_tag(:div, nil, 'data-arborist-token': token(config))
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def url(config, path)
|
25
|
+
if config.dev_mode
|
26
|
+
[%q{http://localhost:3000}, path]
|
27
|
+
else
|
28
|
+
[%q{https://www.arborist.app}, path]
|
29
|
+
end.join(%q{/})
|
30
|
+
end
|
31
|
+
|
32
|
+
def token(config)
|
33
|
+
JWT.encode(payload(config), config.app_secret, %q{HS256})
|
34
|
+
end
|
35
|
+
|
36
|
+
def payload(config)
|
37
|
+
{
|
38
|
+
app_id: config.app_id,
|
39
|
+
current_user: instance_exec(&config.current_user)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: arborist_chat_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Leon
|
8
|
+
- Pearce
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-07-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: actionview
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '5.0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '5.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: activesupport
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '5.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '5.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: jwt
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.0'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: railties
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.0'
|
70
|
+
description: adds Arborist live chat to your web app
|
71
|
+
email:
|
72
|
+
- leonp1991@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CHANGELOG.md
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- arborist_chat_rails.gemspec
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- lib/arborist_chat_rails.rb
|
88
|
+
- lib/arborist_chat_rails/install_generator.rb
|
89
|
+
- lib/arborist_chat_rails/railtie.rb
|
90
|
+
- lib/arborist_chat_rails/tags_helper.rb
|
91
|
+
- lib/arborist_chat_rails/version.rb
|
92
|
+
homepage: http://github.com/arborist-software/arborist-chat-rails
|
93
|
+
licenses: []
|
94
|
+
metadata:
|
95
|
+
allowed_push_host: https://rubygems.org
|
96
|
+
changelog_uri: http://github.com/arborist-software/arborist-chat-rails/CHANGELOG.md
|
97
|
+
homepage_uri: http://github.com/arborist-software/arborist-chat-rails
|
98
|
+
source_code_uri: http://github.com/arborist-software/arborist-chat-rails
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: 2.3.0
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubygems_version: 3.0.3
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: adds Arborist live chat to your web app
|
118
|
+
test_files: []
|