validates_captcha 0.9.7 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Validates Captcha
|
2
2
|
|
3
|
-
A captcha verification approach for Rails apps, directly integrated into
|
3
|
+
A captcha verification approach for Rails 2.3 apps, directly integrated into
|
4
4
|
ActiveRecord's validation mechanism and providing helpers for ActionController
|
5
5
|
and ActionView.
|
6
6
|
|
@@ -122,7 +122,8 @@ new challenge and updates the question/image after the request is complete.
|
|
122
122
|
|
123
123
|
+regenerate_captcha_challenge_link+ internally calls Rails' +link_to_remote+
|
124
124
|
helper method. So it relies on the Prototype javascript framework to be
|
125
|
-
available on the page.
|
125
|
+
available on the page. As of version 0.9.8 you can pass <tt>:jquery => true</tt>
|
126
|
+
as an option to render Javascript that's based on jQuery.
|
126
127
|
|
127
128
|
The anchor's text defaults to 'New question' (question challenge) and
|
128
129
|
'Regenerate Captcha' (image challenge) respectively. You can set this to
|
@@ -186,15 +186,20 @@ module ValidatesCaptcha
|
|
186
186
|
#
|
187
187
|
# Internally calls Rails' +link_to_remote+ helper method, passing the +options+ and
|
188
188
|
# +html_options+ arguments. So it relies on the Prototype javascript framework
|
189
|
-
# to be available on the web page.
|
189
|
+
# to be available on the web page. As of version 0.9.8 you can pass <tt>:jquery => true</tt>
|
190
|
+
# as an option to render Javascript that's based on jQuery.
|
190
191
|
#
|
191
192
|
# The anchor text defaults to 'Regenerate Captcha'. You can set this to a custom value
|
192
193
|
# providing a +:text+ key in the +options+ hash.
|
193
194
|
def render_regenerate_challenge_link(sanitized_object_name, object, options = {}, html_options = {})
|
194
195
|
text = options.delete(:text) || 'Regenerate Captcha'
|
195
|
-
|
196
|
-
|
197
|
-
|
196
|
+
if options.delete(:jquery)
|
197
|
+
onclick = "jQuery.getJSON('#{regenerate_path}', function(result){jQuery('##{sanitized_object_name}_captcha_image').attr('src',result.captcha_image_path); jQuery('##{sanitized_object_name}_captcha_challenge').val(result.captcha_challenge); jQuery('##{sanitized_object_name}_captcha_solution').val('');});return false;"
|
198
|
+
link_to text, "#", options.reverse_merge(:onclick => onclick), html_options
|
199
|
+
else
|
200
|
+
success = "var result = request.responseJSON; $('#{sanitized_object_name}_captcha_image').src = result.captcha_image_path; $('#{sanitized_object_name}_captcha_challenge').value = result.captcha_challenge; $('#{sanitized_object_name}_captcha_solution').value = '';"
|
201
|
+
link_to_remote text, options.reverse_merge(:url => regenerate_path, :method => :get, :success => success), html_options
|
202
|
+
end
|
198
203
|
end
|
199
204
|
|
200
205
|
private
|
@@ -17,7 +17,7 @@ module ValidatesCaptcha
|
|
17
17
|
"Bread, ham or milk: which is something to drink?" => "milk",
|
18
18
|
"What day is today, if yesterday was Friday?" => "Saturday",
|
19
19
|
"What day is today, if tomorrow is Tuesday?" => "Monday",
|
20
|
-
"What is the 2nd letter of the
|
20
|
+
"What is the 2nd letter of the third word in this question?" => "h",
|
21
21
|
"What color is the sky on a sunny day?" => "blue" }.freeze
|
22
22
|
|
23
23
|
@@questions_and_answers = DEFAULT_QUESTIONS_AND_ANSWERS
|
@@ -81,15 +81,20 @@ module ValidatesCaptcha
|
|
81
81
|
#
|
82
82
|
# Internally calls Rails' +link_to_remote+ helper method, passing the +options+ and
|
83
83
|
# +html_options+ arguments. So it relies on the Prototype javascript framework
|
84
|
-
# to be available on the web page.
|
84
|
+
# to be available on the web page. As of version 0.9.8 you can pass <tt>:jquery => true</tt>
|
85
|
+
# as an option to render Javascript that's based on jQuery.
|
85
86
|
#
|
86
87
|
# The anchor text defaults to 'New question'. You can set this to a custom value
|
87
88
|
# providing a +:text+ key in the +options+ hash.
|
88
89
|
def render_regenerate_challenge_link(sanitized_object_name, object, options = {}, html_options = {})
|
89
90
|
text = options.delete(:text) || 'New question'
|
90
|
-
|
91
|
-
|
92
|
-
|
91
|
+
if options.delete(:jquery)
|
92
|
+
onclick = "jQuery.getJSON('#{regenerate_path}', function(result){jQuery('##{sanitized_object_name}_captcha_question').text(result.captcha_challenge); jQuery('##{sanitized_object_name}_captcha_challenge').val(result.captcha_challenge); jQuery('##{sanitized_object_name}_captcha_solution').val('');});return false;"
|
93
|
+
link_to text, "#", options.reverse_merge(:onclick => onclick), html_options
|
94
|
+
else
|
95
|
+
success = "var result = request.responseJSON; $('#{sanitized_object_name}_captcha_question').update = result.captcha_challenge; $('#{sanitized_object_name}_captcha_challenge').value = result.captcha_challenge; $('#{sanitized_object_name}_captcha_solution').value = '';"
|
96
|
+
link_to_remote text, options.reverse_merge(:url => regenerate_path, :method => :get, :success => success), html_options
|
97
|
+
end
|
93
98
|
end
|
94
99
|
|
95
100
|
private
|
@@ -178,15 +178,20 @@ module ValidatesCaptcha
|
|
178
178
|
#
|
179
179
|
# Internally calls Rails' +link_to_remote+ helper method, passing the +options+ and
|
180
180
|
# +html_options+ arguments. So it relies on the Prototype javascript framework
|
181
|
-
# to be available on the web page.
|
181
|
+
# to be available on the web page. As of version 0.9.8 you can pass <tt>:jquery => true</tt>
|
182
|
+
# as an option to render Javascript that's based on jQuery.
|
182
183
|
#
|
183
184
|
# The anchor text defaults to 'Regenerate Captcha'. You can set this to a custom value
|
184
185
|
# providing a +:text+ key in the +options+ hash.
|
185
186
|
def render_regenerate_challenge_link(sanitized_object_name, object, options = {}, html_options = {})
|
186
187
|
text = options.delete(:text) || 'Regenerate Captcha'
|
187
|
-
|
188
|
-
|
189
|
-
|
188
|
+
if options.delete(:jquery)
|
189
|
+
onclick = "jQuery.getJSON('#{regenerate_path}', function(result){jQuery('##{sanitized_object_name}_captcha_image').attr('src',result.captcha_image_path); jQuery('##{sanitized_object_name}_captcha_challenge').val(result.captcha_challenge); jQuery('##{sanitized_object_name}_captcha_solution').val('');});return false;"
|
190
|
+
link_to text, "#", options.reverse_merge(:onclick => onclick), html_options
|
191
|
+
else
|
192
|
+
success = "var result = request.responseJSON; $('#{sanitized_object_name}_captcha_image').src = result.captcha_image_path; $('#{sanitized_object_name}_captcha_challenge').value = result.captcha_challenge; $('#{sanitized_object_name}_captcha_solution').value = '';"
|
193
|
+
link_to_remote text, options.reverse_merge(:url => regenerate_path, :method => :get, :success => success), html_options
|
194
|
+
end
|
190
195
|
end
|
191
196
|
|
192
197
|
private
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_captcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 43
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 8
|
10
|
+
version: 0.9.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Martin Andert
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-03 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
hash: 7
|
30
30
|
segments:
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
hash: 7
|
46
46
|
segments:
|
@@ -97,7 +97,7 @@ licenses: []
|
|
97
97
|
post_install_message:
|
98
98
|
rdoc_options:
|
99
99
|
- --title
|
100
|
-
- Validates Captcha 0.9.
|
100
|
+
- Validates Captcha 0.9.8
|
101
101
|
- --main
|
102
102
|
- README.rdoc
|
103
103
|
- --line-numbers
|