shareable 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a98ad05010d306ff7b726daec73356113ef8562
|
4
|
+
data.tar.gz: bf4ee10e50d2bc73584999605e7ff9bd08f2b6dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ebf790d7f6c2416d0870c0e8eee2ffa045e49e1397021872474606cd6b821b98d25f068a3d28fa5b404c7f0629e6c9906f521c81668e43fa334c0c4bd250177
|
7
|
+
data.tar.gz: f6559be4c2ee8365d84a6f1740405b5755952f66fd75d72d418d2a617235b094862ee49e88fbd9c56e1dc5a39153f9e8452ad357856a346474abc9fcd94ef419
|
data/README.md
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
Shareable
|
2
2
|
=========
|
3
3
|
<img src="https://cloud.githubusercontent.com/assets/28847/3418917/8883ea2e-fe51-11e3-81f4-368f184b9a49.png" title="Shareable makes social media buttons." /><br/>
|
4
|
-
A gem for adding social buttons to your Rails app.
|
4
|
+
A gem for adding social buttons to your Rails app. This gem runs with minimal configuration<sup>*</sup> and offers many options for personalizing your social buttons. You can generate javascript buttons or static links. Render buttons for the most popular social media sites and your own custom code with a single method call. Buttons are available for the following social networks:
|
5
5
|
- Facebook
|
6
6
|
- Twitter
|
7
7
|
- Pinterest
|
8
8
|
- Reddit
|
9
9
|
- Linkedin
|
10
10
|
- Google Plus
|
11
|
-
- Tumblr<sup
|
12
|
-
- StumbleUpon<sup
|
11
|
+
- Tumblr<sup>**</sup>
|
12
|
+
- StumbleUpon<sup>**</sup>
|
13
13
|
|
14
|
-
|
14
|
+
The Shareable gem supports Rails 3 and 4.
|
15
|
+
|
16
|
+
<sub>* If your app uses Rails 4 or Turbolinks, set configuration option *turbolinks* to **true** ([see Turbolinks](https://github.com/hermango/shareable#turbolinks)).</sub><sub> ** Tumblr and StumbleUpon buttons aren't displayed by default ([see Configuration](https://github.com/hermango/shareable#configuration)).</sub>
|
15
17
|
|
16
|
-
The shareable gem supports Rails 3 and 4.
|
17
18
|
|
18
19
|
Install
|
19
20
|
--------
|
@@ -29,15 +30,15 @@ Usage
|
|
29
30
|
------
|
30
31
|
### Views
|
31
32
|
|
32
|
-
For the simplest way of using
|
33
|
+
For the simplest way of using this gem, add this helper method to your views:
|
33
34
|
|
34
35
|
```no-highlight
|
35
36
|
<%= render_shareable %>
|
36
37
|
```
|
37
38
|
|
38
|
-
That's it!
|
39
|
+
That's it! Change the look and content of each button with more options. Keep reading to find out how.
|
39
40
|
|
40
|
-
You can also render each social
|
41
|
+
You can also render each social button separately by calling the following methods:
|
41
42
|
+ facebook_button
|
42
43
|
+ twitter_button
|
43
44
|
+ pinterest_button
|
@@ -49,7 +50,7 @@ You can also render each social media button separately by calling the following
|
|
49
50
|
|
50
51
|
#### Static Links
|
51
52
|
|
52
|
-
|
53
|
+
Javascript buttons are rendered by default. To render plain html links instead, set the configuration option *static_link* to boolean **true** in your app's 'shareable.rb' configuration file ([see Configuration](https://github.com/hermango/shareable#configuration) for more information). You can also pass *static_link* to the render_shareable method like so:
|
53
54
|
|
54
55
|
```no-highlight
|
55
56
|
<%= render_shareable :static_link => true %>
|
@@ -57,7 +58,7 @@ Shareable generates javascript buttons by default. To render plain html links in
|
|
57
58
|
|
58
59
|
#### Tumblr and StumbleUpon Buttons
|
59
60
|
|
60
|
-
By default
|
61
|
+
By default, display of Tumblr and StumbleUpon buttons is disabled. Enable either button by including the name of the button you want to add (**tumblr** or **stumble_upon**) to the configuration option *names* (found in your local 'shareable.rb' configuration file).
|
61
62
|
|
62
63
|
|
63
64
|
### Advanced Usage
|
@@ -71,7 +72,7 @@ To render only certain buttons:
|
|
71
72
|
<%= render_shareable :buttons=> ['twitter', 'facebook', 'tumblr'] %>
|
72
73
|
```
|
73
74
|
|
74
|
-
Alternatively, omit the render_shareable method
|
75
|
+
Alternatively, omit the render_shareable method and render each button individually instead.
|
75
76
|
The helper method for each social link is the site name joined with an underscore to the word 'button'. E.g.:
|
76
77
|
|
77
78
|
```no-highlight
|
@@ -79,10 +80,34 @@ The helper method for each social link is the site name joined with an underscor
|
|
79
80
|
<%= reddit_button :title=> 'Alternate Title' %>
|
80
81
|
```
|
81
82
|
|
82
|
-
|
83
|
-
|
83
|
+
#### Customizing Buttons
|
84
|
+
Overriding Shareable is possible and entirely optional. Some knowledge of [Rails layouts and rendering](http://guides.rubyonrails.org/layouts_and_rendering.html) is required. Read on to learn how you can personalize your buttons.
|
85
|
+
|
86
|
+
##### Custom HTML Wrappers
|
87
|
+
|
88
|
+
Buttons and static links are wrapped in overwritable files called partials. The look and DOM structure of your buttons can be changed by creating your own files with matching filenames and placed in your local 'views' directory. As long as the yield method is called in the following two partials, you can make whatever changes you want:
|
89
|
+
+ [_parent_wrapper.html.erb](https://github.com/hermango/shareable/blob/master/app/views/shareable/partials/_parent_wrapper.html.erb) goes in your app's 'app/views/shareable/partials/' directory. This partial is rendered once and encloses all of the buttons.
|
90
|
+
+ [_button_wrapper.html.erb](https://github.com/hermango/shareable/blob/master/app/views/shareable/partials/_button_wrapper.html.erb) goes in your app's 'app/views/shareable/partials/' directory. This partial is rendered inside _parent_wrapper.html.erb and is outputted for each button.
|
91
|
+
|
92
|
+
##### Change Static Links
|
93
|
+
|
94
|
+
The partial used for static links is named _link.html.erb. The important variable you want to include is called *options[:url]*.
|
95
|
+
+ [_link.html.erb](https://github.com/hermango/shareable/blob/master/app/views/shareable/partials/_link.html.erb) goes in your app's 'app/views/shareable/partials/' directory.
|
96
|
+
|
97
|
+
##### Change Javascript Buttons
|
98
|
+
|
99
|
+
To override the code for a javascript button, place your own template file in the
|
100
|
+
'app/views/shareable/' directory of your app and prepend that filename with an underscore and the name of the social media site. For example, to overwrite the Facebook button: Create a file called _facebook.html.erb that goes in the 'app/views/shareable/' directory.
|
101
|
+
|
102
|
+
##### A Note about Variables: button_name and button_caption
|
103
|
+
Each outputted button has two variables that identify the social network the button belongs to. These variables are named *button_name* and *button_caption* and are contained in the *options* hash. Depending on the button instance these variables are accessed within, the possible string values are:
|
104
|
+
+ options[:button_name] is one of the following: "facebook", "twitter", "pinterest", "linkedin", "google_plus", "reddit", "tumblr" or "stumble_upon".
|
105
|
+
+ options[:button_caption] is one of the following: "Facebook", "Twitter", "Pinterest", "Linkedin", "Google+", "Reddit", "Tumblr" or "StumbleUpon".
|
84
106
|
|
85
|
-
|
107
|
+
Both variables can be overridden when passed to the render_shareable method as hash values. E.g.:
|
108
|
+
```
|
109
|
+
<%= render_shareable :twitter => {:button_caption => 'Tweet this!'} %>
|
110
|
+
```
|
86
111
|
|
87
112
|
#### Facebook compatibility with Internet Explorer
|
88
113
|
Add an XML namespace fb='http://ogp.me/ns/fb#' to the html tag of your view. Eg:
|
@@ -92,15 +117,14 @@ Add an XML namespace fb='http://ogp.me/ns/fb#' to the html tag of your view. Eg:
|
|
92
117
|
|
93
118
|
This is necessary for XFBML to work in earlier versions of Internet Explorer.
|
94
119
|
|
95
|
-
#### Styling for
|
120
|
+
#### Styling for Buttons
|
96
121
|
For horizontally aligned buttons, try this CSS:
|
97
122
|
|
98
123
|
```no-highlight
|
99
124
|
nav.share {display:inline-block;} /* shareable's nav tag */
|
100
|
-
nav.share div {float:left;
|
101
|
-
nav.share iframe {
|
102
|
-
#___plusone_0 {
|
103
|
-
.twitter-share-button, .twitter-count-horizontal {max-width:80px;}
|
125
|
+
nav.share div {float:left;}
|
126
|
+
nav.share iframe {border:0; margin-top:0; padding-top:0;} /* if using medium sized buttons */
|
127
|
+
#___plusone_0 {font-size: default !important;}
|
104
128
|
.fb_iframe_widget span { vertical-align: top; }
|
105
129
|
.fb_edge_widget_with_comment { vertical-align: top;}
|
106
130
|
.fb-like{display:inline-block}
|
@@ -108,23 +132,36 @@ nav.share iframe {max-height:20px; border:0; margin-top:0; padding-top:0;} /* if
|
|
108
132
|
*+html .fb-like{display:inline}/* ie7 inline block fix*/
|
109
133
|
```
|
110
134
|
|
111
|
-
If you use the default configuration options
|
135
|
+
If you use the default configuration options and styling above, the output should appear as:
|
112
136
|
<img src="https://cloud.githubusercontent.com/assets/28847/3418917/8883ea2e-fe51-11e3-81f4-368f184b9a49.png" alt="horizontal row of evenly aligned social media buttons." />
|
113
137
|
|
138
|
+
###Turbolinks
|
139
|
+
**Important:** If your project uses Rails 4, then it's very likely you should set the *turbolinks* option to **true**. Otherwise social buttons won't appear on pages loaded via Turbolinks (Turbolinks is default in Rails 4 unless explicitly disabled).
|
140
|
+
|
141
|
+
This gem works with Turbolinks however the javascript library [jQuery](https://github.com/rails/jquery-rails) is required. Turbolinks support in Shareable is turned off by default. To enable Turbolinks support, first make sure your app includes jQuery then set configuration option *turbolinks* in your local 'shareable.rb' [configuration](https://github.com/hermango/shareable/blob/master/README.md#configuration) file to boolean **true**. The *turbolinks* option can also be passed as a hash value to the render_shareable method like this:
|
142
|
+
|
143
|
+
```
|
144
|
+
<%= render_shareable :turbolinks => true, :facebook => {:turbolinks => false} %>
|
145
|
+
```
|
146
|
+
If your app doesn't use jQuery or you don't want to use the provided solution but still want to use this gem, here are some other options:
|
147
|
+
|
148
|
+
1. Use [static links](https://github.com/hermango/shareable#static-links) instead.
|
149
|
+
2. Roll your own solution: Set configuration option *button_only* to boolean **true**. This will output button tags without javascript. Then you can add your own javascript solution. See [Nick Reed's tutorials](http://reed.github.io/turbolinks-compatibility/) to check out some approaches.
|
150
|
+
3. Disable Turbolinks. To disable Turbolinks from your app: Remove the line "//= require turbolinks" from your app's application.js. Or to disable Turbolinks for only some cases, use the data marker *data-no-turbolink* in links and html elements [(instructions here)](https://github.com/rails/turbolinks#opting-out-of-turbolinks).
|
151
|
+
|
114
152
|
Configuration
|
115
153
|
------------
|
116
|
-
|
154
|
+
This gem comes pre-configured and ready to use. You can use the [default configuration settings](https://github.com/hermango/shareable/blob/master/lib/shareable/config.rb) or customize your buttons by adding and editing your own initializer named 'shareable.rb' to your app's 'config/initializers' directory.
|
117
155
|
|
118
|
-
A generator is available for generating
|
119
|
-
Run the following generator command, then edit the generated file as preferred.
|
156
|
+
A generator is available for generating an editable configuration file. Run the following command, then edit the file as preferred.
|
120
157
|
|
121
158
|
rails g shareable:config
|
122
159
|
|
123
|
-
|
124
|
-
* static_link
|
125
|
-
* button_only
|
126
|
-
* turbolinks
|
160
|
+
String values are expected for nearly all configuration options. Any value passed to a configuration option not enclosed in quotation marks will cause errors! Four configuration options are exceptions to this rule. The configuration option *names* (also called *buttons* when passed as a hash value to the render_shareable method) expects an array of strings ([see it in the configuration file](https://github.com/hermango/shareable/blob/master/lib/shareable/config.rb)). The other three configuration options listed below expect boolean values only:
|
161
|
+
* static_link - **false** by default. See [Static Links](https://github.com/hermango/shareable#static-links).
|
162
|
+
* button_only - **false** by default. If set to **true**, javascript code for buttons is omitted.
|
163
|
+
* turbolinks - **false** by default. When set to **true**, javascript buttons will work with Turbolinks. Relies on jQuery. See [Turbolinks](https://github.com/hermango/shareable#turbolinks).
|
127
164
|
|
128
165
|
---
|
129
166
|
|
130
|
-
This project was inspired by Akira Matsuda's Kaminari
|
167
|
+
This project was inspired by [Akira Matsuda's](https://github.com/amatsuda) [Kaminari gem](https://github.com/amatsuda/kaminari) and uses the MIT-LICENSE. Suggestions, bug reports, criticism and all contributions welcome.
|
@@ -10,9 +10,18 @@
|
|
10
10
|
<% end %>
|
11
11
|
<% end %>
|
12
12
|
<%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
|
13
|
-
<div class="fb-like"
|
14
|
-
|
15
|
-
|
13
|
+
<div class="fb-like" data-href='<%= options[:url] %>'
|
14
|
+
data-send='<%= options[:send] %>'
|
15
|
+
data-layout='<%= options[:layout] %>'
|
16
|
+
data-show-faces='<%= options[:show_faces] %>'
|
17
|
+
data-width='<%= options[:width] %>'
|
18
|
+
data-action='<%= options[:action] %>'
|
19
|
+
data-font='<%= options[:font] %>'
|
20
|
+
data-colorscheme='<%= options[:colorscheme] %>'
|
21
|
+
data-ref='<%= options[:ref] %>'
|
22
|
+
data-share='<%= options[:share] %>'
|
23
|
+
data-kid-directed-site='<%= options[:kid_directed_site] %>' >
|
24
|
+
</div>
|
16
25
|
<% end %>
|
17
26
|
<% if options[:turbolinks] && !options[:button_only] %>
|
18
27
|
<%= output_once :facebook do %>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
var js, fjs = d.getElementsByTagName(s)[0];
|
4
4
|
if (d.getElementById(id)) return;
|
5
5
|
js = d.createElement(s); js.id = id;
|
6
|
-
js.src = "//connect.facebook.net/en_US/
|
6
|
+
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1<%= raw('&appId=' + app_id.to_s) if defined?(app_id) %>&status=0&version=v2.0";
|
7
7
|
fjs.parentNode.insertBefore(js, fjs);
|
8
8
|
}(document, 'script', 'facebook-jssdk'));
|
9
9
|
</script>
|
@@ -25,7 +25,7 @@ restoreFacebookRoot = function() { \
|
|
25
25
|
}; \
|
26
26
|
loadFacebookSDK = function() { \
|
27
27
|
window.fbAsyncInit = initializeFacebookSDK; \
|
28
|
-
return $.getScript('//connect.facebook.net/en_US/
|
28
|
+
return $.getScript('//connect.facebook.net/en_US/sdk.js', function() { facebookLoaded = true; }); \
|
29
29
|
}; \
|
30
30
|
initializeFacebookSDK = function() { \
|
31
31
|
return FB.init({ \
|
data/lib/shareable/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shareable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hermango
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|