Class: Guider::Social
- Inherits:
-
Object
- Object
- Guider::Social
- Defined in:
- lib/guider/social.rb
Overview
Generates HTML for Like-buttons of various social services.
Class Method Summary collapse
- .facebook ⇒ Object
- .google ⇒ Object
-
.supported_types ⇒ Object
Returns array of supported social button types.
-
.to_html(types) ⇒ Object
Given array of social button type names, returns HTML for rendering all these buttons.
- .twitter ⇒ Object
Class Method Details
.facebook ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/guider/social.rb', line 35 def self.facebook <<-EOHTML <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/et_EE/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> <div class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="true"></div> EOHTML end |
.google ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/guider/social.rb', line 15 def self.google <<-EOHTML <div class="g-plusone" data-annotation="none"></div> <script type="text/javascript"> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script> EOHTML end |
.supported_types ⇒ Object
Returns array of supported social button types
11 12 13 |
# File 'lib/guider/social.rb', line 11 def self.supported_types [:google, :twitter, :facebook] end |
.to_html(types) ⇒ Object
Given array of social button type names, returns HTML for rendering all these buttons.
6 7 8 |
# File 'lib/guider/social.rb', line 6 def self.to_html(types) types.map {|t| send(t) }.compact.join("\n") end |
.twitter ⇒ Object
28 29 30 31 32 33 |
# File 'lib/guider/social.rb', line 28 def self.twitter <<-EOHTML <a href="https://twitter.com/share" class="twitter-share-button">Tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> EOHTML end |