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 " <div id=\"fb-root\"></div>\n <script>(function(d, s, id) {\n var js, fjs = d.getElementsByTagName(s)[0];\n if (d.getElementById(id)) return;\n js = d.createElement(s); js.id = id;\n js.src = \"//connect.facebook.net/et_EE/all.js#xfbml=1\";\n fjs.parentNode.insertBefore(js, fjs);\n }(document, 'script', 'facebook-jssdk'));</script>\n <div class=\"fb-like\" data-send=\"false\" data-layout=\"button_count\" data-width=\"450\" data-show-faces=\"true\"></div>\n EOHTML\nend\n" |
.google ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/guider/social.rb', line 15 def self.google " <div class=\"g-plusone\" data-annotation=\"none\"></div>\n <script type=\"text/javascript\">\n (function() {\n var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;\n po.src = 'https://apis.google.com/js/plusone.js';\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);\n })();\n </script>\n EOHTML\nend\n" |
.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 " <a href=\"https://twitter.com/share\" class=\"twitter-share-button\">Tweet</a>\n <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>\n EOHTML\nend\n" |