intercom-rails 0.2.11 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
data/README.mdown
CHANGED
@@ -151,13 +151,6 @@ You can also override `IntercomRails::Config` options such as your `api_secret`,
|
|
151
151
|
}) %>
|
152
152
|
<% end %>
|
153
153
|
```
|
154
|
-
|
155
|
-
The `intercom:install` rails generator will add the `intercom_script_tag` to your application layout:
|
156
|
-
|
157
|
-
```
|
158
|
-
rails g intercom:install YOUR-APP-ID
|
159
|
-
```
|
160
|
-
|
161
154
|
## Importing your users
|
162
155
|
To get started faster with Intercom, `IntercomRails` includes a Rake task that will do an initial import of your users:
|
163
156
|
|
@@ -10,11 +10,34 @@ module Intercom
|
|
10
10
|
argument :api_secret, :desc => "Your Intercom api-secret, used for secure mode", :optional => true
|
11
11
|
argument :api_key, :desc => "An Intercom API key, for various rake tasks", :optional => true
|
12
12
|
|
13
|
+
FALSEY_RESPONSES = ['n', 'no']
|
13
14
|
def create_config_file
|
14
15
|
@app_id = app_id
|
15
16
|
@api_secret = api_secret
|
16
17
|
@api_key = api_key
|
17
18
|
|
19
|
+
introduction = <<-desc
|
20
|
+
Intercom will automatically insert its javascript before the closing '</body>'
|
21
|
+
tag on every page where it can find a logged-in user. Intercom by default
|
22
|
+
looks for logged-in users, in the controller, via 'current_user' and '@user'.
|
23
|
+
|
24
|
+
Is the logged-in user accessible via either 'current_user' or '@user'? [Yn]
|
25
|
+
desc
|
26
|
+
|
27
|
+
print "#{introduction.strip} "
|
28
|
+
default_ok = $stdin.gets.strip.downcase
|
29
|
+
|
30
|
+
if FALSEY_RESPONSES.include?(default_ok)
|
31
|
+
custom_current_user_question = <<-desc
|
32
|
+
|
33
|
+
How do you access the logged-in user in your controllers? This can be
|
34
|
+
any Ruby code, e.g. 'current_customer', '@admin', etc.:
|
35
|
+
desc
|
36
|
+
|
37
|
+
print "#{custom_current_user_question.rstrip} "
|
38
|
+
@current_user = $stdin.gets.strip
|
39
|
+
end
|
40
|
+
|
18
41
|
template("intercom.rb.erb", "config/initializers/intercom.rb")
|
19
42
|
end
|
20
43
|
|
@@ -27,7 +27,11 @@ IntercomRails.config do |config|
|
|
27
27
|
# The method/variable that contains the logged in user in your controllers.
|
28
28
|
# If it is `current_user` or `@user`, then you can ignore this
|
29
29
|
#
|
30
|
+
<%- if @current_user -%>
|
31
|
+
config.user.current = Proc.new { <%= @current_user %> }
|
32
|
+
<%- else -%>
|
30
33
|
# config.user.current = Proc.new { current_user }
|
34
|
+
<%- end -%>
|
31
35
|
|
32
36
|
# == User model class
|
33
37
|
# The class which defines your user model
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intercom-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-01-
|
14
|
+
date: 2013-01-12 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -153,7 +153,6 @@ files:
|
|
153
153
|
- lib/intercom-rails.rb
|
154
154
|
- lib/rails/generators/intercom/config/config_generator.rb
|
155
155
|
- lib/rails/generators/intercom/config/intercom.rb.erb
|
156
|
-
- lib/rails/generators/intercom/install/install_generator.rb
|
157
156
|
- Rakefile
|
158
157
|
- README.mdown
|
159
158
|
- test/action_controller_test_setup.rb
|
@@ -181,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
180
|
version: '0'
|
182
181
|
segments:
|
183
182
|
- 0
|
184
|
-
hash:
|
183
|
+
hash: -28937987010178608
|
185
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
185
|
none: false
|
187
186
|
requirements:
|
@@ -190,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
189
|
version: '0'
|
191
190
|
segments:
|
192
191
|
- 0
|
193
|
-
hash:
|
192
|
+
hash: -28937987010178608
|
194
193
|
requirements: []
|
195
194
|
rubyforge_project: intercom-rails
|
196
195
|
rubygems_version: 1.8.23
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Intercom
|
2
|
-
module Generators
|
3
|
-
class InstallGenerator < ::Rails::Generators::Base
|
4
|
-
desc "Installs Intercom (https://www.intercom.io) into your Rails app"
|
5
|
-
|
6
|
-
argument :app_id, :desc => "Your Intercom app-id, which can be found here: https://www.intercom.io/apps/api_keys"
|
7
|
-
|
8
|
-
def update_layout
|
9
|
-
snippet = <<-HTML
|
10
|
-
<!--
|
11
|
-
TODO add any user/app/situational data to the custom Hash below
|
12
|
-
e.g. :plan => 'Pro', :dashboard_page => 'http://dashboard.example.com/user-id'
|
13
|
-
See http://docs.intercom.io/#CustomData for more details about custom data
|
14
|
-
-->
|
15
|
-
<% if logged_in? %>
|
16
|
-
<%= intercom_script_tag({
|
17
|
-
:app_id => #{app_id.inspect},
|
18
|
-
:user_id => current_user.id,
|
19
|
-
:email => current_user.email,
|
20
|
-
:name => current_user.name,
|
21
|
-
:created_at => current_user.created_at,
|
22
|
-
:custom_data => {
|
23
|
-
|
24
|
-
}}) %>
|
25
|
-
<% end %>
|
26
|
-
</body>
|
27
|
-
HTML
|
28
|
-
|
29
|
-
gsub_file('app/views/layouts/application.html.erb', %r{</body>}, snippet)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|