Module: Sinatra::Captcha
- Defined in:
- lib/sinatra/captcha.rb
Defined Under Namespace
Classes: Image
Class Method Summary collapse
Class Method Details
.registered(app) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/sinatra/captcha.rb', line 17 def self.registered app app.helpers CaptchaHelpers app.set :captcha_ttl, 60 unless app.respond_to? :captcha_ttl app.set :captcha_level, 2 unless app.respond_to? :captcha_level app.set :captcha_width, 200 unless app.respond_to? :captcha_width app.set :captcha_height, 50 unless app.respond_to? :captcha_height app.set :captcha_handler, Image.new(app) app.get '/captcha/refresh' do content_type 'text/plain' app.captcha_handler.html('captcha', params['key']) end app.get '/captcha' do content_type 'text/plain' app.captcha_handler.html end app.get '/captcha/snippet/:id' do content_type 'text/plain' app.captcha_handler.html params[:id] end app.get '/captcha/:key' do expires 0, :no_cache content_type 'image/png' app.captcha_handler.image params[:key] end end |