Class: OmniAuth::Form
- Inherits:
-
Object
- Object
- OmniAuth::Form
- Defined in:
- lib/omniauth/form.rb
Constant Summary collapse
- DEFAULT_CSS =
<<-CSS body { background: #ccc; font-family: "Lucida Grande", "Lucida Sans", Helvetica, Arial, sans-serif; } h1 { text-align: center; margin: 30px auto 0px; font-size: 18px; padding: 10px 10px 15px; background: #555; color: white; width: 320px; border: 10px solid #444; border-bottom: 0; -moz-border-radius-topleft: 10px; -moz-border-radius-topright: 10px; -webkit-border-top-left-radius: 10px; -webkit-border-top-right-radius: 10px; border-top-left-radius: 10px; border-top-right-radius: 10px; } h1, form { -moz-box-shadow: 2px 2px 7px rgba(0,0,0,0.3); -webkit-box-shadow: 2px 2px 7px rgba(0,0,0,0.3); } form { background: white; border: 10px solid #eee; border-top: 0; padding: 20px; margin: 0px auto 40px; width: 300px; -moz-border-radius-bottomleft: 10px; -moz-border-radius-bottomright: 10px; -webkit-border-bottom-left-radius: 10px; -webkit-border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; } label { display: block; font-weight: bold; margin-bottom: 5px; } input { font-size: 18px; padding: 4px 8px; display: block; margin-bottom: 10px; width: 280px; } input#identifier, input#openid_url { background: url(http://openid.net/login-bg.gif) no-repeat; background-position: 0 50%; padding-left: 18px; } button { font-size: 22px; padding: 4px 8px; display: block; margin: 20px auto 0; } CSS
Class Method Summary collapse
Instance Method Summary collapse
- #footer ⇒ Object
- #header(title) ⇒ Object
-
#initialize(title = nil) ⇒ Form
constructor
A new instance of Form.
- #input_field(type, name) ⇒ Object
- #label_field(text, target) ⇒ Object
- #password_field(label, name) ⇒ Object
- #text_field(label, name) ⇒ Object
- #to_html ⇒ Object
- #to_response ⇒ Object
Constructor Details
#initialize(title = nil) ⇒ Form
Returns a new instance of Form.
77 78 79 80 81 |
# File 'lib/omniauth/form.rb', line 77 def initialize(title=nil) title ||= "Authentication Info Required" @html = "" header(title) end |
Class Method Details
Instance Method Details
#footer ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/omniauth/form.rb', line 125 def return self if @footer @html << <<-HTML <button type='submit'>Connect</button> </form> </body> </html> HTML @footer = true self end |
#header(title) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/omniauth/form.rb', line 110 def header(title) @html << <<-HTML <!DOCTYPE html> <html> <head> <title>#{title}</title> #{css} </head> <body> <h1>#{title}</h1> <form method='post'> HTML self end |
#input_field(type, name) ⇒ Object
93 94 95 96 |
# File 'lib/omniauth/form.rb', line 93 def input_field(type, name) @html << "\n<input type='#{type}' id='#{name}' name='#{name}'/>" self end |
#label_field(text, target) ⇒ Object
88 89 90 91 |
# File 'lib/omniauth/form.rb', line 88 def label_field(text, target) @html << "\n<label for='#{target}'>#{text}:</label>" self end |
#password_field(label, name) ⇒ Object
104 105 106 107 108 |
# File 'lib/omniauth/form.rb', line 104 def password_field(label, name) label_field(label, name) input_field('password', name) self end |
#text_field(label, name) ⇒ Object
98 99 100 101 102 |
# File 'lib/omniauth/form.rb', line 98 def text_field(label, name) label_field(label, name) input_field('text', name) self end |
#to_html ⇒ Object
137 138 139 140 |
# File 'lib/omniauth/form.rb', line 137 def to_html @html end |
#to_response ⇒ Object
142 143 144 145 |
# File 'lib/omniauth/form.rb', line 142 def to_response Rack::Response.new(@html).finish end |