Module: Devise::DeviseLoginza::Helpers

Defined in:
lib/devise_loginza/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#loginza_button_tag(*args, &block) ⇒ Object

Loginza button

Simple example:

<%= loginza_button_tag("Login via OpenID", clients_url) %>

With set of providers:

<%= loginza_button_tag("Login via OpenID", clients_url, :providers => [ :google, :facebook, :twitter ]) %>

With default provider:

<%= loginza_button_tag("Login via OpenID", clients_url, :provider => :google) %>

With a block:

<%= loginza_button_tag(clients_url, :provider => :google) do %>
  <div class='loginza'>
    ...
  </div>
<% end %>

Supported providers:

google, yandex, mailruapi, mailru, vkontakte, facebook, twitter, loginza, myopenid, webmoney, rambler, flickr, lastfm, verisign, aol, steam, openid.


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/devise_loginza/view_helpers.rb', line 31

def loginza_button_tag(*args, &block)
  if block_given?
    callback_url = args.first
    options      = args.second || {}
    html_options = args.third

    loginza_button_tag(capture(&block), callback_url,  options, html_options)
  else
    name         = args[0]
    callback_url = args[1]
    options      = args[2] || {}
    html_options = args[3] || {}

    html_options[:class] ||= "loginza"
    url = generate_url(callback_url, options)

    html = ""
    html << javascript_include_tag("http://s1.loginza.ru/js/widget.js")
    html << link_to(name, url, options, html_options)
    html
  end
end

#loginza_frame_tag(callback_url, options = {}, html_options = {}) ⇒ Object

Loginza frame

Simple example:

<%= loginza_frame_tag(clients_url, { :providers => [:google, :yandex, :mailru] }, { :style => "width:400px;height:350px;" }) %>


60
61
62
63
64
65
66
67
68
69
70
# File 'lib/devise_loginza/view_helpers.rb', line 60

def loginza_frame_tag(callback_url, options = {}, html_options = {})
  html_options = {
    :scrolling => "no",
    :frameborder => "no",
    :style => "width:359px;height:300px;",
  }.merge(html_options)

  html_options[:src] = generate_url(callback_url, options, { :overlay => 'loginza' })

  (:iframe, nil, html_options)
end

#loginza_jsObject



6
7
8
# File 'lib/devise_loginza/view_helpers.rb', line 6

def loginza_js
  javascript_include_tag("http://s1.loginza.ru/js/widget.js")
end