Sha256: be8d62b7fc023beac8a08dc9a42b0a13bb54972a46635c7e4690b05475a9df35

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

module FacebookSocialPlugins::Helper
	module OpenGraph
		def og_header name, namespace, &block
			content = capture(&block)
			content_tag :head, content, :prefix => "og: http://ogp.me/ns# og_#{name}: http://ogp.me/ns/apps/#{namespace}x#"
		end

		def fb_app_id app_id
			content_tag :meta, '', :property => "fb:app_id", :content => app_id
		end

		def og_type namespace, object_type
			content_tag :meta, '', :property => "og:type", :content => "#{namespace}:#{object_type}"
		end

		def og_title title
			content_tag :meta, '', :property => "og:title", :content => title
		end

		def og_image href
			content_tag :meta, '', :property => "og:image", :content => href
		end

		def og_desc desc
			content_tag :meta, '', :property => "og:description", :content => desc
		end

		def og_url href
			content_tag :meta, '', :property => "og:url", :content => href
		end

		def open_graph_meta name, namespace, app_id, object_type, options = {}
			content = fb_app_id(app_id) + og_type(namespace, object_type)
			content << og_title(options[:title]) if options[:title]
			content << og_image(options[:img]) if options[:img]
			content << og_image(options[:desc]) if options[:desc]
			content << og_image(options[:url]) if options[:url]				
			og_header(name, namespace) do
				content
			end
		end			
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facebook-social_plugins-0.2.2 lib/facebook-social_plugins/helper/open_graph.rb
facebook-social_plugins-0.2.1 lib/facebook-social_plugins/helper/open_graph.rb
facebook-social_plugins-0.2.0 lib/facebook-social_plugins/helper/open_graph.rb