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; } fieldset { border: 1px solid #ccc; border-left: 0; border-right: 0; padding: 10px 0; } fieldset input { width: 260px; font-size: 16px; } CSS
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #button(text) ⇒ Object
- #fieldset(legend, options = {}, &block) ⇒ Object
- #footer ⇒ Object
- #header(title, header_info) ⇒ Object
- #html(html) ⇒ Object
-
#initialize(options = {}) ⇒ 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(options = {}) ⇒ Form
Returns a new instance of Form.
91 92 93 94 95 96 97 98 99 |
# File 'lib/omniauth/form.rb', line 91 def initialize( = {}) [:title] ||= "Authentication Info Required" [:header_info] ||= "" self. = @html = "" @with_custom_button = false header([:title],[:header_info]) end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
89 90 91 |
# File 'lib/omniauth/form.rb', line 89 def @options end |
Class Method Details
Instance Method Details
#button(text) ⇒ Object
133 134 135 136 |
# File 'lib/omniauth/form.rb', line 133 def (text) @with_custom_button = true @html << "\n<button type='submit'>#{text}</button>" end |
#fieldset(legend, options = {}, &block) ⇒ Object
142 143 144 145 146 147 |
# File 'lib/omniauth/form.rb', line 142 def fieldset(legend, = {}, &block) @html << "\n<fieldset#{" style='#{[:style]}'" if [:style]}#{" id='#{[:id]}'" if [:id]}>\n <legend>#{legend}</legend>\n" self.instance_eval &block @html << "\n</fieldset>" self end |
#footer ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/omniauth/form.rb', line 166 def return self if @footer @html << "\n<button type='submit'>Connect</button>" unless @with_custom_button @html << <<-HTML </form> </body> </html> HTML @footer = true self end |
#header(title, header_info) ⇒ Object
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/omniauth/form.rb', line 149 def header(title,header_info) @html << <<-HTML <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>#{title}</title> #{css} #{header_info} </head> <body> <h1>#{title}</h1> <form method='post' #{"action='#{[:url]}' " if [:url]}noValidate='noValidate'> HTML self end |
#html(html) ⇒ Object
138 139 140 |
# File 'lib/omniauth/form.rb', line 138 def html(html) @html << html end |
#input_field(type, name) ⇒ Object
116 117 118 119 |
# File 'lib/omniauth/form.rb', line 116 def input_field(type, name) @html << "\n<input type='#{type}' id='#{name}' name='#{name}'/>" self end |
#label_field(text, target) ⇒ Object
111 112 113 114 |
# File 'lib/omniauth/form.rb', line 111 def label_field(text, target) @html << "\n<label for='#{target}'>#{text}:</label>" self end |
#password_field(label, name) ⇒ Object
127 128 129 130 131 |
# File 'lib/omniauth/form.rb', line 127 def password_field(label, name) label_field(label, name) input_field('password', name) self end |
#text_field(label, name) ⇒ Object
121 122 123 124 125 |
# File 'lib/omniauth/form.rb', line 121 def text_field(label, name) label_field(label, name) input_field('text', name) self end |
#to_html ⇒ Object
178 179 180 181 |
# File 'lib/omniauth/form.rb', line 178 def to_html @html end |
#to_response ⇒ Object
183 184 185 186 |
# File 'lib/omniauth/form.rb', line 183 def to_response Rack::Response.new(@html).finish end |