diff --git a/Rakefile b/Rakefile index 09b166a..aa8d84e 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,11 @@ require 'bundler' -Bundler::GemHelper.install_tasks \ No newline at end of file +Bundler::GemHelper.install_tasks + + +require 'rake/testtask' +Rake::TestTask.new(:test) do |t| + t.libs << 'test' + t.test_files = FileList['test/*\.rb'] + t.verbose = true +end + \ No newline at end of file diff --git a/lib/acts_as_opengraph/helper/acts_as_opengraph_helper.rb b/lib/acts_as_opengraph/helper/acts_as_opengraph_helper.rb index 1f9c273..d21af67 100644 --- a/lib/acts_as_opengraph/helper/acts_as_opengraph_helper.rb +++ b/lib/acts_as_opengraph/helper/acts_as_opengraph_helper.rb @@ -45,6 +45,36 @@ def like_button_for(obj, options = {}) end config[:locale] ||= 'en_US' + if config[:xfbml] + unless @fb_sdk_included + content_for :javascripts, fb_javascript_include_tag( config[:locale], config[:appid] ) + end + like_html = %() + else + like_html = %() + end + + like_html.respond_to?(:html_safe) ? like_html.html_safe : like_html + end + + def comments_for(obj, options = {}) + raise(ArgumentError.new, "You need to call acts_as_opengraph on your #{obj.class} model") unless obj.respond_to?(:opengraph_data) + href = options[:href] ? options[:href] : obj.opengraph_url + return unless href.present? + + onfig = { :layout => :standard, :show_faces => false, :width => 450, :action => :like, :colorscheme => :light } + config.update(options) if options.is_a?(Hash) + + o_layout = config[:layout].to_sym + if o_layout == :standard + config[:height] = config[:show_faces].to_s.to_sym == :true ? 80 : 35 + elsif o_layout == :button_count + config[:height] = 21 + elsif o_layout == :box_count + config[:height] = 65 + end + config[:locale] ||= 'en_US' + if config[:xfbml] unless @fb_sdk_included content_for :javascripts, fb_javascript_include_tag( config[:locale], config[:appid] ) diff --git a/test/opengraph_test.rb b/test/opengraph_test.rb index 1c639ab..ce428a5 100644 --- a/test/opengraph_test.rb +++ b/test/opengraph_test.rb @@ -39,7 +39,7 @@ class MovieTest < Test::Unit::TestCase -) +) GENERATED_LIKE_BUTTON = %() GENERATED_LIKE_BUTTON_CUSTOM_URL = %()