module GoSocial
module Like
include GoSocial::Assistant
LIKE_BUTTON_CLASS = "fb-like"
LIKE_BOX_CLASS = "fb-like-box"
COMMENT_CLASS = "fb-comments"
# Facebook Like Button
def like_button(app_id, options = {})
clazz = GoSocial::Like
params = clazz.options_to_data(clazz.default_options_like_button.merge(options))
params.merge!(class: LIKE_BUTTON_CLASS)
html = "".html_safe
html << content_tag(:div, nil, id: "fb-root")
html << clazz.script(app_id)
html << content_tag(:div, nil, params)
html
end
# Facebook Like Box
def like_box(app_id, options = {})
clazz = GoSocial::Like
params = clazz.options_to_data(clazz.default_options_like_box.merge(options))
params.merge!(class: LIKE_BOX_CLASS)
html = "".html_safe
html << content_tag(:div, nil, id: "fb-root")
html << clazz.script(app_id)
html << content_tag(:div, nil, params)
html
end
# Facebook Comment Box
def comment_box(app_id, options = {})
clazz = GoSocial::Like
params = clazz.options_to_data(clazz.default_options_comment_box.merge(options))
params.merge!(class: COMMENT_CLASS)
html = "".html_safe
html << content_tag(:div, nil, id: "fb-root")
html << clazz.script(app_id)
html << content_tag(:div, nil, params)
html
end
# To avoid polluting namespace in like button
class << self
def default_options_like_button
@default_options ||= {
send: "false",
layout: "box_count",
width: "250",
action: "like",
font: "arial",
colorscheme: "light"
}.merge("show-faces" => "false")
end
# To avoid polluting namespace in like box
def default_options_like_box
@default_options ||= {
send: "false",
stream: "true",
width: "250",
show-border: "true",
header: "true",
colorscheme: "light"
}.merge("show-faces" => "true")
end
# To avoid polluting namespace in comment box
def default_options_comment_box
@default_options ||= {
width: "250",
colorscheme: "light"
}.merge("num-posts" => "2")
end
def script(app_id)
return blank_content if scriptized?
@scriptized = true
# "".html_safe
''.html_safe
end
#def js_sdk app_id
# "https://connect.facebook.net/en_US/all.js#xfbml=1&appId=#{app_id}"
#end
end
end
end