Module: Devise::RpxConnectable::Helpers

Defined in:
lib/devise_rpx_connectable/view_helpers.rb

Overview

RPX view helpers to easily add the link to the RPX connection popup and also the necessary JS code.

Instance Method Summary collapse

Instance Method Details

#embed_rpx(link_url, options = {}) ⇒ Object

Embeds the RPX connection iframe in your page. By default the RPX frame will refer to the RPX application name you defined in the configuration. It may be overriden using :application_name if the options. The first parameter is the return URL, it must be absolute (***_url). You can override default iframe size using :width and :height in the options.

Example : <%= embed_rpx user_session_url %>



36
37
38
39
40
# File 'lib/devise_rpx_connectable/view_helpers.rb', line 36

def embed_rpx(link_url, options={})
  token_url = build_token_url(link_url)
  out = RPXNow.embed_code(rpx_application_name_from_options(options), token_url, options)
  out.respond_to?(:html_safe) ? out.html_safe : out
end

#javascript_include_rpx(link_url, options = {}) ⇒ Object

Returns the necessary JS code for the RPX popup. It is recommended to put this code just before the </body> tag of your layout.

For example : … <%= javascript_include_rpx(user_session_url) %> </body> </html>



51
52
53
54
55
# File 'lib/devise_rpx_connectable/view_helpers.rb', line 51

def javascript_include_rpx(link_url, options={})
token_url = build_token_url(link_url)
  out = RPXNow.popup_source(rpx_application_name_from_options(options), token_url, options)
  out.respond_to?(:html_safe) ? out.html_safe : out
end

Creates the link to the RPX connection popup. If you create a link without putting the JS code, the popup will load in a new page. By default the RPX link will be linked to the RPX application name you defined in the configuration. It may be overriden using :application_name if the options. The second parameter is the return URL, it must be absolute (***_url).

For example : <%= link_to_rpx “Signin using RPX!”, user_session_url %>



20
21
22
23
24
25
# File 'lib/devise_rpx_connectable/view_helpers.rb', line 20

def link_to_rpx(link_text, link_url, options={})
  options = { :unobtrusive => true }.merge(options)
token_url = build_token_url(link_url)
out = RPXNow.popup_code(link_text, rpx_application_name_from_options(options), token_url, options)
out.respond_to?(:html_safe) ? out.html_safe : out
end