24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/sinatra/captcha.rb', line 24
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)
set_captcha_cache_class(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
|