shareable 1.0.0 → 1.1.3

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: 19c19e220407ca941b623e9fa1193f404741adbc
4
- data.tar.gz: 214c19f7a01b047c536a5b26bf32676161e0988e
3
+ metadata.gz: ba9650886c5ad7975604cc704ec816335c2062ea
4
+ data.tar.gz: e3a2669c4cd0da49b4205fda5055fec31123d60e
5
5
  SHA512:
6
- metadata.gz: 91f23d8a1f33e77d7421c9bbbe91c617bce9361bbc07918cdb5c49e04bf8f0cd5f6ff06607a17ed7e9c773bb67286837f5968b6e0cce7eb5de3e1267acb2d938
7
- data.tar.gz: 01b71ab520dcb4575d26f567013eb370060bf8ec6e99fe4f89ae98724da890d834f7b61339b82158478a131a2f9ac76829c35cdc4be34f63a44505426df49bbd
6
+ metadata.gz: 836391912e90847d1dc1cb4f559674cf532580715359eb496ee19e6da00d3ce5e16cafbdb5177a75ec005b9b0cb135ed6df3a1b9abb6f1c33cfb8fd60a0b9eb8
7
+ data.tar.gz: 12ac8624003365973b03b43fdab6eb7e7624ec16bd518512f3ac5c8acac2f479fe7b4339962bba48e22fe2a48d7eccdf5d8af97571df86d4e7353c4e48840001
data/.gitignore CHANGED
@@ -3,4 +3,5 @@
3
3
  .idea
4
4
  Gemfile.lock
5
5
  gemfiles/*.lock
6
- doc
6
+ doc
7
+ .DS_Store
data/README.md CHANGED
@@ -1,12 +1,19 @@
1
1
  Shareable
2
2
  =========
3
- A simple and unobtrusive gem for adding social link sharing to your Rails app. Supported social sites include:
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. Shareable runs with zero configuration and offers a wide range of customization features. Rendering javascript buttons and static links is easy. One method call can generate all the sharing buttons you want. The available social media sites include:
4
5
  - Facebook
5
6
  - Twitter
6
7
  - Pinterest
7
8
  - Reddit
8
9
  - Linkedin
9
10
  - Google Plus
11
+ - Tumblr<sup>*</sup>
12
+ - StumbleUpon<sup>*</sup>
13
+
14
+ <sub>*Tumblr and StumbleUpon buttons aren't rendered by default. Set a [configuration](https://github.com/hermango/shareable#configuration) option to show these buttons.</sub>
15
+
16
+ The shareable gem supports Rails 3 and 4.
10
17
 
11
18
  Install
12
19
  --------
@@ -21,47 +28,64 @@ Then run the bundle command:
21
28
  Usage
22
29
  ------
23
30
  ### Views
24
- To add shareable in views use any of the following methods:
25
- + render_shareable
31
+
32
+ For the simplest way of using shareable, add this helper method to your views:
33
+
34
+ ```no-highlight
35
+ <%= render_shareable %>
36
+ ```
37
+
38
+ That's it! You can customize the look and content of each button with more options. Keep reading to find out how.
39
+
40
+ You can also render each social media button separately by calling the following methods:
26
41
  + facebook_button
27
42
  + twitter_button
28
43
  + pinterest_button
29
44
  + linkedin_button
30
45
  + reddit_button
31
46
  + google_plus_button
47
+ + tumblr_button
48
+ + stumble_upon_button
49
+
50
+ #### Static Links
32
51
 
33
- For the easiest way to use shareable, add this helper method to your view:
52
+ Shareable generates javascript buttons by default. To render plain html links instead, set the configuration option *static_link* to boolean value **true** in your app's local 'shareable.rb' configuration file. You can also pass *static_link* to the render_shareable method like so:
34
53
 
35
54
  ```no-highlight
36
- <%= render_shareable %>
55
+ <%= render_shareable :static_link => true %>
37
56
  ```
38
57
 
58
+ #### Tumblr and StumbleUpon Buttons
59
+
60
+ By default the 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). [See Configuration](https://github.com/hermango/shareable#configuration) for more information.
61
+
62
+
39
63
  ### Advanced Usage
40
64
  Pass hash values to the render_shareable method to overwrite options locally:
41
65
  ```no-highlight
42
- <%= render_shareable :url=> 'http://github.com/hermango/', :facebook=> {:send=> 'true', :url=> 'http://demo.com'} %>
66
+ <%= render_shareable :url=> 'http://github.com/hermango/', :facebook=> {:send=> 'true', :url=> 'http://demo.dev'} %>
43
67
  ```
44
68
 
45
69
  To render only certain buttons:
46
70
  ```no-highlight
47
- <%= render_shareable :buttons=> ['twitter', 'facebook'] %>
71
+ <%= render_shareable :buttons=> ['twitter', 'facebook', 'tumblr'] %>
48
72
  ```
49
73
 
50
74
  Alternatively, omit the render_shareable method entirely and instead add each social link individually.
51
- The helper method for each social link, is the site name joined with an underscore to the word 'button'. E.g.:
75
+ The helper method for each social link is the site name joined with an underscore to the word 'button'. E.g.:
52
76
 
53
77
  ```no-highlight
54
78
  <%= twitter_button %>
55
79
  <%= reddit_button :title=> 'Alternate Title' %>
56
80
  ```
57
81
 
58
- To override the default view for a button, place your own template file in the
59
- app/views/shareable/ directory of your app and prepend your filename with an underscore.
82
+ To override the default code for a button, place your own template file in the
83
+ 'app/views/shareable/' directory of your app and prepend your filename with an underscore.
60
84
 
61
85
  E.g.: facebook_button -> app/views/shareable/_facebook.html.erb
62
86
 
63
87
  #### Facebook compatibility with Internet Explorer
64
- Add an XML namespace fb='http://ogp.me/ns/fb#' to the <html> tag of your view. Eg:
88
+ Add an XML namespace fb='http://ogp.me/ns/fb#' to the html tag of your view. Eg:
65
89
  ```no-highlight
66
90
  <html xmlns:fb="http://ogp.me/ns/fb#">
67
91
  ```
@@ -75,7 +99,7 @@ For horizontally aligned buttons, try this CSS:
75
99
  nav.share {display:inline-block;} /* shareable's nav tag */
76
100
  nav.share div {float:left; overflow:hidden;}
77
101
  nav.share iframe {max-height:20px; border:0; margin-top:0; padding-top:0;} /* if using medium sized buttons */
78
- #___plusone_0 {max-width:70px; font-size: default; !important}
102
+ #___plusone_0 {max-width:70px; font-size: default !important;}
79
103
  .twitter-share-button, .twitter-count-horizontal {max-width:80px;}
80
104
  .fb_iframe_widget span { vertical-align: top; }
81
105
  .fb_edge_widget_with_comment { vertical-align: top;}
@@ -84,18 +108,23 @@ nav.share iframe {max-height:20px; border:0; margin-top:0; padding-top:0;} /* if
84
108
  *+html .fb-like{display:inline}/* ie7 inline block fix*/
85
109
  ```
86
110
 
111
+ If you use the default configuration options of Shareable and styling above, the output should appear as:
112
+ <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
+
87
114
  Configuration
88
115
  ------------
89
- Use shareable's default configuration settings or add your own initializer named 'shareable.rb' to your app's 'config/initializers' directory.
116
+ Use shareable's [default configuration settings](https://github.com/hermango/shareable/blob/master/lib/shareable/config.rb) or add your own initializer named 'shareable.rb' to your app's 'config/initializers' directory.
90
117
 
91
- A generator is available for generating the default configuration file into the 'config/initializers' directory.
92
- Run the following generator command, then edit the generated file.
118
+ A generator is available for generating the default configuration file into your project's 'config/initializers' directory.
119
+ Run the following generator command, then edit the generated file as preferred.
93
120
 
94
121
  rails g shareable:config
95
122
 
96
- To Do:
97
- ---------
98
- - Add Tests.
99
- - More buttons.
123
+ Shareable expects string values for nearly all configuration options. Any values passed as configuration options 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 to the helper method) expects an array of strings. The other three configuration options expect boolean values and are the following:
124
+ * static_link
125
+ * button_only
126
+ * turbolinks
127
+
128
+ ---
100
129
 
101
- This project is based on Akira Matsuda's Kaminari project and uses the MIT-LICENSE. Suggestions, bug reports, criticism and all contributions welcome.
130
+ This project was inspired by Akira Matsuda's Kaminari project and uses the MIT-LICENSE. Suggestions, bug reports, criticism and all contributions welcome.
@@ -3,9 +3,10 @@
3
3
  <%= render "shareable/partials/link", :options => options.merge(:url=>"https://www.facebook.com/sharer.php?u=#{options[:url]}") %>
4
4
  <% end %>
5
5
  <% else %>
6
- <% unless options[:button_only] %>
6
+ <div id="fb-root"></div>
7
+ <% if !options[:button_only] && !options[:turbolinks] %>
7
8
  <%= output_once :facebook do %>
8
- <%= render "shareable/partials/scripts/facebook", :app_id => options[:app_id] %>
9
+ <%= render "shareable/partials/scripts/facebook", :app_id => options[:app_id] %>
9
10
  <% end %>
10
11
  <% end %>
11
12
  <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
@@ -13,4 +14,27 @@
13
14
  <%= html_attributes(options.slice(:url, :send, :layout, :show_faces, :width, :action, :font, :colorscheme, :ref, :share, :kid_directed_site), :data => true) %>
14
15
  ></div>
15
16
  <% end %>
17
+ <% if options[:turbolinks] && !options[:button_only] %>
18
+ <%= output_once :facebook do %>
19
+ <script>
20
+ if (typeof window.facebookLoaded == 'undefined') {
21
+ var facebookLoaded = false;
22
+ }
23
+ var __loadFacebook = function() {
24
+ if (facebookLoaded !== true) {
25
+ $('head').append("<script><%= raw(render 'shareable/partials/scripts/head/facebook', :app_id=>options[:app_id]) %><\/script>");
26
+ }
27
+ };
28
+ if (typeof $.turbo == 'undefined') {
29
+ $(function() {
30
+ return __loadFacebook();
31
+ });
32
+ }
33
+ //for jquery.turbolinks
34
+ else {
35
+ __loadFacebook();
36
+ }
37
+ </script>
38
+ <% end %>
39
+ <% end %>
16
40
  <% end %>
@@ -1,14 +1,41 @@
1
1
  <% if options[:static_link] %>
2
2
  <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
3
- <%= render "shareable/partials/link", :options => options.merge(:url=>"http://www.linkedin.com/shareArticle?url=#{options[:url]}&title=#{options[:title]}&summary=#{options[:description]}") %>
3
+ <%= render "shareable/partials/link", :options => options.merge(:url=>"https://www.linkedin.com/shareArticle?url=#{options[:url]}&title=#{options[:title]}&summary=#{options[:description]}") %>
4
4
  <% end %>
5
5
  <% else %>
6
- <% unless options[:button_only] %>
7
- <%= render "shareable/partials/scripts/linkedin" %>
6
+ <% if !options[:button_only] && !options[:turbolinks] %>
7
+ <%= output_once :linkedin do %>
8
+ <%= render "shareable/partials/scripts/linkedin" %>
9
+ <% end %>
8
10
  <% end %>
9
11
  <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
10
12
  <script type="IN/Share"
11
13
  <%= html_attributes(options.slice(:url, :counter, :onerror, :onsuccess, :showzero), :data => true) %>
12
14
  ></script>
13
15
  <% end %>
16
+ <% if options[:turbolinks] && !options[:button_only] %>
17
+ <%= output_once :linkedin do %>
18
+ <script type="text/javascript">
19
+ if (typeof window.linkedinLoaded == 'undefined') {
20
+ var linkedinLoaded = false;
21
+ }
22
+ var __loadLinkedin = function() {
23
+ if (linkedinLoaded !== true) {
24
+ $('head').append("<script><%= raw(render 'shareable/partials/scripts/head/linkedin') %><\/script>");
25
+ }
26
+ };
27
+ if (typeof $.turbo == 'undefined') {
28
+ $(function() {
29
+ return __loadLinkedin();
30
+ });
31
+ }
32
+ //for jquery.turbolinks
33
+ else {
34
+ if (linkedinLoaded !== true) {
35
+ __loadLinkedin();
36
+ }
37
+ }
38
+ </script>
39
+ <% end %>
40
+ <% end %>
14
41
  <% end %>
@@ -1,17 +1,35 @@
1
1
  <% if options[:static_link] %>
2
2
  <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
3
- <%= render "shareable/partials/link", :options => options.merge(:url=>"http://pinterest.com/pin/create/button/?url=#{options[:url]}&description=#{options[:description]}&media=#{options[:media]}") %>
3
+ <%= render "shareable/partials/link", :options => options.merge(:url=>"https://pinterest.com/pin/create/button/?url=#{options[:url]}&description=#{options[:description]}&media=#{options[:media]}") %>
4
4
  <% end %>
5
5
  <% else %>
6
6
  <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
7
7
  <a data-pin-config="<%= options[:pin_config] %>"
8
8
  href="//pinterest.com/pin/create/button/?url=<%= options[:url] %><%= raw('&media=' + options[:media]) unless options[:media].blank? %><%= raw('&description=' + options[:description]) unless options[:description].blank? %>"
9
- data-pin-do="<%= options[:pin_do] %>" >
9
+ data-pin-do="<%= options[:pin_do] %>" data-pin-shape="<%= options[:pin_shape] %>" data-pin-height="<%= options[:pin_height] %>" data-pin-color="<%= options[:pin_color] %>" >
10
10
  <img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" title="<%= options[:title]%>" alt="<%= options[:alt] %>" /></a>
11
11
  <% end %>
12
12
  <% unless options[:button_only] %>
13
13
  <%= output_once :pinterest do %>
14
- <%= render "shareable/partials/scripts/pinterest" %>
14
+ <% if options[:turbolinks] %>
15
+ <script>
16
+ var Pinterest;
17
+ Pinterest = {
18
+ load: function() {
19
+ delete window["PIN_" + ~~((new Date).getTime() / 864e5)];
20
+ return $.getScript("//assets.pinterest.com/js/pinit.js");
21
+ }
22
+ };
23
+ $(function() {
24
+ return Pinterest.load();
25
+ });
26
+ $(document).on('page:load', function() {
27
+ return Pinterest.load();
28
+ });
29
+ </script>
30
+ <% else %>
31
+ <%= render "shareable/partials/scripts/pinterest" %>
32
+ <% end %>
15
33
  <% end %>
16
34
  <% end %>
17
35
  <% end %>
@@ -1,7 +1,8 @@
1
1
  <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
2
2
  <% if options[:static_link] %>
3
- <%= render "shareable/partials/link", :options => options.merge(:url=>"http://www.reddit.com/submit?url=#{options[:url]}&title=#{options[:title]}") %>
3
+ <%= render "shareable/partials/link", :options => options.merge(:url=>"https://ssl.reddit.com/submit?url=#{options[:url]}&title=#{options[:title]}") %>
4
4
  <% else %>
5
+ <% if !options[:turbolinks] %>
5
6
  <script type="text/javascript">
6
7
  reddit_url='<%= options[:url] %>';
7
8
  reddit_target='<%= options[:target]%>';
@@ -10,10 +11,22 @@
10
11
  reddit_bordercolor='<%= options[:bordercolor] %>';
11
12
  reddit_newwindow='<%= options[:newwindow] %>';
12
13
  </script>
13
- <% unless options[:button_only] %>
14
+ <% unless options[:button_only] %>
14
15
  <script type="text/javascript"
15
- src="<%= raw((options[:btnsrc].blank? ? ('//www.reddit.com/static/button/button' + options[:type] + '.js?i=' + options[:points]) : options[:btnsrc]) + '&styled=' + options[:styled]) %>">
16
+ src="<%= raw(options[:btnsrc].blank? ? ('//www.reddit.com/static/button/button' + options[:type] + '.js') : ('//www.reddit.com/buttonlite.js?i=' + options[:points] + '&styled=' + options[:styled])) %>">
16
17
  </script>
18
+ <% end %>
19
+ <% else #if turbolinks is enabled then use this iframe hack %>
20
+ <%# TODO: move to reddit tag class %>
21
+ <% unless options[:type].blank? || options[:button_only] %>
22
+ <% width, height = case options[:type] %>
23
+ <% when '1' then ['120', '22'] %>
24
+ <% when '2' then ['51', '69'] %>
25
+ <% when '3' then ['69', '52'] %>
26
+ <% else ['0', '0'] %>
27
+ <% end %>
28
+ <iframe src="//www.reddit.com/static/button/button<%= options[:type] %>.html?width=<%= width %>&url=<%= url_encode(options[:url]) %>&target=<%= options[:target]%>&title=<%= url_encode(options[:title]) %>&bgcolor=<%= options[:color] %>&bordercolor=<%= options[:bordercolor] %>&newwindow=<%= options[:newwindow] %>" height="<%= height %>" width="<%= width %>" scrolling="no" frameborder="0"></iframe>
29
+ <% end %>
17
30
  <% end %>
18
31
  <% end %>
19
32
  <% end %>
@@ -4,8 +4,8 @@
4
4
  <% end %>
5
5
  <% else %>
6
6
  <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
7
- <a href="http://www.tumblr.com/share/link?url=<%= options[:url] %>&name=<%= options[:title] %>&description=<%= options[:description] %>" title="Share on Tumblr"
8
- style="display:inline-block; text-indent:-9999px; overflow:hidden; width:<%= options[:width] %>px; height:20px; background:url('http://platform.tumblr.com/v1/<%= options[:background] %>') top left no-repeat transparent;">Share on Tumblr</a>
7
+ <a href="https://www.tumblr.com/share/link?url=<%= options[:url] %>&name=<%= options[:title] %>&description=<%= options[:description] %>" title="Share on Tumblr"
8
+ style="display:inline-block; text-indent:-9999px; overflow:hidden; width:<%= options[:width] %>px; height:20px; background:url('https://platform.tumblr.com/v1/share_<%= options[:background] %>.png') top left no-repeat transparent; vertical-align:top;" class="tumblr-button">Share on Tumblr</a>
9
9
  <% end %>
10
10
  <% unless options[:button_only] %>
11
11
  <%= output_once :tumblr do %>
@@ -3,17 +3,17 @@
3
3
  <%= render "shareable/partials/link", :options => options.merge(:url=>"https://twitter.com/intent/tweet?url=#{options[:url]}&text=#{options[:text]}&hashtags=#{options[:hashtags]}") %>
4
4
  <% end %>
5
5
  <% else %>
6
- <% if tl = (defined?(Turbolinks) && !(options[:button_only])) %>
6
+ <% if (options[:turbolinks] && !options[:button_only]) %>
7
7
  <%= output_once :twitter do %>
8
8
  <script src="//platform.twitter.com/widgets.js"></script>
9
9
  <% end %>
10
10
  <% end %>
11
11
  <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
12
- <a href="http://twitter.com/share" class="twitter-share-button"
12
+ <a href="https://twitter.com/share" class="twitter-share-button"
13
13
  <%= html_attributes(options.slice(:url, :via, :text, :related, :count, :lang, :counturl, :hashtags, :size, :dnt), :data => true) %>
14
14
  >Tweet</a>
15
15
  <% end %>
16
- <% unless tl %>
16
+ <% unless (options[:button_only] || options[:turbolinks]) %>
17
17
  <%= output_once :twitter do %>
18
18
  <%= render "shareable/partials/scripts/twitter" %>
19
19
  <% end %>
@@ -1,9 +1,9 @@
1
- <div id="fb-root"></div>
2
- <script>(function(d, s, id) {
1
+ <script>
2
+ (function(d, s, id) {
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/all.js#xfbml=1<%= raw('&appId=' + app_id) unless app_id.empty? %>";
6
+ js.src = "//connect.facebook.net/en_US/all.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>
@@ -4,4 +4,4 @@
4
4
  po.src = 'https://apis.google.com/js/plusone.js';
5
5
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
6
6
  })();
7
- </script>
7
+ </script>
@@ -1 +1 @@
1
- <script src="http://platform.tumblr.com/v1/share.js"></script>
1
+ <script src="//platform.tumblr.com/v1/share.js"></script>
@@ -0,0 +1,38 @@
1
+ var bindFacebookEvents, fb_events_bound, fb_root, initializeFacebookSDK, loadFacebookSDK, restoreFacebookRoot, saveFacebookRoot; \
2
+ fb_root = null; \
3
+ fb_events_bound = false; \
4
+ $(function() { \
5
+ loadFacebookSDK(); \
6
+ if (!fb_events_bound) { \
7
+ return bindFacebookEvents(); \
8
+ } \
9
+ }); \
10
+ bindFacebookEvents = function() { \
11
+ $(document).on('page:fetch', saveFacebookRoot).on('page:change', restoreFacebookRoot).on('page:load', function() { \
12
+ return typeof FB !== 'undefined' && FB !== null ? FB.XFBML.parse() : void 0; \
13
+ }); \
14
+ return fb_events_bound = true; \
15
+ }; \
16
+ saveFacebookRoot = function() { \
17
+ return fb_root = $('#fb-root').detach(); \
18
+ }; \
19
+ restoreFacebookRoot = function() { \
20
+ if ($('#fb-root').length > 0) { \
21
+ return $('#fb-root').replaceWith(fb_root); \
22
+ } else { \
23
+ return $('body').append(fb_root); \
24
+ } \
25
+ }; \
26
+ loadFacebookSDK = function() { \
27
+ window.fbAsyncInit = initializeFacebookSDK; \
28
+ return $.getScript('//connect.facebook.net/en_US/all.js', function() { facebookLoaded = true; }); \
29
+ }; \
30
+ initializeFacebookSDK = function() { \
31
+ return FB.init({ \
32
+ appId: '<%= app_id.to_s if defined?(app_id) %>', \
33
+ status: true, \
34
+ cookie: true, \
35
+ version: 'v2.0', \
36
+ xfbml: true \
37
+ }); \
38
+ };
@@ -0,0 +1,14 @@
1
+ var loadLinkedIn; \
2
+ $(function() { \
3
+ if(linkedinLoaded !== true) { \
4
+ loadLinkedIn(); \
5
+ return $(document).on('page:load', loadLinkedIn); \
6
+ } \
7
+ }); \
8
+ loadLinkedIn = function() { \
9
+ delete IN; \
10
+ $.getScript('//platform.linkedin.com/in.js', function() {linkedinLoaded = true;}); \
11
+ return { \
12
+ lang: 'en_US' \
13
+ }; \
14
+ };
@@ -1,93 +1,99 @@
1
1
  Shareable.configure do |config|
2
2
 
3
- # valid names are:
4
- # twitter facebook pinterest reddit google_plus linkedin tumblr stumble_upon
3
+ ## configuration "names" determines which social buttons are rendered. The order the buttons are
4
+ ## displayed in is decided by the same order as listed here.
5
+ ## Valid names are: twitter facebook linkedin pinterest google_plus reddit tumblr stumble_upon
5
6
  #config.names = %w[ twitter facebook linkedin pinterest google_plus reddit tumblr stumble_upon ]
6
7
 
7
- #config.button_only=false # omit initializing javacript. Only button code is rendered.
8
- #config.static_link=false # renders non-javascript html links.
8
+ #config.static_link=false # renders html links instead of javascript buttons.
9
+ #config.button_only=false # omit initializing javacript code. Only button code is rendered.
10
+ #config.turbolinks=false # set to true to enable turbolinks fixes. Requires jquery to work!
9
11
 
10
- ##############
11
- #facebook
12
- ##############
13
- #config.app_id=''
12
+ ###############
13
+ ##facebook
14
+ ###############
15
+ #config.app_id='' # required if using facebook button!
14
16
  #config.send= 'false'
15
- #config.layout=''
16
- #config.show_faces=''
17
- #config.action=''
17
+ #config.layout='' # 'standard', 'button_count', 'button' or 'box_count'. '' defaults to 'standard'.
18
+ #config.show_faces='' # 'true' or 'false'. '' defaults to 'false'. Don't set to 'true', if kid_directed_site is also 'true'.
19
+ #config.action='' # 'like' or 'recommend'. '' defaults to 'like'.
18
20
  #config.font=''
19
- #config.colorscheme=''
21
+ #config.colorscheme='' # 'light' or 'dark'. '' defaults to 'light'.
20
22
  #config.ref=''
21
- #config.share=''
22
- #config.kid_directed_site=''
23
+ #config.share='' # 'true' or 'false'. '' defaults to 'false'.
24
+ #config.kid_directed_site='' # 'true' or 'false'. '' defaults to 'false'. Facebook assumes your site is not kid friendly.
23
25
 
24
- ##############
25
- #google_plus
26
- ##############
27
- #config.annotation='bubble'
28
- #config.align=''
29
- #config.expand_to=''
30
- #config.callback=''
26
+ ###############
27
+ ##google_plus
28
+ ###############
29
+ #config.annotation='bubble' # 'none', 'bubble' or 'inline'. '' defaults to 'bubble'.
30
+ #config.align='' # 'left' or 'right'. '' defaults to 'left'.
31
+ #config.expand_to='' # comma separated list of 'top', 'right', 'bottom' and 'left'.
32
+ #config.callback=''
31
33
  #config.onstartinteraction=''
32
34
  #config.onendinteraction=''
33
- #config.recommendations='false'
35
+ #config.recommendations='false' # 'true' or 'false'. '' defaults to 'true'.
34
36
 
35
- ##############
36
- #linkedin
37
- ##############
38
- #config.counter = 'right'
39
- #config.onsuccess = ''
37
+ ###############
38
+ ##linkedin
39
+ ###############
40
+ #config.counter = 'right' # 'right', 'top' or ''. '' hides counter.
41
+ #config.onsuccess = '' # name of a javascript function to fire if url is successfully shared.
40
42
  #config.onerror = ''
41
- #config.showzero = 'true'
43
+ #config.showzero = 'true' # 'true' or 'false'.
42
44
 
43
- ##############
44
- #pinterest
45
- ##############
46
- #config.pin_config = 'none'
47
- #config.pin_do = 'buttonPin'
48
- #config.alt='' # alternate text for image tag
45
+ ###############
46
+ ##pinterest
47
+ ###############
48
+ #config.pin_config = 'beside' # 'beside', 'above' or 'none'.
49
+ #config.pin_do = 'buttonPin' # 'buttonPin' or 'buttonBookmark'.
50
+ #config.pin_shape='' # 'round' or ''.
51
+ #config.pin_height='' # '28' or ''. '28' is for large button.
52
+ #config.pin_color='' # 'red', 'white' or 'gray'. '' defaults to 'gray'.
53
+ #config.alt='' # alternate text for image tag.
49
54
  #config.media=''
50
55
 
51
- ##############
52
- #reddit
53
- ##############
54
- #config.target=''
56
+ ###############
57
+ ##reddit
58
+ ###############
59
+ #config.target='' # subreddit name, eg: 'rails'
55
60
  #config.color=''
56
61
  #config.bordercolor=''
57
- #config.styled='off'
62
+ #config.styled='off' # 'off' or ''. Only used when btnsrc is not blank.
58
63
  #config.newwindow='1'
59
64
  #config.btnsrc='' # alternate reddit button url, eg: 'http://www.reddit.com/buttonlite.js?i=1'
60
- #config.type= '1' # button type, eg: 1 to n
61
- #config.points = '1' # points style, eg: 0 to 5
65
+ #config.type= '1' # '1' to '3'.
66
+ #config.points = '1' # '0' to '5'. Only used when btnsrc is not blank.
62
67
 
63
- ##############
64
- #twitter
65
- ##############
66
- #config.via='tweetbutton'
67
- #config.text=''
68
- #config.related=''
69
- #config.count='horizontal'
68
+ ###############
69
+ ##twitter
70
+ ###############
71
+ #config.via='' # screen name of the user to attribute the tweet to.
72
+ #config.text='' # default tweet text. If blank, defaults to value of config.title.
73
+ #config.related='' # related accounts
74
+ #config.count='horizontal' # 'none', 'horizontal' or 'vertical'. '' defaults to 'horizontal'.
70
75
  #config.lang='en'
71
- #config.counturl=''
72
- #config.hashtags=''
73
- #config.size='medium'
74
- #config.dnt=''
76
+ #config.counturl='' # url to which your shared url resolves
77
+ #config.hashtags='' # comma separated hashtags appended to tweet text
78
+ #config.dnt='' # 'true' or 'false'. 'true' tailors content and suggestions for twitter users.
75
79
 
76
- ##############
77
- #stumble_upon
78
- ##############
79
- #config.badge_layout='1'
80
+ ###############
81
+ ##stumble_upon
82
+ ###############
83
+ #config.badge_layout='1' # '1' to '6'.
80
84
 
81
- ##############
82
- #tumblr
83
- ##############
84
- #config.background='share_1.png'
85
-
86
- ##############
87
- #shared configuration options
88
- ##############
89
- #config.width='80' # used by facebook and tumblr
90
- #config.title= '' # used by linkedin, pinterest, reddit, stumbleupon and tumblr
91
- #config.description='' # used by linkedin and tumblr
85
+ ###############
86
+ ##tumblr
87
+ ###############
88
+ #config.background='1' # '1' to '4'. Or '1T', '2T', '3T' or '4T'.
92
89
 
90
+ ###############
91
+ ##shared configuration options
92
+ ###############
93
+ #config.width='80' # used by facebook, google_plus and tumblr.
94
+ #config.title= '' # used by linkedin, pinterest, reddit, stumbleupon and tumblr.
95
+ #config.description='' # used by linkedin and tumblr.
96
+ #config.size='medium' # used by twitter and google_plus.
97
+ ## google_plus config.size can be 'small', 'medium', 'standard' and 'tall'. Default is 'standard'. Shareable uses 'medium'.
98
+ ## twitter config.size can be 'medium' or 'large'. Default is medium'.
93
99
  end
@@ -15,101 +15,107 @@ module Shareable
15
15
  class Configuration #:nodoc:
16
16
  include ActiveSupport::Configurable
17
17
  config_accessor :names, :url, :send, :layout, :show_faces, :title, :alt, :target, :app_id,
18
- :width, :action, :font, :colorscheme, :ref, :annotation, :align, :expand_to, :callback,
19
- :onstartinteraction, :onendinteraction, :pin_config, :pin_do, :media, :color,
18
+ :width, :action, :font, :colorscheme, :ref, :annotation, :align, :expand_to, :callback, :color,
19
+ :onstartinteraction, :onendinteraction, :pin_config, :pin_do, :pin_shape, :pin_height, :pin_color, :media,
20
20
  :bordercolor, :btnsrc, :via, :text, :related, :count, :lang, :counturl, :hashtags, :size, :dnt,
21
21
  :type, :styled, :newwindow, :description, :counter, :onsuccess, :onerror, :showzero,
22
22
  :recommendations, :points, :badge_layout, :background, :share, :kid_directed_site,
23
- :button_only, :static_link
23
+ :button_only, :static_link, :turbolinks
24
24
  end
25
25
 
26
26
  configure do |config|
27
27
  config.names = %w[ twitter facebook linkedin pinterest google_plus reddit ]
28
28
 
29
- config.button_only=false # omit initializing javacript. Only button code is rendered.
30
- config.static_link=false # renders non-javascript html links.
29
+ config.static_link=false # renders html links instead of javascript buttons.
30
+ config.button_only=false # omit initializing javacript code. Only button code is rendered.
31
+ config.turbolinks=false # set to true to enable turbolinks fixes. Requires jquery to work!
31
32
 
32
33
  ##############
33
34
  #facebook
34
35
  ##############
35
- config.app_id = ''
36
+ config.app_id = '' # required if using facebook button!
36
37
  config.send= 'false'
37
- config.layout='button_count'
38
- config.show_faces=''
39
- config.action=''
38
+ config.layout='button_count' # 'standard', 'button_count', 'button' or 'box_count'. '' defaults to 'standard'.
39
+ config.show_faces='' # 'true' or 'false'. '' defaults to 'false'. Don't set to 'true', if kid_directed_site is also 'true'.
40
+ config.action='' # 'like' or 'recommend'. '' defaults to 'like'.
40
41
  config.font=''
41
- config.colorscheme=''
42
+ config.colorscheme='' # 'light' or 'dark'. '' defaults to 'light'.
42
43
  config.ref=''
43
- config.share=''
44
- config.kid_directed_site=''
44
+ config.share='' # 'true' or 'false'. '' defaults to 'false'.
45
+ config.kid_directed_site='' # 'true' or 'false'. '' defaults to 'false'. Facebook assumes your site is not kid friendly.
45
46
 
46
47
  ##############
47
48
  #google_plus
48
49
  ##############
49
- config.annotation='bubble'
50
- config.recommendations='false'
51
- config.align=''
52
- config.expand_to=''
50
+ config.annotation='bubble' # 'none', 'bubble' or 'inline'. '' defaults to 'bubble'.
51
+ config.align='' # 'left' or 'right'. '' defaults to 'left'.
52
+ config.expand_to='' # comma separated list of 'top', 'right', 'bottom' and 'left'.
53
53
  config.callback=''
54
54
  config.onstartinteraction=''
55
55
  config.onendinteraction=''
56
+ config.recommendations='false' # 'true' or 'false'. '' defaults to 'true'.
56
57
 
57
58
  ##############
58
59
  #linkedin
59
60
  ##############
60
- config.counter = 'right'
61
- config.onsuccess = ''
61
+ config.counter = 'right' # 'right', 'top' or ''. '' hides counter.
62
+ config.onsuccess = '' # name of a javascript function to fire if url is successfully shared.
62
63
  config.onerror = ''
63
- config.showzero = 'true'
64
+ config.showzero = 'true' # 'true' or 'false'.
64
65
 
65
66
  ##############
66
67
  #pinterest
67
68
  ##############
68
- config.pin_config = 'beside'
69
- config.pin_do = 'buttonPin'
70
- config.alt='' # alternate text for image tag
69
+ config.pin_config = 'beside' # 'beside', 'above' or 'none'.
70
+ config.pin_do = 'buttonPin' # 'buttonPin' or 'buttonBookmark'.
71
+ config.pin_shape='' # 'round' or ''.
72
+ config.pin_height='' # '28' or ''. '28' is for large button.
73
+ config.pin_color='' # 'red', 'white' or 'gray'. '' defaults to 'gray'.
74
+ config.alt='' # alternate text for image tag.
71
75
  config.media=''
72
76
 
73
77
  ##############
74
78
  #reddit
75
79
  ##############
76
- config.target=''
80
+ config.target='' # subreddit name, eg: 'rails'
77
81
  config.color=''
78
82
  config.bordercolor=''
79
- config.styled='off'
83
+ config.styled='off' # 'off' or ''. Only used when btnsrc is not blank.
80
84
  config.newwindow='1'
81
85
  config.btnsrc='' # alternate reddit button url, eg: 'http://www.reddit.com/buttonlite.js?i=1'
82
- config.type= '1' # button type, eg: 1 to n
83
- config.points = '1' # points style, eg: 0 to 5
86
+ config.type= '1' # '1' to '3'.
87
+ config.points = '1' # '0' to '5'. Only used when btnsrc is not blank.
84
88
 
85
89
  ##############
86
90
  #twitter
87
91
  ##############
88
- config.via='tweetbutton'
89
- config.text=''
90
- config.related=''
91
- config.count='horizontal'
92
+ config.via='' # screen name of the user to attribute the tweet to.
93
+ config.text='' # default tweet text. If blank, defaults to value of config.title.
94
+ config.related='' # related accounts
95
+ config.count='horizontal' # 'none', 'horizontal' or 'vertical'. '' defaults to 'horizontal'.
92
96
  config.lang='en'
93
- config.counturl=''
94
- config.hashtags=''
95
- config.size='medium'
96
- config.dnt=''
97
+ config.counturl='' # url to which your shared url resolves
98
+ config.hashtags='' # comma separated hashtags appended to tweet text
99
+ config.dnt='' # 'true' or 'false'. 'true' tailors content and suggestions for twitter users.
97
100
 
98
101
  ##############
99
102
  #stumble_upon
100
103
  ##############
101
- config.badge_layout='1'
104
+ config.badge_layout='1' # '1' to '6'.
102
105
 
103
106
  ##############
104
107
  #tumblr
105
108
  ##############
106
- config.background='share_1.png'
109
+ config.background='1' # '1' to '4'. Or '1T', '2T', '3T' or '4T'.
107
110
 
108
111
  ##############
109
112
  #shared configuration options
110
113
  ##############
111
- config.width='80' # used by facebook and tumblr
112
- config.title= '' # used by linkedin, pinterest, reddit, stumbleupon and tumblr
113
- config.description='' # used by linkedin and tumblr
114
+ config.width='80' # used by facebook, google_plus and tumblr.
115
+ config.title= '' # used by linkedin, pinterest, reddit, stumbleupon and tumblr.
116
+ config.description='' # used by linkedin and tumblr.
117
+ config.size='medium' # used by twitter and google_plus.
118
+ # google_plus config.size can be 'small', 'medium', 'standard' and 'tall'. Default is 'standard'. Shareable uses 'medium'.
119
+ # twitter config.size can be 'medium' or 'large'. Default is medium'.
114
120
  end
115
121
  end
@@ -16,7 +16,7 @@ module Shareable
16
16
  :facebook => [ :app_id, :send, :layout, :show_faces, :width, :action, :font, :colorscheme, :ref, :share, :kid_directed_site ],
17
17
  :google_plus => [ :annotation, :recommendations, :align, :expand_to, :callback, :onstartinteraction, :onendinteraction, :size, :width ],
18
18
  :linkedin => [ :counter, :onsuccess, :onerror, :showzero, :title, :description ],
19
- :pinterest => [ :pin_config, :pin_do, :title, :alt, :media, :description ],
19
+ :pinterest => [ :pin_config, :pin_do, :title, :alt, :media, :description, :pin_shape, :pin_height, :pin_color ],
20
20
  :reddit => [ :title, :target, :color, :bordercolor, :type, :styled, :newwindow, :btnsrc, :points ],
21
21
  :stumble_upon => [ :badge_layout, :title ],
22
22
  :tumblr => [ :title, :description, :width, :background ],
@@ -1,3 +1,3 @@
1
1
  module Shareable
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.3"
3
3
  end
@@ -9,21 +9,16 @@ Gem::Specification.new do |s|
9
9
  s.version = Shareable::VERSION
10
10
  s.authors = ["Hermango"]
11
11
  s.homepage = "http://github.com/hermango/shareable"
12
- s.summary = "Simple and unobtrusive gem for adding social links to your Rails app."
13
- s.description = "Add social sharing links to a view in your Rails app with one method call. The configuration options for each social link are customizable. Please see read me doc for more details."
12
+ s.summary = "Simple and unobtrusive gem for adding social links to your Rails app. Rails 3 and 4 supported."
13
+ s.description = "Add social sharing functionality to your Rails app with one method call. Shareable allows you the choice of displaying javascript buttons or static links. Configuration options for each social site are ready-to-use and entirely customizable. Please see readme for more details."
14
14
  s.require_paths = ['lib']
15
15
  s.licenses = ['MIT']
16
16
  s.files = `git ls-files`.split($/)
17
17
 
18
18
  #s.test_files = Dir["test/**/*"]
19
19
 
20
- s.add_dependency 'activesupport', ['>= 3.0.0']
21
- s.add_dependency 'actionpack', ['>= 3.0.0']
22
-
23
- s.add_development_dependency 'bundler', ['>= 1.0.0']
24
- s.add_development_dependency 'tzinfo', ['>= 0']
25
- s.add_development_dependency 'rspec', ['>= 0']
26
- s.add_development_dependency 'rr', ['>= 0']
27
- s.add_development_dependency 'capybara', ['>= 1.0']
20
+ s.add_dependency 'activesupport', '>= 3.0.0'
21
+ s.add_dependency 'actionpack', '>= 3.0.0'
28
22
 
23
+ s.add_development_dependency 'bundler', '>= 1.0.0'
29
24
  end
metadata CHANGED
@@ -1,123 +1,67 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shareable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hermango
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-03 00:00:00.000000000 Z
11
+ date: 2014-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: actionpack
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.0.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.0.0
55
- - !ruby/object:Gem::Dependency
56
- name: tzinfo
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rr
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '>='
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: capybara
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - '>='
102
- - !ruby/object:Gem::Version
103
- version: '1.0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - '>='
109
- - !ruby/object:Gem::Version
110
- version: '1.0'
111
- description: Add social sharing links to a view in your Rails app with one method
112
- call. The configuration options for each social link are customizable. Please see
113
- read me doc for more details.
55
+ description: Add social sharing functionality to your Rails app with one method call.
56
+ Shareable allows you the choice of displaying javascript buttons or static links.
57
+ Configuration options for each social site are ready-to-use and entirely customizable.
58
+ Please see readme for more details.
114
59
  email:
115
60
  executables: []
116
61
  extensions: []
117
62
  extra_rdoc_files: []
118
63
  files:
119
- - .DS_Store
120
- - .gitignore
64
+ - ".gitignore"
121
65
  - Gemfile
122
66
  - MIT-LICENSE
123
67
  - README.md
@@ -140,6 +84,8 @@ files:
140
84
  - app/views/shareable/partials/scripts/_stumble_upon.html.erb
141
85
  - app/views/shareable/partials/scripts/_tumblr.html.erb
142
86
  - app/views/shareable/partials/scripts/_twitter.html.erb
87
+ - app/views/shareable/partials/scripts/head/_facebook.html.erb
88
+ - app/views/shareable/partials/scripts/head/_linkedin.html.erb
143
89
  - lib/generators/shareable/config_generator.rb
144
90
  - lib/generators/shareable/templates/shareable_config.rb
145
91
  - lib/shareable.rb
@@ -162,18 +108,19 @@ require_paths:
162
108
  - lib
163
109
  required_ruby_version: !ruby/object:Gem::Requirement
164
110
  requirements:
165
- - - '>='
111
+ - - ">="
166
112
  - !ruby/object:Gem::Version
167
113
  version: '0'
168
114
  required_rubygems_version: !ruby/object:Gem::Requirement
169
115
  requirements:
170
- - - '>='
116
+ - - ">="
171
117
  - !ruby/object:Gem::Version
172
118
  version: '0'
173
119
  requirements: []
174
120
  rubyforge_project:
175
- rubygems_version: 2.0.14
121
+ rubygems_version: 2.2.2
176
122
  signing_key:
177
123
  specification_version: 4
178
- summary: Simple and unobtrusive gem for adding social links to your Rails app.
124
+ summary: Simple and unobtrusive gem for adding social links to your Rails app. Rails
125
+ 3 and 4 supported.
179
126
  test_files: []
data/.DS_Store DELETED
Binary file