share_buttons 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -10
- data/app/assets/javascripts/share_buttons.coffee +2 -2
- data/app/helpers/share_buttons/view_helper.rb +2 -1
- data/app/views/share_buttons/_email.html.haml +1 -1
- data/app/views/share_buttons/_facebook.html.haml +1 -1
- data/app/views/share_buttons/_google_plus.html.haml +1 -1
- data/app/views/share_buttons/_link.html.haml +1 -1
- data/app/views/share_buttons/_pinterest.html.haml +1 -1
- data/app/views/share_buttons/_twitter.html.haml +1 -1
- data/lib/generators/share_buttons/install/templates/initializer.rb +2 -0
- data/lib/share_buttons/base.rb +4 -0
- data/lib/share_buttons/facebook.rb +5 -2
- data/lib/share_buttons/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11db4faf869ab88325e89a36c95f02ea1ca5c992
|
4
|
+
data.tar.gz: 100e03d7d849b65a48a102ef87ab74d837eb04be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
35
|
-
initializer configuration file
|
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
|
-
|
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(
|
50
|
-
<%= twitter_share_button(
|
51
|
-
<%= google_plus_share_button(
|
52
|
-
<%= pinterest_share_button(
|
53
|
-
<%= email_share_button(
|
54
|
-
<%= link_share_button(
|
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
|
@@ -1,4 +1,4 @@
|
|
1
|
-
%button
|
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
|
|
data/lib/share_buttons/base.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module ShareButtons
|
2
2
|
class Facebook < ShareButtons::Base
|
3
|
-
|
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:
|
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
|