antage-merb-recaptcha 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/merb-recaptcha/controller_mixin.rb +1 -0
- data/lib/merb-recaptcha/view_helpers.rb +10 -6
- data/merb-recaptcha.gemspec +4 -4
- data/spec/spec_helper.rb +1 -0
- metadata +4 -4
data/Rakefile
CHANGED
@@ -9,6 +9,7 @@ module Merb # :nodoc:
|
|
9
9
|
# * It will raise exception, if Recaptcha API server returns error.
|
10
10
|
#
|
11
11
|
def recaptcha_valid?
|
12
|
+
return true if (Merb.testing? && !Merb::RecaptchaMixin.const_defined?(:DO_NOT_IGNORE_RECAPTCHA_IN_TESTING_ENV))
|
12
13
|
response = Net::HTTP.post_form(URI.parse("#{Merb::Recaptcha::API_VERIFY_SERVER}/verify"), {
|
13
14
|
:privatekey => Merb::Plugins.config[:merb_recaptcha][:private_key],
|
14
15
|
:remoteip => request.remote_ip,
|
@@ -67,19 +67,23 @@ module Merb # :nodoc:
|
|
67
67
|
xhtml = Builder::XmlMarkup.new(:target => result, :indent => 2)
|
68
68
|
if ajax
|
69
69
|
xhtml.script(:type => "text/javascript", :src => "#{api_url}/js/recaptcha_ajax.js") {}
|
70
|
-
xhtml.script(:type => "text/javascript") do
|
70
|
+
xhtml.script(:type => "text/javascript") do |js|
|
71
71
|
options_and_callback = callback.nil? ? options : options.merge(:callback => callback)
|
72
|
-
|
72
|
+
js << "//<![CDATA[\n"
|
73
|
+
js << "var options = #{hash_to_json(options_and_callback)};\n"
|
73
74
|
if ajax == :jquery
|
74
|
-
|
75
|
+
js << "$(document).ready(function() { Recaptcha.create('#{public_key}', document.getElementById('#{element_id}'), options); });\n"
|
75
76
|
else
|
76
|
-
|
77
|
+
js << "window.onload = function() { Recaptcha.create('#{public_key}', document.getElementById('#{element_id}'), options); };\n"
|
77
78
|
end
|
79
|
+
js << "//]]>\n"
|
78
80
|
end
|
79
81
|
else
|
80
82
|
unless options.empty?
|
81
|
-
xhtml.script(:type => "text/javascript") do
|
82
|
-
|
83
|
+
xhtml.script(:type => "text/javascript") do |js|
|
84
|
+
js << "//<![CDATA[\n"
|
85
|
+
js << "var RecaptchaOptions = #{hash_to_json(options)};\n"
|
86
|
+
js << "//]]>\n"
|
83
87
|
end
|
84
88
|
end
|
85
89
|
xhtml.script(:type => "text/javascript", :src => "#{api_url}/challenge?k=#{public_key}") {}
|
data/merb-recaptcha.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{merb-recaptcha}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Anton Ageev"]
|
9
|
-
s.date = %q{2008-12-
|
9
|
+
s.date = %q{2008-12-19}
|
10
10
|
s.description = %q{Merb plugin that provides helpers for recaptcha.net service}
|
11
11
|
s.email = %q{antage@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
|
13
|
-
s.files = ["LICENSE", "README.rdoc", "Rakefile", "TODO", "merb-recaptcha.gemspec", "lib/merb-recaptcha/constants.rb", "lib/merb-recaptcha/merbtasks.rb", "lib/merb-recaptcha/controller_mixin.rb", "lib/merb-recaptcha/view_helpers.rb", "lib/merb-recaptcha/exceptions.rb", "lib/merb-recaptcha.rb", "spec/spec_helper.rb", "spec/
|
13
|
+
s.files = ["LICENSE", "README.rdoc", "Rakefile", "TODO", "merb-recaptcha.gemspec", "lib/merb-recaptcha/constants.rb", "lib/merb-recaptcha/merbtasks.rb", "lib/merb-recaptcha/controller_mixin.rb", "lib/merb-recaptcha/view_helpers.rb", "lib/merb-recaptcha/exceptions.rb", "lib/merb-recaptcha.rb", "spec/spec_helper.rb", "spec/recaptcha_ajax_with_options_spec.rb", "spec/recaptcha_noajax_without_noscript_spec.rb", "spec/recaptcha_noajax_with_noscript_spec.rb", "spec/recaptcha_valid_spec.rb", "spec/recaptcha_ajax_spec.rb", "spec/recaptcha_ajax_with_callback_spec.rb", "spec/recaptcha_noajax_with_options_spec.rb", "spec/recaptcha_ajax_with_jquery_spec.rb", "spec/fixture/app/controllers/application.rb", "spec/fixture/app/controllers/exceptions.rb", "spec/fixture/app/controllers/recaptcha.rb", "spec/fixture/app/views/exceptions/not_acceptable.html.erb", "spec/fixture/app/views/exceptions/not_found.html.erb", "spec/fixture/app/views/layout/application.html.erb", "spec/fixture/app/views/recaptcha/ajax.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_callback.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_options.html.erb", "spec/fixture/app/views/recaptcha/noajax_without_noscript.html.erb", "spec/fixture/app/views/recaptcha/noajax_with_options.html.erb", "spec/fixture/app/views/recaptcha/noajax_with_noscript.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_jquery.html.erb", "spec/fixture/app/helpers/global_helpers.rb", "spec/fixture/app/helpers/recaptcha_helpers.rb"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{http://github.com/antage/merb-recaptcha/}
|
16
16
|
s.rdoc_options = ["--main", "README.rdoc"]
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.rubyforge_project = %q{merb-recaptcha}
|
19
19
|
s.rubygems_version = %q{1.3.1}
|
20
20
|
s.summary = %q{Merb plugin that provides helpers for recaptcha.net service}
|
21
|
-
s.test_files = ["spec/spec_helper.rb", "spec/
|
21
|
+
s.test_files = ["spec/spec_helper.rb", "spec/recaptcha_ajax_with_options_spec.rb", "spec/recaptcha_noajax_without_noscript_spec.rb", "spec/recaptcha_noajax_with_noscript_spec.rb", "spec/recaptcha_valid_spec.rb", "spec/recaptcha_ajax_spec.rb", "spec/recaptcha_ajax_with_callback_spec.rb", "spec/recaptcha_noajax_with_options_spec.rb", "spec/recaptcha_ajax_with_jquery_spec.rb", "spec/fixture/app/controllers/application.rb", "spec/fixture/app/controllers/exceptions.rb", "spec/fixture/app/controllers/recaptcha.rb", "spec/fixture/app/views/exceptions/not_acceptable.html.erb", "spec/fixture/app/views/exceptions/not_found.html.erb", "spec/fixture/app/views/layout/application.html.erb", "spec/fixture/app/views/recaptcha/ajax.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_callback.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_options.html.erb", "spec/fixture/app/views/recaptcha/noajax_without_noscript.html.erb", "spec/fixture/app/views/recaptcha/noajax_with_options.html.erb", "spec/fixture/app/views/recaptcha/noajax_with_noscript.html.erb", "spec/fixture/app/views/recaptcha/ajax_with_jquery.html.erb", "spec/fixture/app/helpers/global_helpers.rb", "spec/fixture/app/helpers/recaptcha_helpers.rb"]
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
24
24
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
data/spec/spec_helper.rb
CHANGED
@@ -19,6 +19,7 @@ Merb::BootLoader.after_app_loads do
|
|
19
19
|
Merb::Plugins.config[:merb_recaptcha][:private_key] = "QAAAAAA--private-key--AAAAAAAQ"
|
20
20
|
|
21
21
|
Merb::Router.prepare { default_routes }
|
22
|
+
Merb::RecaptchaMixin.const_set(:DO_NOT_IGNORE_RECAPTCHA_IN_TESTING_ENV, true)
|
22
23
|
end
|
23
24
|
Merb.start_environment(options)
|
24
25
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: antage-merb-recaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Ageev
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-19 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -70,12 +70,12 @@ files:
|
|
70
70
|
- lib/merb-recaptcha/exceptions.rb
|
71
71
|
- lib/merb-recaptcha.rb
|
72
72
|
- spec/spec_helper.rb
|
73
|
+
- spec/recaptcha_ajax_with_options_spec.rb
|
73
74
|
- spec/recaptcha_noajax_without_noscript_spec.rb
|
74
75
|
- spec/recaptcha_noajax_with_noscript_spec.rb
|
75
76
|
- spec/recaptcha_valid_spec.rb
|
76
77
|
- spec/recaptcha_ajax_spec.rb
|
77
78
|
- spec/recaptcha_ajax_with_callback_spec.rb
|
78
|
-
- spec/recaptcha_ajax_with_options_spec.rb
|
79
79
|
- spec/recaptcha_noajax_with_options_spec.rb
|
80
80
|
- spec/recaptcha_ajax_with_jquery_spec.rb
|
81
81
|
- spec/fixture/app/controllers/application.rb
|
@@ -122,12 +122,12 @@ specification_version: 2
|
|
122
122
|
summary: Merb plugin that provides helpers for recaptcha.net service
|
123
123
|
test_files:
|
124
124
|
- spec/spec_helper.rb
|
125
|
+
- spec/recaptcha_ajax_with_options_spec.rb
|
125
126
|
- spec/recaptcha_noajax_without_noscript_spec.rb
|
126
127
|
- spec/recaptcha_noajax_with_noscript_spec.rb
|
127
128
|
- spec/recaptcha_valid_spec.rb
|
128
129
|
- spec/recaptcha_ajax_spec.rb
|
129
130
|
- spec/recaptcha_ajax_with_callback_spec.rb
|
130
|
-
- spec/recaptcha_ajax_with_options_spec.rb
|
131
131
|
- spec/recaptcha_noajax_with_options_spec.rb
|
132
132
|
- spec/recaptcha_ajax_with_jquery_spec.rb
|
133
133
|
- spec/fixture/app/controllers/application.rb
|