Class: OmniAuth::Form
- Inherits:
-
Object
- Object
- OmniAuth::Form
- Defined in:
- lib/omniauth/form.rb
Constant Summary collapse
- DEFAULT_CSS =
"body {\n background: #ccc;\n font-family: \"Lucida Grande\", \"Lucida Sans\", Helvetica, Arial, sans-serif;\n}\n\nh1 {\n text-align: center;\n margin: 30px auto 0px;\n font-size: 18px;\n padding: 10px 10px 15px;\n background: #555;\n color: white;\n width: 320px;\n border: 10px solid #444;\n border-bottom: 0;\n -moz-border-radius-topleft: 10px;\n -moz-border-radius-topright: 10px;\n -webkit-border-top-left-radius: 10px;\n -webkit-border-top-right-radius: 10px;\n border-top-left-radius: 10px;\n border-top-right-radius: 10px;\n}\n\nh1, form {\n -moz-box-shadow: 2px 2px 7px rgba(0,0,0,0.3);\n -webkit-box-shadow: 2px 2px 7px rgba(0,0,0,0.3);\n}\n\nform {\n background: white;\n border: 10px solid #eee;\n border-top: 0;\n padding: 20px;\n margin: 0px auto 40px;\n width: 300px;\n -moz-border-radius-bottomleft: 10px;\n -moz-border-radius-bottomright: 10px;\n -webkit-border-bottom-left-radius: 10px;\n -webkit-border-bottom-right-radius: 10px;\n border-bottom-left-radius: 10px;\n border-bottom-right-radius: 10px;\n}\n\nlabel {\n display: block;\n font-weight: bold;\n margin-bottom: 5px;\n}\n\ninput {\n font-size: 18px;\n padding: 4px 8px;\n display: block;\n margin-bottom: 10px;\n width: 280px;\n}\n\ninput#identifier, input#openid_url {\n background: url(http://openid.net/login-bg.gif) no-repeat;\n background-position: 0 50%;\n padding-left: 18px;\n}\n\nbutton {\n font-size: 22px;\n padding: 4px 8px;\n display: block;\n margin: 20px auto 0;\n}\n\nfieldset {\n border: 1px solid #ccc;\n border-left: 0;\n border-right: 0;\n padding: 10px 0;\n}\n\nfieldset input {\n width: 260px;\n font-size: 16px;\n}\n"
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
91 92 93 94 95 96 97 98 |
# File 'lib/omniauth/form.rb', line 91 def initialize( = {}) [:title] ||= "Authentication Info Required" [:header_info] ||= "" self. = @html = "" 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 end |
Class Method Details
.build(title = nil, &block) ⇒ Object
100 101 102 103 |
# File 'lib/omniauth/form.rb', line 100 def self.build(title=nil,&block) form = OmniAuth::Form.new(title) form.instance_eval(&block) end |
Instance Method Details
#button(text) ⇒ Object
127 128 129 |
# File 'lib/omniauth/form.rb', line 127 def (text) @html << "\n<button type='submit'>#{text}</button>" end |
#fieldset(legend, options = {}, &block) ⇒ Object
135 136 137 138 139 140 |
# File 'lib/omniauth/form.rb', line 135 def fieldset(legend, = {}, &block) @html << "\n<fieldset#{" style='#{options[:style]}'" if options[:style]}#{" id='#{options[:id]}'" if options[:id]}>\n <legend>#{legend}</legend>\n" self.instance_eval &block @html << "\n</fieldset>" self end |
#footer ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/omniauth/form.rb', line 158 def return self if @html << " <button type='submit'>Connect</button>\n </form>\n </body>\n </html>\n HTML\n @footer = true\n self\nend\n" |
#header(title, header_info) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/omniauth/form.rb', line 142 def header(title,header_info) @html << " <!DOCTYPE html>\n <html>\n <head>\n <title>\#{title}</title>\n \#{css}\n \#{header_info}\n </head>\n <body>\n <h1>\#{title}</h1>\n <form method='post' \#{\"action='\#{options[:url]}' \" if options[:url]}noValidate='noValidate'>\n HTML\n self\nend\n" |
#html(html) ⇒ Object
131 132 133 |
# File 'lib/omniauth/form.rb', line 131 def html(html) @html << html end |
#input_field(type, name) ⇒ Object
110 111 112 113 |
# File 'lib/omniauth/form.rb', line 110 def input_field(type, name) @html << "\n<input type='#{type}' id='#{name}' name='#{name}'/>" self end |
#label_field(text, target) ⇒ Object
105 106 107 108 |
# File 'lib/omniauth/form.rb', line 105 def label_field(text, target) @html << "\n<label for='#{target}'>#{text}:</label>" self end |
#password_field(label, name) ⇒ Object
121 122 123 124 125 |
# File 'lib/omniauth/form.rb', line 121 def password_field(label, name) label_field(label, name) input_field('password', name) self end |
#text_field(label, name) ⇒ Object
115 116 117 118 119 |
# File 'lib/omniauth/form.rb', line 115 def text_field(label, name) label_field(label, name) input_field('text', name) self end |
#to_html ⇒ Object
170 171 172 173 |
# File 'lib/omniauth/form.rb', line 170 def to_html @html end |
#to_response ⇒ Object
175 176 177 178 |
# File 'lib/omniauth/form.rb', line 175 def to_response Rack::Response.new(@html).finish end |