module PlataformaSocial module Helpers def plataforma_social_javascripts plataforma_social_script_tag + plataforma_social_config_script + signed_request_javascript end def plataforma_social_script_tag %Q{}.html_safe end def plataforma_social_config_script %Q{}.html_safe end def signed_request_javascript default_params = { :signed_request => params[:signed_request] || nil, :code => params[:code] || nil } %Q{ }.html_safe end def custom_redirect_to path, options = {}, protocol = '' options.each_pair do |key, value| cookies[key] = value end protocol = "#{protocol}:" if protocol.present? render :text => %Q{ } end def from_facebook? request.referer && request.referer.index('facebook.com') end def from_admin? params.present? && params[:controller].present? && params[:controller].index(PlataformaSocial.admin_controller_name) == 0 end def link_to_facebook *args, &block if block_given? href = capture(&block) args.unshift(href) link_to_facebook *args else args[2] ||= {} server_domain = request.env['HTTP_HOST'] url = 'apps.facebook.com/' + PlataformaSocial.facebook_app_namespace if args[1].include? server_domain args[1].gsub! server_domain, url else args[1] = request.protocol + url + args[1] end args[2][:target] = '_top' return link_to *args end end end end ActiveSupport.on_load(:action_view) do include PlataformaSocial::Helpers end class ActionController::Base include PlataformaSocial::Helpers end