share_buttons 1.1.0 → 1.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48ddf4aed372d084e4fa5e3178c0a81654ab68d7
4
- data.tar.gz: f647c4f310618ddda0a25d980bcdb1f36d17b006
3
+ metadata.gz: 11db4faf869ab88325e89a36c95f02ea1ca5c992
4
+ data.tar.gz: 100e03d7d849b65a48a102ef87ab74d837eb04be
5
5
  SHA512:
6
- metadata.gz: 197612915bf4fedfb6bdd2fbe9cef27aebc33872d8a96e8b4750bedfc56f23f6ff4d49b4c55bd7b3e49bb6f2407e3278c839a403903b8766a44cda1d1e1d5847
7
- data.tar.gz: cd365c831279ea569ce960c23ae8e6b3679990446207a76b424b575ddbc8a857d43de316ebc165db1e08fba4eacdefed607b8d3693388b910e5e4c54037e2c20
6
+ metadata.gz: 96f58a3e94fe3aacaaeb41d80920e96ada34429acdd8ccc9752ff56fb3a9a38bf9844eaca77eb3a78557685af77253dda23ea8a42f4efc7c6cf8af4cd368edbe
7
+ data.tar.gz: 1000db3730f7eae0f4152d4c44f5ca6a90aa5cff7648ba837c84ed5fc5c19643c402b6bfc46505b5ea3c58e8a51c9b5ccc2407f7ec0669ab85253b0a5f795b75
data/README.md CHANGED
@@ -31,13 +31,13 @@ At last, include the javascript file in your `application.js` with :
31
31
 
32
32
  ## Configuration
33
33
 
34
- For Facebook sharing, you need to add you Facebook APP_ID to the generated
35
- initializer configuration file in `config/initializers/share_buttons.rb` :
34
+ For Facebook sharing, you need to set the `FACEBOOK_APP_ID` environment variable
35
+ or add your Facebook App Id to the generated initializer configuration file at
36
+ `config/initializers/share_buttons.rb` :
36
37
 
37
38
  ```ruby
38
39
  ShareButtons.configure do |config|
39
- # Configure your facebook App ID for sharing
40
- config.facebook.app_id = ENV['FACEBOOK_KEY']
40
+ config.facebook.app_id = 'YOUR_APP_ID'
41
41
  end
42
42
  ```
43
43
 
@@ -46,16 +46,19 @@ end
46
46
  In your views, use any of the included helpers :
47
47
 
48
48
  ```erb
49
- <%= facebook_share_button(resource_path(resource), title: resource.title) %>
50
- <%= twitter_share_button(resource_path(resource), title: resource.title) %>
51
- <%= google_plus_share_button(resource_path(resource), title: resource.title) %>
52
- <%= pinterest_share_button(resource_path(resource), title: resource.title, image_url: resource.image.url) %>
53
- <%= email_share_button(resource_path(resource), title: resource.title) %>
54
- <%= link_share_button(resource_path(resource), title: resource.title) %>
49
+ <%= facebook_share_button(resource_url(resource), title: resource.title) %>
50
+ <%= twitter_share_button(resource_url(resource), title: resource.title) %>
51
+ <%= google_plus_share_button(resource_url(resource), title: resource.title) %>
52
+ <%= pinterest_share_button(resource_url(resource), title: resource.title, image_url: resource.image.url) %>
53
+ <%= email_share_button(resource_url(resource), title: resource.title) %>
54
+ <%= link_share_button(resource_url(resource), title: resource.title) %>
55
55
  ```
56
56
 
57
57
  And customize the generated views to your needs in `app/views/share_buttons/_<provider>.html.haml`
58
58
 
59
+ > **Note** : Do not forget to use **URL** helpers and not Path helpers since the
60
+ final URL is to be shared on other websites.
61
+
59
62
  ### Facebook
60
63
 
61
64
  Facebook's `redirect_uri` parameter will be set to `request.original_url` by
@@ -9,8 +9,8 @@
9
9
  # Custom page ready handler allowing to automatically handle apps with or
10
10
  # without Turbolinks
11
11
  onPageReady: (callback) ->
12
- $(document).ready(-> callback() unless window.Turbolinks)
13
- $(document).on('page:change', callback);
12
+ $(document).ready(-> callback() unless window.Turbolinks?.supported)
13
+ $(document).on('page:change turbolinks:load', callback)
14
14
 
15
15
  register: (type, plugin) ->
16
16
  ShareButtons._plugins[type] = plugin
@@ -22,7 +22,8 @@ module ShareButtons
22
22
  options = {}
23
23
  end
24
24
  end
25
+
25
26
  [url, options]
26
27
  end
27
28
  end
28
- end
29
+ end
@@ -1,3 +1,3 @@
1
- = mail_to nil, body: button.url, subject: button.title, class: 'btn btn-default', data: { share: 'email' } do
1
+ = mail_to nil, body: button.url, subject: button.title, class: button.button_class, data: { share: 'email' } do
2
2
  %i.fa.fa-envelope
3
3
  = button.label
@@ -1,3 +1,3 @@
1
- = link_to button.href, class: 'btn btn-default', data: { share: 'popup' } do
1
+ = link_to button.href, class: button.button_class, data: { share: 'popup' } do
2
2
  %i.fa.fa-facebook
3
3
  = button.label
@@ -1,3 +1,3 @@
1
- = link_to button.href, class: 'btn btn-default', data: { share: 'popup' } do
1
+ = link_to button.href, class: button.button_class, data: { share: 'popup' } do
2
2
  %i.fa.fa-google-plus
3
3
  = button.label
@@ -1,4 +1,4 @@
1
- %button.btn.btn-default{ type: 'button', data: { share: 'copy', target: "##{ button.dom_id }", :"clipboard-text" => button.url, :title => button.label } }
1
+ %button{ class: button.button_class, type: 'button', data: { share: 'copy', target: "##{ button.dom_id }", :"clipboard-text" => button.url, :title => button.label } }
2
2
  %i.fa.fa-link
3
3
  = button.label
4
4
 
@@ -1,3 +1,3 @@
1
- = link_to button.href, class: 'btn btn-default', data: { share: 'popup', :'pin-do' => 'buttonBookmark' } do
1
+ = link_to button.href, class: button.button_class, data: { share: 'popup', :'pin-do' => 'buttonBookmark' } do
2
2
  %i.fa.fa-pinterest
3
3
  = button.label
@@ -1,3 +1,3 @@
1
- = link_to button.href, class: 'btn btn-default', data: { share: 'popup' } do
1
+ = link_to button.href, class: button.button_class, data: { share: 'popup' } do
2
2
  %i.fa.fa-twitter
3
3
  = button.label
@@ -1,4 +1,6 @@
1
1
  ShareButtons.configure do |config|
2
2
  # Configure your facebook App ID for sharing
3
+ # Note that it defaults to the `FACEBOOK_APP_ID` environment variable.
4
+ #
3
5
  # config.facebook.app_id = ENV['FACEBOOK_APP_ID']
4
6
  end
@@ -16,6 +16,10 @@ module ShareButtons
16
16
  options.fetch(:label, "Partager sur #{ medium_name }")
17
17
  end
18
18
 
19
+ def button_class
20
+ options.fetch(:button_class, 'btn btn-default')
21
+ end
22
+
19
23
  def medium_name
20
24
  self.class.name.demodulize.underscore.humanize
21
25
  end
@@ -1,6 +1,6 @@
1
1
  module ShareButtons
2
2
  class Facebook < ShareButtons::Base
3
- cattr_accessor :app_id
3
+ class_attribute :app_id
4
4
 
5
5
  private
6
6
 
@@ -11,7 +11,7 @@ module ShareButtons
11
11
  def url_options
12
12
  {
13
13
  display: 'popup', redirect_uri: redirect_uri,
14
- app_id: config.app_id, href: url
14
+ app_id: app_id, href: url
15
15
  }
16
16
  end
17
17
 
@@ -19,5 +19,8 @@ module ShareButtons
19
19
  options[:redirect_uri] || request.original_url
20
20
  end
21
21
 
22
+ def app_id
23
+ @app_id ||= ENV['FACEBOOK_APP_ID'] || config.app_id
24
+ end
22
25
  end
23
26
  end
@@ -1,3 +1,3 @@
1
1
  module ShareButtons
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: share_buttons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentin Ballestrino