Module: OpenGraphHelper
- Defined in:
- lib/open_graph_helper.rb,
lib/open_graph_helper/railtie.rb,
lib/open_graph_helper/version.rb
Overview
Defined Under Namespace
Classes: Railtie
Constant Summary collapse
- SOCIAL_PLUGIN_VERSION =
:html5
- VERSION =
"0.2.0"
Instance Method Summary collapse
- #fb_comments(url, custom_options = {}) ⇒ Object
-
#fb_like(like_url, custom_options = {}) ⇒ Object
types: button_count, standard, box_count.
- #fb_likebox(page_url, custom_options = {}) ⇒ Object
- #fb_recommendations(site_url, custom_options = {}) ⇒ Object
- #og_description(content) ⇒ Object
- #og_fb_admins(admins) ⇒ Object
- #og_fb_app_id(content) ⇒ Object
-
#og_image(content) ⇒ Object
50x50 px ~ 150x150 px.
- #og_site_name(content) ⇒ Object
- #og_title(content) ⇒ Object
- #og_type(content = "article") ⇒ Object
- #og_url(content) ⇒ Object
- #social_plugin(plugin_name, options) ⇒ Object
Instance Method Details
#fb_comments(url, custom_options = {}) ⇒ Object
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/open_graph_helper.rb', line 112 def fb_comments(url, ={}) = { :href => url, :num_posts => 10 } .merge! ("comments", ) end |
#fb_like(like_url, custom_options = {}) ⇒ Object
types: button_count, standard, box_count
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/open_graph_helper.rb', line 67 def fb_like(like_url, ={}) = { :href => like_url, :send => false, :layout => "button_count", :show_faces => false, :width => 90 } .merge! ("like", ) end |
#fb_likebox(page_url, custom_options = {}) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/open_graph_helper.rb', line 81 def fb_likebox(page_url, ={}) = { :href => page_url, :width => 240, :height => 65, :show_faces => false, :stream => false, :header => true } .merge! ("like-box", ) end |
#fb_recommendations(site_url, custom_options = {}) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/open_graph_helper.rb', line 96 def fb_recommendations(site_url, ={}) = { :site => site_url, :width => 300, :height => 380, :header => false, :colorscheme => "light", :border_color => "#CCC" # :linktarget => "_blank" } .merge! ("recommendations", ) end |
#og_description(content) ⇒ Object
13 14 15 16 |
# File 'lib/open_graph_helper.rb', line 13 def og_description(content) content = html_escape((content)) tag(:meta, { :property => "og:description", :content => truncate(content , :length => 100) }, true) end |
#og_fb_admins(admins) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/open_graph_helper.rb', line 39 def og_fb_admins(admins) # Multiple fb:admins should be specified in separated meta tags # See Issue #3 if admins.is_a? Array admins.map { |admin| tag(:meta, { :property => "fb:admins", :content => admin }, true) }.join.html_safe else tag(:meta, { :property => "fb:admins", :content => admins }, true) end end |
#og_fb_app_id(content) ⇒ Object
35 36 37 |
# File 'lib/open_graph_helper.rb', line 35 def og_fb_app_id(content) tag(:meta, { :property => "fb:app_id", :content => content }, true) end |
#og_image(content) ⇒ Object
50x50 px ~ 150x150 px
23 24 25 |
# File 'lib/open_graph_helper.rb', line 23 def og_image(content) tag(:meta, { :property => "og:image", :content => content }, true) end |
#og_site_name(content) ⇒ Object
31 32 33 |
# File 'lib/open_graph_helper.rb', line 31 def og_site_name(content) tag(:meta, { :property => "og:site_name", :content => content }, true) end |
#og_title(content) ⇒ Object
9 10 11 |
# File 'lib/open_graph_helper.rb', line 9 def og_title(content) tag(:meta, { :property => "og:title", :content => content }, true) end |
#og_type(content = "article") ⇒ Object
18 19 20 |
# File 'lib/open_graph_helper.rb', line 18 def og_type(content = "article") tag(:meta, { :property => "og:type", :content => content }, true) end |
#og_url(content) ⇒ Object
27 28 29 |
# File 'lib/open_graph_helper.rb', line 27 def og_url(content) tag(:meta, { :property => "og:url", :content => content }, true) end |
#social_plugin(plugin_name, options) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/open_graph_helper.rb', line 51 def (plugin_name, ) case SOCIAL_PLUGIN_VERSION when :html5 content_tag(:div, "", :class => "fb-#{plugin_name.to_s}", :data => ) when :iframe width = .delete(:width) height = .delete(:height) style = "border:none; overflow:hidden; width:#{width}px; height:#{height}px;" src = "http://www.facebook.com/plugins/#{plugin_name}.php?#{options.to_param}" content_tag(:iframe, "", :src => src, :scrolling => "no", :frameborder => "0", :style => style, :allowtransparency => "true") else raise "Unknown Social Plugin Version: #{SOCIAL_PLUGIN_VERSION}" end end |