Module: TopHat::OpenGraphHelper

Defined in:
lib/tophat/opengraph.rb

Defined Under Namespace

Classes: OpenGraphGenerator

Constant Summary collapse

HTML4_XMLNS =
[
  'http://www.w3.org/1999/xhtml',
  { :prefix => 'og', :url => 'http://ogp.me/ns#' },
  { :prefix => 'fb', :url => 'https://www.facebook.com/2008/fbml' }
]
HTML5_XMLNS =
[
  { :prefix => 'og', :url => 'http://opengraphprotocol.org/schema/' },
  { :prefix => 'fb', :url => 'http://developers.facebook.com/schema/' }
]

Instance Method Summary collapse

Instance Method Details

#html_with_opengraph(style = 'html4') ⇒ Object



74
75
76
77
# File 'lib/tophat/opengraph.rb', line 74

def html_with_opengraph(style='html4')
  Kernel.warn("html_with_opengraph has been deprecated, use opengraph_html instead.")
  opengraph_html(style)
end

#opengraph(options = nil, &block) ⇒ Object



89
90
91
92
93
# File 'lib/tophat/opengraph.rb', line 89

def opengraph(options=nil, &block)
  TopHat.current['open_graph_generator'] ||= OpenGraphGenerator.new(options)
  TopHat.current['open_graph_generator'].merge(options, &block)
  TopHat.current['open_graph_generator'].to_html
end

#opengraph_html(style = 'html4') ⇒ Object



79
80
81
82
83
84
85
86
87
# File 'lib/tophat/opengraph.rb', line 79

def opengraph_html(style='html4')
  if style == 'html4'
    html_tag(:xmlns => HTML4_XMLNS)
  elsif style == 'html5'
    html_tag(:version => 'HTML+RDFa 1.0', :xmlns => HTML5_XMLNS)
  else
    html_tag
  end
end