# File lib/omniauth/form.rb, line 101 def self.build(options = {},&block) form = OmniAuth::Form.new(options) if block.arity > 0 yield form else form.instance_eval(&block) end form end
# File lib/omniauth/form.rb, line 91 def initialize(options = {}) options[:title] ||= "Authentication Info Required" options[:header_info] ||= "" self.options = options @html = "" @with_custom_button = false header(options[:title],options[:header_info]) end
# File lib/omniauth/form.rb, line 142 def fieldset(legend, options = {}, &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
# File lib/omniauth/form.rb, line 149 def header(title,header_info) @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='#{options[:url]}' " if options[:url]}noValidate='noValidate'> " self end
# File lib/omniauth/form.rb, line 138 def html(html) @html << html end
# File lib/omniauth/form.rb, line 116 def input_field(type, name) @html << "\n<input type='#{type}' id='#{name}' name='#{name}'/>" self end
# File lib/omniauth/form.rb, line 111 def label_field(text, target) @html << "\n<label for='#{target}'>#{text}:</label>" self end
# File lib/omniauth/form.rb, line 127 def password_field(label, name) label_field(label, name) input_field('password', name) self end
# File lib/omniauth/form.rb, line 121 def text_field(label, name) label_field(label, name) input_field('text', name) self end
# File lib/omniauth/form.rb, line 178 def to_html footer @html end
# File lib/omniauth/form.rb, line 183 def to_response footer Rack::Response.new(@html).finish end
# File lib/omniauth/form.rb, line 190 def css "\n<style type='text/css'>#{OmniAuth.config.form_css}</style>" end