shareable 0.0.3 → 1.0.0

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.
Files changed (28) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/app/views/shareable/_facebook.html.erb +16 -20
  4. data/app/views/shareable/_google_plus.html.erb +14 -19
  5. data/app/views/shareable/_linkedin.html.erb +13 -7
  6. data/app/views/shareable/_pinterest.html.erb +15 -22
  7. data/app/views/shareable/_reddit.html.erb +10 -2
  8. data/app/views/shareable/_social_buttons.html.erb +7 -7
  9. data/app/views/shareable/_stumble_upon.html.erb +14 -0
  10. data/app/views/shareable/_tumblr.html.erb +15 -0
  11. data/app/views/shareable/_twitter.html.erb +20 -26
  12. data/app/views/shareable/partials/_button_wrapper.html.erb +1 -0
  13. data/app/views/shareable/partials/_link.html.erb +1 -0
  14. data/app/views/shareable/partials/_parent_wrapper.html.erb +3 -0
  15. data/app/views/shareable/partials/scripts/_facebook.html.erb +9 -0
  16. data/app/views/shareable/partials/scripts/_google_plus.html.erb +7 -0
  17. data/app/views/shareable/partials/scripts/_linkedin.html.erb +1 -0
  18. data/app/views/shareable/partials/scripts/_pinterest.html.erb +17 -0
  19. data/app/views/shareable/partials/scripts/_stumble_upon.html.erb +7 -0
  20. data/app/views/shareable/partials/scripts/_tumblr.html.erb +1 -0
  21. data/app/views/shareable/partials/scripts/_twitter.html.erb +7 -0
  22. data/lib/generators/shareable/templates/shareable_config.rb +27 -4
  23. data/lib/shareable/config.rb +24 -4
  24. data/lib/shareable/helpers/action_view_extension.rb +16 -0
  25. data/lib/shareable/helpers/social_buttons.rb +27 -16
  26. data/lib/shareable/helpers/tags.rb +113 -12
  27. data/lib/shareable/version.rb +1 -1
  28. metadata +34 -37
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 19c19e220407ca941b623e9fa1193f404741adbc
4
+ data.tar.gz: 214c19f7a01b047c536a5b26bf32676161e0988e
5
+ SHA512:
6
+ metadata.gz: 91f23d8a1f33e77d7421c9bbbe91c617bce9361bbc07918cdb5c49e04bf8f0cd5f6ff06607a17ed7e9c773bb67286837f5968b6e0cce7eb5de3e1267acb2d938
7
+ data.tar.gz: 01b71ab520dcb4575d26f567013eb370060bf8ec6e99fe4f89ae98724da890d834f7b61339b82158478a131a2f9ac76829c35cdc4be34f63a44505426df49bbd
Binary file
@@ -1,20 +1,16 @@
1
- <%= output_once :facebook do %>
2
- <div id="fb-root"></div>
3
- <script>(function(d, s, id) {
4
- var js, fjs = d.getElementsByTagName(s)[0];
5
- if (d.getElementById(id)) return;
6
- js = d.createElement(s); js.id = id;
7
- js.src = "//connect.facebook.net/en_US/all.js#xfbml=1<%= raw('&appId=' + options[:app_id]) unless options[:app_id].empty? %>";
8
- fjs.parentNode.insertBefore(js, fjs);
9
- }(document, 'script', 'facebook-jssdk'));</script>
10
- <% end %>
11
-
12
- <fb:like href='<%= options[:url] %>'
13
- send='<%= options[:send] %>'
14
- layout='<%= options[:layout] %>'
15
- show_faces='<%= options[:show_faces] %>'
16
- width='<%= options[:width] %>'
17
- action='<%= options[:action] %>'
18
- font='<%= options[:font] %>'
19
- colorscheme='<%= options[:colorscheme] %>'
20
- ref='<%= options[:ref] %>' ></fb:like>
1
+ <% if options[:static_link] %>
2
+ <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
3
+ <%= render "shareable/partials/link", :options => options.merge(:url=>"https://www.facebook.com/sharer.php?u=#{options[:url]}") %>
4
+ <% end %>
5
+ <% else %>
6
+ <% unless options[:button_only] %>
7
+ <%= output_once :facebook do %>
8
+ <%= render "shareable/partials/scripts/facebook", :app_id => options[:app_id] %>
9
+ <% end %>
10
+ <% end %>
11
+ <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
12
+ <div class="fb-like"
13
+ <%= html_attributes(options.slice(:url, :send, :layout, :show_faces, :width, :action, :font, :colorscheme, :ref, :share, :kid_directed_site), :data => true) %>
14
+ ></div>
15
+ <% end %>
16
+ <% end %>
@@ -1,21 +1,16 @@
1
- <div class='g-plusone gplusshare'
2
- data-href='<%= options[:url] %>'
3
- data-size='<%= options[:size] %>'
4
- data-annotation='<%= options[:annotation] %>'
5
- data-width='<%= options[:width] %>'
6
- data-align='<%= options[:align] %>'
7
- data-expandTo='<%= options[:expand_to] %>'
8
- data-callback='<%= options[:callback] %>'
9
- data-onstartinteraction='<%= options[:onstartinteraction] %>'
10
- data-onendinteraction='<%= options[:onendinteraction] %>'
11
- data-recommendations='<%= options[:recommendations] %>'
1
+ <% if options[:static_link] %>
2
+ <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
3
+ <%= render "shareable/partials/link", :options => options.merge(:url=>"https://plus.google.com/share?url=#{options[:url]}") %>
4
+ <% end %>
5
+ <% else %>
6
+ <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
7
+ <div class="g-plusone gplusshare"
8
+ <%= html_attributes(options.slice(:url, :size, :annotation, :width, :align, :expand_to, :callback, :onstartinteraction, :onendinteraction, :recommendations), :data => true) %>
12
9
  ></div>
13
- <%= output_once :google_plus do %>
14
- <script type="text/javascript">
15
- (function() {
16
- var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
17
- po.src = 'https://apis.google.com/js/plusone.js';
18
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
19
- })();
20
- </script>
10
+ <% end %>
11
+ <% unless options[:button_only] %>
12
+ <%= output_once :google_plus do %>
13
+ <%= render "shareable/partials/scripts/google_plus" %>
14
+ <% end %>
15
+ <% end %>
21
16
  <% end %>
@@ -1,8 +1,14 @@
1
- <script src="//platform.linkedin.com/in.js" type="text/javascript"></script>
1
+ <% if options[:static_link] %>
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]}") %>
4
+ <% end %>
5
+ <% else %>
6
+ <% unless options[:button_only] %>
7
+ <%= render "shareable/partials/scripts/linkedin" %>
8
+ <% end %>
9
+ <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
2
10
  <script type="IN/Share"
3
- data-url='<%= options[:url] %>'
4
- data-counter='<%= options[:counter] %>'
5
- data-onerror='<%= options[:onerror]%>'
6
- data-onsuccess='<%= options[:onsuccess]%>'
7
- data-showzero='<%= options[:showzero] %>'
8
- ></script>
11
+ <%= html_attributes(options.slice(:url, :counter, :onerror, :onsuccess, :showzero), :data => true) %>
12
+ ></script>
13
+ <% end %>
14
+ <% end %>
@@ -1,24 +1,17 @@
1
- <a data-pin-config='<%= options[:pin_config] %>'
1
+ <% if options[:static_link] %>
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]}") %>
4
+ <% end %>
5
+ <% else %>
6
+ <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
7
+ <a data-pin-config="<%= options[:pin_config] %>"
2
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? %>"
3
- data-pin-do='<%= options[:pin_do] %>' >
4
- <img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" title='<%= options[:title]%>' alt='<%= options[:alt] %>' /></a>
5
-
6
- <%= output_once :pinterest do %>
7
- <script type="text/javascript">
8
- (function (d, buildThese) {
9
- var homeScript, newScript, n = buildThese.length, i;
10
- for (i = 0; i < n; i = i + 1) {
11
- newScript = d.createElement('SCRIPT');
12
- newScript.type = 'text/javascript';
13
- newScript.async = true;
14
- newScript.src = buildThese[i];
15
- homeScript = d.getElementsByTagName('SCRIPT')[0];
16
- homeScript.parentNode.insertBefore(newScript, homeScript);
17
- }
18
- }(document, [
19
- '//assets.pinterest.com/js/pinit.js'
20
- /* load more third-party JavaScript here */
21
- ])
22
- );
23
- </script>
9
+ data-pin-do="<%= options[:pin_do] %>" >
10
+ <img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" title="<%= options[:title]%>" alt="<%= options[:alt] %>" /></a>
11
+ <% end %>
12
+ <% unless options[:button_only] %>
13
+ <%= output_once :pinterest do %>
14
+ <%= render "shareable/partials/scripts/pinterest" %>
15
+ <% end %>
16
+ <% end %>
24
17
  <% end %>
@@ -1,3 +1,7 @@
1
+ <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
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]}") %>
4
+ <% else %>
1
5
  <script type="text/javascript">
2
6
  reddit_url='<%= options[:url] %>';
3
7
  reddit_target='<%= options[:target]%>';
@@ -6,6 +10,10 @@
6
10
  reddit_bordercolor='<%= options[:bordercolor] %>';
7
11
  reddit_newwindow='<%= options[:newwindow] %>';
8
12
  </script>
13
+ <% unless options[:button_only] %>
9
14
  <script type="text/javascript"
10
- src="<%= raw((options[:btnsrc].blank? ? ('http://www.reddit.com/static/button/button' + options[:type] + '.js?i=' + options[:points]) : options[:btnsrc]) + '&styled=' + options[:styled]) %>">
11
- </script>
15
+ src="<%= raw((options[:btnsrc].blank? ? ('//www.reddit.com/static/button/button' + options[:type] + '.js?i=' + options[:points]) : options[:btnsrc]) + '&styled=' + options[:styled]) %>">
16
+ </script>
17
+ <% end %>
18
+ <% end %>
19
+ <% end %>
@@ -1,7 +1,7 @@
1
- <nav class="share">
2
- <%= social_buttons.render do -%>
3
- <% each_button do |button| -%>
4
- <%= eval button + '_tag' %>
5
- <% end -%>
6
- <% end -%>
7
- </nav>
1
+ <%= render :layout =>'shareable/partials/parent_wrapper' do %>
2
+ <%= social_buttons.render do %>
3
+ <% each_button do |button| %>
4
+ <%= eval button + '_tag' %>
5
+ <% end %>
6
+ <% end %>
7
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <% if options[:static_link] %>
2
+ <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
3
+ <%= render "shareable/partials/link", :options => options.merge(:url=>"https://www.stumbleupon.com/submit?url=#{options[:url]}&title=#{options[:title]}") %>
4
+ <% end %>
5
+ <% else %>
6
+ <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
7
+ <su:badge layout="<%= options[:badge_layout]%>" location="<%= options[:url] %>"></su:badge>
8
+ <% end %>
9
+ <% unless options[:button_only] %>
10
+ <%= output_once :stumble_upon do %>
11
+ <%= render "shareable/partials/scripts/stumble_upon" %>
12
+ <% end %>
13
+ <% end %>
14
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <% if options[:static_link] %>
2
+ <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
3
+ <%= render "shareable/partials/link", :options => options.merge(:url=>"https://www.tumblr.com/share/link?url=#{options[:url]}&name=#{options[:title]}&description=#{options[:description]}") %>
4
+ <% end %>
5
+ <% else %>
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>
9
+ <% end %>
10
+ <% unless options[:button_only] %>
11
+ <%= output_once :tumblr do %>
12
+ <%= render "shareable/partials/scripts/tumblr" %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
@@ -1,27 +1,21 @@
1
- <!--script src='http://platform.twitter.com/widgets.js' type='text/javascript'></script> -->
2
- <%- if defined?(Turbolinks) %>
3
- <%= output_once :twitter do %>
4
- <script src="//platform.twitter.com/widgets.js"></script>
1
+ <% if options[:static_link] %>
2
+ <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
3
+ <%= render "shareable/partials/link", :options => options.merge(:url=>"https://twitter.com/intent/tweet?url=#{options[:url]}&text=#{options[:text]}&hashtags=#{options[:hashtags]}") %>
5
4
  <% end %>
6
- <% else -%>
7
- <script>!function(d,s,id){
8
- var js,fjs=d.getElementsByTagName(s)[0];
9
- if(!d.getElementById(id)){
10
- js=d.createElement(s);
11
- js.id=id;js.src="//platform.twitter.com/widgets.js";
12
- fjs.parentNode.insertBefore(js,fjs);}} (document,"script","twitter-wjs");
13
- </script>
14
- <% end -%>
15
-
16
- <a href='http://twitter.com/share'
17
- class='twitter-share-button'
18
- data-url='<%= options[:url] %>'
19
- data-via='<%= options[:via] %>'
20
- data-text='<%= options[:text] %>'
21
- data-related='<%= options[:related] %>'
22
- data-count='<%= options[:count] %>'
23
- data-lang='<%= options[:lang] %>'
24
- data-counturl='<%= options[:counturl] %>'
25
- data-hashtags='<%= options[:hashtags] %>'
26
- data-size='<%= options[:size] %>'
27
- data-dnt='<%= options[:dnt] %>'>Tweet</a>
5
+ <% else %>
6
+ <% if tl = (defined?(Turbolinks) && !(options[:button_only])) %>
7
+ <%= output_once :twitter do %>
8
+ <script src="//platform.twitter.com/widgets.js"></script>
9
+ <% end %>
10
+ <% end %>
11
+ <%= render :layout => "shareable/partials/button_wrapper", locals: {:options => options} do %>
12
+ <a href="http://twitter.com/share" class="twitter-share-button"
13
+ <%= html_attributes(options.slice(:url, :via, :text, :related, :count, :lang, :counturl, :hashtags, :size, :dnt), :data => true) %>
14
+ >Tweet</a>
15
+ <% end %>
16
+ <% unless tl %>
17
+ <%= output_once :twitter do %>
18
+ <%= render "shareable/partials/scripts/twitter" %>
19
+ <% end %>
20
+ <% end %>
21
+ <% end %>
@@ -0,0 +1 @@
1
+ <a target="_blank" href="<%= options[:url] %>"><%= options[:button_caption] %></a>
@@ -0,0 +1,3 @@
1
+ <nav class="share">
2
+ <%= yield %>
3
+ </nav>
@@ -0,0 +1,9 @@
1
+ <div id="fb-root"></div>
2
+ <script>(function(d, s, id) {
3
+ var js, fjs = d.getElementsByTagName(s)[0];
4
+ if (d.getElementById(id)) return;
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? %>";
7
+ fjs.parentNode.insertBefore(js, fjs);
8
+ }(document, 'script', 'facebook-jssdk'));
9
+ </script>
@@ -0,0 +1,7 @@
1
+ <script type="text/javascript">
2
+ (function() {
3
+ var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
4
+ po.src = 'https://apis.google.com/js/plusone.js';
5
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
6
+ })();
7
+ </script>
@@ -0,0 +1 @@
1
+ <script src="//platform.linkedin.com/in.js" type="text/javascript"></script>
@@ -0,0 +1,17 @@
1
+ <script type="text/javascript">
2
+ (function (d, buildThese) {
3
+ var homeScript, newScript, n = buildThese.length, i;
4
+ for (i = 0; i < n; i = i + 1) {
5
+ newScript = d.createElement('SCRIPT');
6
+ newScript.type = 'text/javascript';
7
+ newScript.async = true;
8
+ newScript.src = buildThese[i];
9
+ homeScript = d.getElementsByTagName('SCRIPT')[0];
10
+ homeScript.parentNode.insertBefore(newScript, homeScript);
11
+ }
12
+ }(document, [
13
+ '//assets.pinterest.com/js/pinit.js'
14
+ /* load more third-party JavaScript here */
15
+ ])
16
+ );
17
+ </script>
@@ -0,0 +1,7 @@
1
+ <script type="text/javascript">
2
+ (function() {
3
+ var li = document.createElement("script"); li.type = "text/javascript"; li.async = true;
4
+ li.src = ("https:" == document.location.protocol ? "https:" : "http:") + "//platform.stumbleupon.com/1/widgets.js";
5
+ var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(li, s);
6
+ })();
7
+ </script>
@@ -0,0 +1 @@
1
+ <script src="http://platform.tumblr.com/v1/share.js"></script>
@@ -0,0 +1,7 @@
1
+ <script>!function(d,s,id){
2
+ var js,fjs=d.getElementsByTagName(s)[0];
3
+ if(!d.getElementById(id)){
4
+ js=d.createElement(s);
5
+ js.id=id;js.src="//platform.twitter.com/widgets.js";
6
+ fjs.parentNode.insertBefore(js,fjs);}} (document,"script","twitter-wjs");
7
+ </script>
@@ -1,5 +1,11 @@
1
1
  Shareable.configure do |config|
2
- #config.names = %w[ twitter facebook linkedin pinterest google_plus reddit ]
2
+
3
+ # valid names are:
4
+ # twitter facebook pinterest reddit google_plus linkedin tumblr stumble_upon
5
+ #config.names = %w[ twitter facebook linkedin pinterest google_plus reddit tumblr stumble_upon ]
6
+
7
+ #config.button_only=false # omit initializing javacript. Only button code is rendered.
8
+ #config.static_link=false # renders non-javascript html links.
3
9
 
4
10
  ##############
5
11
  #facebook
@@ -8,11 +14,12 @@ Shareable.configure do |config|
8
14
  #config.send= 'false'
9
15
  #config.layout=''
10
16
  #config.show_faces=''
11
- #config.width='80'
12
17
  #config.action=''
13
18
  #config.font=''
14
19
  #config.colorscheme=''
15
20
  #config.ref=''
21
+ #config.share=''
22
+ #config.kid_directed_site=''
16
23
 
17
24
  ##############
18
25
  #google_plus
@@ -38,10 +45,8 @@ Shareable.configure do |config|
38
45
  ##############
39
46
  #config.pin_config = 'none'
40
47
  #config.pin_do = 'buttonPin'
41
- #config.title= '' # title for content, also used by reddit button
42
48
  #config.alt='' # alternate text for image tag
43
49
  #config.media=''
44
- #config.description='Pin This'
45
50
 
46
51
  ##############
47
52
  #reddit
@@ -67,4 +72,22 @@ Shareable.configure do |config|
67
72
  #config.hashtags=''
68
73
  #config.size='medium'
69
74
  #config.dnt=''
75
+
76
+ ##############
77
+ #stumble_upon
78
+ ##############
79
+ #config.badge_layout='1'
80
+
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
92
+
70
93
  end
@@ -19,12 +19,16 @@ module Shareable
19
19
  :onstartinteraction, :onendinteraction, :pin_config, :pin_do, :media, :color,
20
20
  :bordercolor, :btnsrc, :via, :text, :related, :count, :lang, :counturl, :hashtags, :size, :dnt,
21
21
  :type, :styled, :newwindow, :description, :counter, :onsuccess, :onerror, :showzero,
22
- :recommendations, :points
22
+ :recommendations, :points, :badge_layout, :background, :share, :kid_directed_site,
23
+ :button_only, :static_link
23
24
  end
24
25
 
25
26
  configure do |config|
26
27
  config.names = %w[ twitter facebook linkedin pinterest google_plus reddit ]
27
28
 
29
+ config.button_only=false # omit initializing javacript. Only button code is rendered.
30
+ config.static_link=false # renders non-javascript html links.
31
+
28
32
  ##############
29
33
  #facebook
30
34
  ##############
@@ -32,11 +36,12 @@ module Shareable
32
36
  config.send= 'false'
33
37
  config.layout='button_count'
34
38
  config.show_faces=''
35
- config.width='80'
36
39
  config.action=''
37
40
  config.font=''
38
41
  config.colorscheme=''
39
42
  config.ref=''
43
+ config.share=''
44
+ config.kid_directed_site=''
40
45
 
41
46
  ##############
42
47
  #google_plus
@@ -62,10 +67,8 @@ module Shareable
62
67
  ##############
63
68
  config.pin_config = 'beside'
64
69
  config.pin_do = 'buttonPin'
65
- config.title= '' # title for content, also used by reddit button
66
70
  config.alt='' # alternate text for image tag
67
71
  config.media=''
68
- config.description='Pin This'
69
72
 
70
73
  ##############
71
74
  #reddit
@@ -91,5 +94,22 @@ module Shareable
91
94
  config.hashtags=''
92
95
  config.size='medium'
93
96
  config.dnt=''
97
+
98
+ ##############
99
+ #stumble_upon
100
+ ##############
101
+ config.badge_layout='1'
102
+
103
+ ##############
104
+ #tumblr
105
+ ##############
106
+ config.background='share_1.png'
107
+
108
+ ##############
109
+ #shared configuration options
110
+ ##############
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
94
114
  end
95
115
  end
@@ -3,6 +3,19 @@ require 'shareable/helpers/social_buttons'
3
3
  module Shareable
4
4
  # = Helpers
5
5
  module ActionViewExtension
6
+ def html_attributes(attributes, opts={})
7
+ opts = {
8
+ :data => false
9
+ }.merge(opts)
10
+
11
+ prefix = opts[:data] ? 'data-' : ''
12
+ attributes.map { |(k, v)|
13
+ if v.present?
14
+ %{#{prefix}#{k.to_s.camelize(:lower)}="#{html_escape( v )}"}.html_safe
15
+ end
16
+ }.compact.join( " " ).html_safe
17
+ end
18
+
6
19
  # A helper that renders social links
7
20
  # <%= render_shareable [options] %>
8
21
  def render_shareable(options = {}, &block)
@@ -32,6 +45,9 @@ module Shareable
32
45
  def refine_options(options={},button=nil)
33
46
  options[:options] ||= {}
34
47
  options[:options].merge! options.except(:options)
48
+ if options.has_key?(:buttons) then
49
+ options[:buttons].map!(&:to_s)
50
+ end
35
51
  if options[:url].blank? then
36
52
  options[:options][:url] = request.url
37
53
  end
@@ -9,16 +9,17 @@ module Shareable
9
9
  class SocialButtons < Tag
10
10
  include ::ActionView::Context
11
11
  cattr_accessor :buttons
12
- self.buttons = %w[ twitter facebook pinterest reddit google_plus linkedin ]
12
+ self.buttons = %w[ twitter facebook pinterest reddit google_plus linkedin tumblr stumble_upon ]
13
13
 
14
- #not very DRY. Refactor.
15
14
  cattr_accessor :config_options
16
15
  self.config_options = {
17
- :facebook => [ :app_id, :send, :layout, :show_faces, :width, :action, :font, :colorscheme, :ref ],
16
+ :facebook => [ :app_id, :send, :layout, :show_faces, :width, :action, :font, :colorscheme, :ref, :share, :kid_directed_site ],
18
17
  :google_plus => [ :annotation, :recommendations, :align, :expand_to, :callback, :onstartinteraction, :onendinteraction, :size, :width ],
19
- :linkedin => [ :counter, :onsuccess, :onerror, :showzero ],
18
+ :linkedin => [ :counter, :onsuccess, :onerror, :showzero, :title, :description ],
20
19
  :pinterest => [ :pin_config, :pin_do, :title, :alt, :media, :description ],
21
20
  :reddit => [ :title, :target, :color, :bordercolor, :type, :styled, :newwindow, :btnsrc, :points ],
21
+ :stumble_upon => [ :badge_layout, :title ],
22
+ :tumblr => [ :title, :description, :width, :background ],
22
23
  :twitter => [ :via, :text, :related, :count, :lang, :counturl, :hashtags, :size, :dnt ]}
23
24
 
24
25
  def initialize(template, options) #:nodoc:
@@ -49,22 +50,32 @@ module Shareable
49
50
  def to_s #:nodoc:
50
51
  #from Kamanari for handling log subscriber:
51
52
  subscriber = ActionView::LogSubscriber.log_subscribers.detect {|ls| ls.is_a? ActionView::LogSubscriber}
52
- return super @options.merge :social_buttons => self unless subscriber
53
53
 
54
- # dirty hack to suppress logging render_partial
55
- class << subscriber
56
- alias_method :render_partial_with_logging, :render_partial
57
- # do nothing
58
- def render_partial(event); end
59
- end
54
+ # There is a logging subscriber
55
+ # and we don't want it to log render_partial
56
+ # It is threadsafe, but might not repress logging
57
+ # consistently in a high-load environment
58
+ if subscriber
59
+ unless defined? subscriber.render_partial_with_logging
60
+ class << subscriber
61
+ alias_method :render_partial_with_logging, :render_partial
62
+ attr_accessor :render_without_logging
63
+ # ugly hack to make a renderer where
64
+ # we can turn logging on or off
65
+ def render_partial(event)
66
+ render_partial_with_logging(event) unless render_without_logging
67
+ end
68
+ end
69
+ end
60
70
 
61
- ret = super @options.merge :social_buttons => self
71
+ subscriber.render_without_logging = true
72
+ ret = super @options.merge :social_buttons => self
73
+ subscriber.render_without_logging = false
62
74
 
63
- class << subscriber
64
- alias_method :render_partial, :render_partial_with_logging
65
- undef :render_partial_with_logging
75
+ ret
76
+ else
77
+ super @options.merge :social_buttons => self
66
78
  end
67
- ret
68
79
  end
69
80
 
70
81
  def each_relevant_button #:nodoc:
@@ -1,5 +1,6 @@
1
1
  module Shareable
2
2
  module Helpers
3
+
3
4
  class Tag
4
5
  def initialize(template, options = {}) #:nodoc:
5
6
  @template, @options = template, options.dup
@@ -11,9 +12,10 @@ module Shareable
11
12
  end
12
13
 
13
14
  class Socialize < Tag
14
- def to_s(locals={}) #:nodoc:
15
+ def to_s(locals={}, caption="") #:nodoc:
15
16
  locals[:options] ||= {}
16
- social_site = self.class.name.demodulize.downcase.to_sym
17
+ social_site=(locals[:options][:button_name]=self.class.name.demodulize.underscore.downcase).to_sym
18
+ locals[:options][:button_caption] = caption
17
19
  if @options[:options]
18
20
  @options[:filtered] ||= @options[:options].reject {|opt| locals[:options].include?(opt)}
19
21
  locals[:options].merge!(@options[:filtered])
@@ -26,36 +28,135 @@ module Shareable
26
28
  end
27
29
 
28
30
  class Facebook < Socialize
31
+ def to_s(locals={}) #:nodoc:
32
+ if (@options[:options][:static_link] && !(@options[:facebook] && @options[:facebook][:static_link]==false)) || (@options[:facebook] && @options[:facebook][:static_link])
33
+ locals[:options] ||= {}
34
+ p_opts = {:url => CGI::escape(@options[:options][:url])}
35
+ locals[:options].merge!(@options[:options].merge(p_opts))
36
+ if @options[:facebook]
37
+ @options[:facebook][:url] = CGI::escape(@options[:facebook][:url]) if @options[:facebook][:url]
38
+ end
39
+ end
40
+ super locals, "Facebook"
41
+ end
29
42
  end
30
43
 
31
44
  class GooglePlus < Socialize
45
+ def to_s(locals={}) #:nodoc:
46
+ if (@options[:options][:static_link] && !(@options[:google_plus] && @options[:google_plus][:static_link]==false)) || (@options[:google_plus] && @options[:google_plus][:static_link])
47
+ locals[:options] ||= {}
48
+ p_opts = {:url => CGI::escape(@options[:options][:url])}
49
+ locals[:options].merge!(@options[:options].merge(p_opts))
50
+ if @options[:google_plus]
51
+ @options[:google_plus][:url] = CGI::escape(@options[:google_plus][:url]) if @options[:google_plus][:url]
52
+ end
53
+ end
54
+ super locals, "Google+"
55
+ end
32
56
  end
33
57
 
34
58
  class Linkedin < Socialize
59
+ def to_s(locals={}) #:nodoc:
60
+ if (@options[:options][:static_link] && !(@options[:linkedin] && @options[:linkedin][:static_link]==false)) || (@options[:linkedin] && @options[:linkedin][:static_link])
61
+ locals[:options] ||= {}
62
+ p_opts = {:description => CGI::escape(@options[:options][:description]),
63
+ :title => CGI::escape(@options[:options][:title]),
64
+ :url => CGI::escape(@options[:options][:url])}
65
+ locals[:options].merge!(@options[:options].merge(p_opts))
66
+ if @options[:linkedin]
67
+ @options[:linkedin][:description] = CGI::escape(@options[:linkedin][:description]) if @options[:linkedin][:description]
68
+ @options[:linkedin][:title] = CGI::escape(@options[:linkedin][:title]) if @options[:linkedin][:title]
69
+ @options[:linkedin][:url] = CGI::escape(@options[:linkedin][:url]) if @options[:linkedin][:url]
70
+ end
71
+ end
72
+ super locals, "LinkedIn"
73
+ end
35
74
  end
36
75
 
37
76
  class Pinterest < Socialize
38
77
  def to_s(locals={}) #:nodoc:
39
78
  locals[:options] ||= {}
40
- unless @options[:options].blank?
41
- p_opts = {:description => CGI::escape(@options[:options][:description] ? @options[:options][:description] : '' ),
42
- :url => CGI::escape(@options[:options][:url] ? @options[:options][:url] : ''),
43
- :media => CGI::escape(@options[:options][:media] ? @options[:options][:media] : '')}
79
+ p_opts = {:description => CGI::escape(@options[:options][:description]),
80
+ :url => CGI::escape(@options[:options][:url]),
81
+ :media => CGI::escape(@options[:options][:media])}
82
+ locals[:options].merge!(@options[:options].merge(p_opts))
83
+ if @options[:pinterest]
84
+ @options[:pinterest][:description] = CGI::escape(@options[:pinterest][:description]) if @options[:pinterest][:description]
85
+ @options[:pinterest][:url] = CGI::escape(@options[:pinterest][:url]) if @options[:pinterest][:url]
86
+ @options[:pinterest][:media] = CGI::escape(@options[:pinterest][:media]) if @options[:pinterest][:media]
87
+ end
88
+ super locals, "Pinterest"
89
+ end
90
+ end
91
+
92
+ class Reddit < Socialize
93
+ def to_s(locals={}) #:nodoc:
94
+ if (@options[:options][:static_link] && !(@options[:reddit] && @options[:reddit][:static_link]==false)) || (@options[:reddit] && @options[:reddit][:static_link])
95
+ locals[:options] ||= {}
96
+ p_opts = {:title => CGI::escape(@options[:options][:title]),
97
+ :url => CGI::escape(@options[:options][:url])}
44
98
  locals[:options].merge!(@options[:options].merge(p_opts))
45
- if @options[:pinterest]
46
- @options[:pinterest][:description] = CGI::escape(@options[:pinterest][:description]) if @options[:pinterest][:description]
47
- @options[:pinterest][:url] = CGI::escape(@options[:pinterest][:url]) if @options[:pinterest][:url]
48
- @options[:pinterest][:media] = CGI::escape(@options[:pinterest][:media]) if @options[:pinterest][:media]
99
+ if @options[:reddit]
100
+ @options[:reddit][:title] = CGI::escape(@options[:reddit][:title]) if @options[:reddit][:title]
101
+ @options[:reddit][:url] = CGI::escape(@options[:reddit][:url]) if @options[:reddit][:url]
49
102
  end
50
103
  end
51
- super locals
104
+ super locals, "Reddit"
52
105
  end
53
106
  end
54
107
 
55
- class Reddit < Socialize
108
+ class StumbleUpon < Socialize
109
+ def to_s(locals={}) #:nodoc:
110
+ if (@options[:options][:static_link] && !(@options[:stumble_upon] && @options[:stumble_upon][:static_link]==false)) || (@options[:stumble_upon] && @options[:stumble_upon][:static_link])
111
+ locals[:options] ||= {}
112
+ p_opts = {:title => CGI::escape(@options[:options][:title]),
113
+ :url => CGI::escape(@options[:options][:url])}
114
+ locals[:options].merge!(@options[:options].merge(p_opts))
115
+ if @options[:stumble_upon]
116
+ @options[:stumble_upon][:title] = CGI::escape(@options[:stumble_upon][:title]) if @options[:stumble_upon][:title]
117
+ @options[:stumble_upon][:url] = CGI::escape(@options[:stumble_upon][:url]) if @options[:stumble_upon][:url]
118
+ end
119
+ end
120
+ super locals, "StumbleUpon"
121
+ end
122
+ end
123
+
124
+ class Tumblr < Socialize
125
+ def to_s(locals={}) #:nodoc:
126
+ locals[:options] ||= {}
127
+ p_opts = {:description => CGI::escape(@options[:options][:description]),
128
+ :url => CGI::escape(@options[:options][:url]),
129
+ :title => CGI::escape(@options[:options][:title])}
130
+ locals[:options].merge!(@options[:options].merge(p_opts))
131
+ if @options[:tumblr]
132
+ @options[:tumblr][:description] = CGI::escape(@options[:tumblr][:description]) if @options[:tumblr][:description]
133
+ @options[:tumblr][:url] = CGI::escape(@options[:tumblr][:url]) if @options[:tumblr][:url]
134
+ @options[:tumblr][:title] = CGI::escape(@options[:tumblr][:title]) if @options[:tumblr][:title]
135
+ end
136
+ super locals, "Tumblr"
137
+ end
56
138
  end
57
139
 
58
140
  class Twitter < Socialize
141
+ def to_s(locals={}) #:nodoc:
142
+ locals[:options] ||= {}
143
+ if locals[:options][:text].blank? && @options[:options][:text].blank? && (@options[:twitter] ? @options[:twitter][:text].blank? : true) && @options[:options][:title]
144
+ locals[:options][:text] = @options[:options][:title]
145
+ end
146
+ if (@options[:options][:static_link] && !(@options[:twitter] && @options[:twitter][:static_link]==false)) || (@options[:twitter] && @options[:twitter][:static_link])
147
+ p_opts = {:text => CGI::escape(locals[:options][:text] ? locals[:options][:text] : (@options[:options][:text] ? @options[:options][:text] : '')),
148
+ :url => CGI::escape(@options[:options][:url]),
149
+ :hashtags => @options[:options][:hashtags].blank? ? '' : @options[:options][:hashtags].split(',').map{|tag| CGI::escape(tag)}.join(',')}
150
+ locals[:options].merge!(@options[:options].merge(p_opts))
151
+ if @options[:twitter]
152
+ @options[:twitter][:text] = CGI::escape(@options[:twitter][:text]) if @options[:twitter][:text]
153
+ @options[:twitter][:url] = CGI::escape(@options[:twitter][:url]) if @options[:twitter][:url]
154
+ @options[:twitter][:hashtags] = @options[:twitter][:hashtags].split(',').map{|tag| CGI::escape(tag)}.join(',') if @options[:twitter][:hashtags]
155
+ end
156
+ end
157
+ super locals, "Twitter"
158
+ end
59
159
  end
160
+
60
161
  end
61
162
  end
@@ -1,3 +1,3 @@
1
1
  module Shareable
2
- VERSION = "0.0.3"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,126 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shareable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Hermango
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-05 00:00:00.000000000 Z
11
+ date: 2014-06-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.0.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: actionpack
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 3.0.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 3.0.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: bundler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.0.0
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.0.0
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: tzinfo
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rr
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: capybara
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - '>='
116
102
  - !ruby/object:Gem::Version
117
103
  version: '1.0'
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - '>='
124
109
  - !ruby/object:Gem::Version
125
110
  version: '1.0'
126
111
  description: Add social sharing links to a view in your Rails app with one method
@@ -131,6 +116,7 @@ executables: []
131
116
  extensions: []
132
117
  extra_rdoc_files: []
133
118
  files:
119
+ - .DS_Store
134
120
  - .gitignore
135
121
  - Gemfile
136
122
  - MIT-LICENSE
@@ -141,7 +127,19 @@ files:
141
127
  - app/views/shareable/_pinterest.html.erb
142
128
  - app/views/shareable/_reddit.html.erb
143
129
  - app/views/shareable/_social_buttons.html.erb
130
+ - app/views/shareable/_stumble_upon.html.erb
131
+ - app/views/shareable/_tumblr.html.erb
144
132
  - app/views/shareable/_twitter.html.erb
133
+ - app/views/shareable/partials/_button_wrapper.html.erb
134
+ - app/views/shareable/partials/_link.html.erb
135
+ - app/views/shareable/partials/_parent_wrapper.html.erb
136
+ - app/views/shareable/partials/scripts/_facebook.html.erb
137
+ - app/views/shareable/partials/scripts/_google_plus.html.erb
138
+ - app/views/shareable/partials/scripts/_linkedin.html.erb
139
+ - app/views/shareable/partials/scripts/_pinterest.html.erb
140
+ - app/views/shareable/partials/scripts/_stumble_upon.html.erb
141
+ - app/views/shareable/partials/scripts/_tumblr.html.erb
142
+ - app/views/shareable/partials/scripts/_twitter.html.erb
145
143
  - lib/generators/shareable/config_generator.rb
146
144
  - lib/generators/shareable/templates/shareable_config.rb
147
145
  - lib/shareable.rb
@@ -157,26 +155,25 @@ files:
157
155
  homepage: http://github.com/hermango/shareable
158
156
  licenses:
159
157
  - MIT
158
+ metadata: {}
160
159
  post_install_message:
161
160
  rdoc_options: []
162
161
  require_paths:
163
162
  - lib
164
163
  required_ruby_version: !ruby/object:Gem::Requirement
165
- none: false
166
164
  requirements:
167
- - - ! '>='
165
+ - - '>='
168
166
  - !ruby/object:Gem::Version
169
167
  version: '0'
170
168
  required_rubygems_version: !ruby/object:Gem::Requirement
171
- none: false
172
169
  requirements:
173
- - - ! '>='
170
+ - - '>='
174
171
  - !ruby/object:Gem::Version
175
172
  version: '0'
176
173
  requirements: []
177
174
  rubyforge_project:
178
- rubygems_version: 1.8.24
175
+ rubygems_version: 2.0.14
179
176
  signing_key:
180
- specification_version: 3
177
+ specification_version: 4
181
178
  summary: Simple and unobtrusive gem for adding social links to your Rails app.
182
179
  test_files: []