aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vendor/gems/recaptcha-0.3.1/.specification111
-rw-r--r--vendor/gems/recaptcha-0.3.1/CHANGELOG23
-rw-r--r--vendor/gems/recaptcha-0.3.1/LICENSE (renamed from vendor/plugins/recaptcha/LICENSE)0
-rw-r--r--vendor/gems/recaptcha-0.3.1/README.rdoc123
-rw-r--r--vendor/gems/recaptcha-0.3.1/Rakefile60
-rw-r--r--vendor/gems/recaptcha-0.3.1/VERSION1
-rw-r--r--vendor/gems/recaptcha-0.3.1/init.rb6
-rw-r--r--vendor/gems/recaptcha-0.3.1/lib/recaptcha.rb40
-rw-r--r--vendor/gems/recaptcha-0.3.1/lib/recaptcha/client_helper.rb42
-rw-r--r--vendor/gems/recaptcha-0.3.1/lib/recaptcha/configuration.rb52
-rw-r--r--vendor/gems/recaptcha-0.3.1/lib/recaptcha/merb.rb4
-rw-r--r--vendor/gems/recaptcha-0.3.1/lib/recaptcha/rails.rb4
-rw-r--r--vendor/gems/recaptcha-0.3.1/lib/recaptcha/verify.rb51
-rw-r--r--vendor/gems/recaptcha-0.3.1/recaptcha.gemspec62
-rw-r--r--vendor/gems/recaptcha-0.3.1/tasks/recaptcha_tasks.rake (renamed from vendor/plugins/recaptcha/tasks/recaptcha_tasks.rake)0
-rw-r--r--vendor/gems/recaptcha-0.3.1/test/recaptcha_test.rb39
-rw-r--r--vendor/gems/recaptcha-0.3.1/test/verify_recaptcha_test.rb95
-rw-r--r--vendor/plugins/recaptcha/README5
-rw-r--r--vendor/plugins/recaptcha/Rakefile23
-rw-r--r--vendor/plugins/recaptcha/init.rb3
-rw-r--r--vendor/plugins/recaptcha/install.rb1
-rw-r--r--vendor/plugins/recaptcha/lib/recaptcha.rb69
-rw-r--r--vendor/plugins/recaptcha/test/recaptcha_test.rb49
-rw-r--r--vendor/plugins/recaptcha/uninstall.rb1
24 files changed, 713 insertions, 151 deletions
diff --git a/vendor/gems/recaptcha-0.3.1/.specification b/vendor/gems/recaptcha-0.3.1/.specification
new file mode 100644
index 000000000..b7234754d
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/.specification
@@ -0,0 +1,111 @@
+--- !ruby/object:Gem::Specification
+name: recaptcha
+version: !ruby/object:Gem::Version
+ hash: 17
+ prerelease: false
+ segments:
+ - 0
+ - 3
+ - 1
+ version: 0.3.1
+platform: ruby
+authors:
+- Jason L. Perry
+autorequire:
+bindir: bin
+cert_chain: []
+
+date: 2010-12-20 00:00:00 +00:00
+default_executable:
+dependencies:
+- !ruby/object:Gem::Dependency
+ name: mocha
+ prerelease: false
+ requirement: &id001 !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 3
+ segments:
+ - 0
+ version: "0"
+ type: :development
+ version_requirements: *id001
+- !ruby/object:Gem::Dependency
+ name: activesupport
+ prerelease: false
+ requirement: &id002 !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 3
+ segments:
+ - 0
+ version: "0"
+ type: :development
+ version_requirements: *id002
+description: "This plugin adds helpers for the reCAPTCHA API "
+email: jasper@ambethia.com
+executables: []
+
+extensions: []
+
+extra_rdoc_files:
+- LICENSE
+- README.rdoc
+files:
+- CHANGELOG
+- LICENSE
+- README.rdoc
+- Rakefile
+- VERSION
+- init.rb
+- lib/recaptcha.rb
+- lib/recaptcha/client_helper.rb
+- lib/recaptcha/configuration.rb
+- lib/recaptcha/merb.rb
+- lib/recaptcha/rails.rb
+- lib/recaptcha/verify.rb
+- recaptcha.gemspec
+- tasks/recaptcha_tasks.rake
+- test/recaptcha_test.rb
+- test/verify_recaptcha_test.rb
+has_rdoc: true
+homepage: http://ambethia.com/recaptcha
+licenses: []
+
+post_install_message:
+rdoc_options: []
+
+require_paths:
+- lib
+required_ruby_version: !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 3
+ segments:
+ - 0
+ version: "0"
+required_rubygems_version: !ruby/object:Gem::Requirement
+ none: false
+ requirements:
+ - - ">="
+ - !ruby/object:Gem::Version
+ hash: 3
+ segments:
+ - 0
+ version: "0"
+requirements: []
+
+rubyforge_project:
+rubygems_version: 1.3.7
+signing_key:
+specification_version: 3
+summary: Helpers for the reCAPTCHA API
+test_files:
+- test/recaptcha_test.rb
+- test/verify_recaptcha_test.rb
diff --git a/vendor/gems/recaptcha-0.3.1/CHANGELOG b/vendor/gems/recaptcha-0.3.1/CHANGELOG
new file mode 100644
index 000000000..92a63fd8e
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/CHANGELOG
@@ -0,0 +1,23 @@
+== 0.2.2 / 2009-09-14
+
+* Add a timeout to the validator
+* Give the documentation some love
+
+== 0.2.1 / 2009-09-14
+
+* Removed Ambethia namespace, and restructured classes a bit
+* Added an example rails app in the example-rails branch
+
+== 0.2.0 / 2009-09-12
+
+* RecaptchaOptions AJAX API Fix
+* Added 'cucumber' as a test environment to skip
+* Ruby 1.9 compat fixes
+* Added option :message => 'Custom error message' to verify_recaptcha
+* Removed dependency on ActiveRecord constant
+* Add I18n
+
+== 0.1.0 / 2008-2-8
+
+* 1 major enhancement
+ * Initial Gem Release \ No newline at end of file
diff --git a/vendor/plugins/recaptcha/LICENSE b/vendor/gems/recaptcha-0.3.1/LICENSE
index dc9c67e75..dc9c67e75 100644
--- a/vendor/plugins/recaptcha/LICENSE
+++ b/vendor/gems/recaptcha-0.3.1/LICENSE
diff --git a/vendor/gems/recaptcha-0.3.1/README.rdoc b/vendor/gems/recaptcha-0.3.1/README.rdoc
new file mode 100644
index 000000000..e91fb1d52
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/README.rdoc
@@ -0,0 +1,123 @@
+= reCAPTCHA
+
+Author:: Jason L Perry (http://ambethia.com)
+Copyright:: Copyright (c) 2007 Jason L Perry
+License:: {MIT}[http://creativecommons.org/licenses/MIT/]
+Info:: http://ambethia.com/recaptcha
+Git:: http://github.com/ambethia/recaptcha/tree/master
+Bugs:: http://github.com/ambethia/recaptcha/issues
+
+This plugin adds helpers for the {reCAPTCHA API}[http://recaptcha.net]. In your
+views you can use the +recaptcha_tags+ method to embed the needed javascript,
+and you can validate in your controllers with +verify_recaptcha+.
+
+Beforehand you need to configure Recaptcha with your custom private and public
+key. You may find detailed examples below. Exceptions will be raised if you
+call these methods and the keys can't be found.
+
+== About this fork
+
+This fork tries to introduces a more convenient way to configure recaptcha's
+settings. The API will be inspired by {Thoughtbot's
+Hoptoad}[http://robots.thoughtbot.com/post/344833329/mygem-configure-block].
+
+== Rails Installation
+
+reCAPTCHA for Rails can be installed as a gem:
+
+ config.gem "recaptcha", :lib => "recaptcha/rails"
+
+Or, as a standard rails plugin:
+
+ script/plugin install git://github.com/ambethia/recaptcha.git
+
+== Merb Installation
+
+reCAPTCHA can also be used in a Merb application when installed as a gem:
+
+ dependency "alm-recaptcha", ">=0.2.2.1", :require_as => "recaptcha/merb"
+
+Initial Merb compatability funded by ALM Labs.
+
+== Setting up your API Keys
+
+There are multiple ways to setup your reCAPTCHA API key once you
+{obtain}[http://recaptcha.net/whyrecaptcha.html] a pair.
+
+=== Recaptcha.configure
+
+You may use the block style configuration. The following code could be placed
+into a +config/initializers/recaptcha.rb+ when used in a Rails project.
+
+ Recaptcha.configure do |config|
+ config.public_key = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
+ config.private_key = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
+ end
+
+This way, you may also set additional options to fit recaptcha into your
+deployment environment.
+
+=== Shell environment
+
+Or, you can keep your keys out of your code base by exporting the following
+environment variables. You might do this in the .profile/rc, or equivalent for
+the user running your application:
+
+ export RECAPTCHA_PUBLIC_KEY = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
+ export RECAPTCHA_PRIVATE_KEY = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
+
+=== Per call
+
+You can also pass in your keys as options at runtime, for example:
+
+ recaptcha_tags :public_key => '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
+
+and later,
+
+ verify_recaptcha :private_key => '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
+
+This option might be useful, if the same code base is used for multiple
+reCAPTCHA setups.
+
+== +recaptcha_tags+
+
+Some of the options available:
+
+<tt>:ssl</tt>:: Uses secure http for captcha widget (default +false+)
+<tt>:noscript</tt>:: Include <noscript> content (default +true+)
+<tt>:display</tt>:: Takes a hash containing the +theme+ and +tabindex+ options per the API. (default +nil+)
+<tt>:ajax</tt>:: Render the dynamic AJAX captcha per the API. (default +false+)
+<tt>:public_key</tt>:: Your public API key, takes precedence over the ENV variable (default +nil+)
+<tt>:error</tt>:: Override the error code returned from the reCAPTCHA API (default +nil+)
+
+You can also override the html attributes for the sizes of the generated +textarea+ and +iframe+
+elements, if CSS isn't your thing. Inspect the source of +recaptcha_tags+ to see these options.
+
+== +verify_recaptcha+
+
+This method returns +true+ or +false+ after processing the parameters from the reCAPTCHA widget. Why
+isn't this a model validation? Because that violates MVC. Use can use it like this, or how ever you
+like. Passing in the ActiveRecord object is optional, if you do--and the captcha fails to verify--an
+error will be added to the object for you to use.
+
+Some of the options available:
+
+<tt>:model</tt>:: Model to set errors
+<tt>:attribute</tt>:: Model attribute to receive errors (default :base)
+<tt>:message</tt>:: Custom error message
+<tt>:private_key</tt>:: Your private API key, takes precedence over the ENV variable (default +nil+).
+<tt>:timeout</tt>:: The number of seconds to wait for reCAPTCHA servers before give up. (default +3+)
+
+ respond_to do |format|
+ if verify_recaptcha(:model => @post, :message => "Oh! It's error with reCAPTCHA!") && @post.save
+ # ...
+ else
+ # ...
+ end
+ end
+
+== TODO
+* Remove Rails/ActionController dependencies
+* Framework agnostic
+* Add some helpers to use in before_filter and what not
+* Better documentation
diff --git a/vendor/gems/recaptcha-0.3.1/Rakefile b/vendor/gems/recaptcha-0.3.1/Rakefile
new file mode 100644
index 000000000..a56b58d1d
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/Rakefile
@@ -0,0 +1,60 @@
+require 'rake'
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gem|
+ gem.name = "recaptcha"
+ gem.description = "This plugin adds helpers for the reCAPTCHA API "
+ gem.summary = "Helpers for the reCAPTCHA API"
+ gem.homepage = "http://ambethia.com/recaptcha"
+ gem.authors = ["Jason L. Perry"]
+ gem.email = "jasper@ambethia.com"
+ gem.files.reject! { |fn| fn.include? ".gitignore" }
+ gem.add_development_dependency "mocha"
+ gem.add_development_dependency "activesupport"
+ end
+ Jeweler::GemcutterTasks.new
+rescue LoadError
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
+end
+
+require 'rake/rdoctask'
+Rake::RDocTask.new do |rd|
+ if File.exist?('VERSION.yml')
+ config = YAML.load(File.read('VERSION.yml'))
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
+ else
+ version = ""
+ end
+
+ rd.main = "README.rdoc"
+ rd.rdoc_files.include "README.rdoc", "LICENSE", "lib/**/*.rb"
+ rd.rdoc_dir = 'rdoc'
+ rd.options << '-N' # line numbers
+ rd.options << '-S' # inline source
+end
+
+require 'rake/testtask'
+Rake::TestTask.new(:test) do |test|
+ test.libs << 'test'
+ test.pattern = 'test/**/*_test.rb'
+ # test.verbose = true
+end
+
+begin
+ require 'rcov/rcovtask'
+ Rcov::RcovTask.new do |test|
+ test.libs << 'test'
+ test.pattern = 'test/**/*_test.rb'
+ test.verbose = true
+ end
+rescue LoadError
+ task :rcov do
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
+ end
+end
+
+task :default => :test
+
+
+
diff --git a/vendor/gems/recaptcha-0.3.1/VERSION b/vendor/gems/recaptcha-0.3.1/VERSION
new file mode 100644
index 000000000..a2268e2de
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/VERSION
@@ -0,0 +1 @@
+0.3.1 \ No newline at end of file
diff --git a/vendor/gems/recaptcha-0.3.1/init.rb b/vendor/gems/recaptcha-0.3.1/init.rb
new file mode 100644
index 000000000..2e9a27ac8
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/init.rb
@@ -0,0 +1,6 @@
+# Rails plugin initialization.
+# You can also install it as a gem:
+# config.gem "ambethia-recaptcha", :lib => "recaptcha/rails", :source => "http://gems.github.com"
+
+require 'net/http'
+require 'recaptcha/rails' \ No newline at end of file
diff --git a/vendor/gems/recaptcha-0.3.1/lib/recaptcha.rb b/vendor/gems/recaptcha-0.3.1/lib/recaptcha.rb
new file mode 100644
index 000000000..cb6f039a4
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/lib/recaptcha.rb
@@ -0,0 +1,40 @@
+require 'recaptcha/configuration'
+require 'recaptcha/client_helper'
+require 'recaptcha/verify'
+
+module Recaptcha
+ module VERSION #:nodoc:
+ MAJOR = 0
+ MINOR = 2
+ TINY = 2
+ PATCH = 1
+
+ STRING = [MAJOR, MINOR, TINY, PATCH].join('.')
+ end
+
+
+ RECAPTCHA_API_SERVER_URL = 'http://www.google.com/recaptcha/api'
+ RECAPTCHA_API_SECURE_SERVER_URL = 'https://www.google.com/recaptcha/api'
+ RECAPTCHA_VERIFY_URL = 'http://www.google.com/recaptcha/api/verify'
+
+ SKIP_VERIFY_ENV = ['test', 'cucumber']
+
+ # Gives access to the current Configuration.
+ def self.configuration
+ @configuration ||= Configuration.new
+ end
+
+ # Allows easy setting of multiple configuration options. See Configuration
+ # for all available options.
+ #--
+ # The temp assignment is only used to get a nicer rdoc. Feel free to remove
+ # this hack.
+ #++
+ def self.configure
+ config = configuration
+ yield(config)
+ end
+
+ class RecaptchaError < StandardError
+ end
+end
diff --git a/vendor/gems/recaptcha-0.3.1/lib/recaptcha/client_helper.rb b/vendor/gems/recaptcha-0.3.1/lib/recaptcha/client_helper.rb
new file mode 100644
index 000000000..2d54178e1
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/lib/recaptcha/client_helper.rb
@@ -0,0 +1,42 @@
+module Recaptcha
+ module ClientHelper
+ # Your public API can be specified in the +options+ hash or preferably
+ # using the Configuration.
+ def recaptcha_tags(options = {})
+ # Default options
+ key = options[:public_key] ||= Recaptcha.configuration.public_key
+ raise RecaptchaError, "No public key specified." unless key
+ error = options[:error] ||= (defined? flash ? flash[:recaptcha_error] : "")
+ uri = Recaptcha.configuration.api_server_url(options[:ssl])
+ html = ""
+ if options[:display]
+ html << %{<script type="text/javascript">\n}
+ html << %{ var RecaptchaOptions = #{options[:display].to_json};\n}
+ html << %{</script>\n}
+ end
+ if options[:ajax]
+ html << %{<div id="dynamic_recaptcha"></div>}
+ html << %{<script type="text/javascript" src="#{uri}/js/recaptcha_ajax.js"></script>\n}
+ html << %{<script type="text/javascript">\n}
+ html << %{ Recaptcha.create('#{key}', document.getElementById('dynamic_recaptcha')#{options[:display] ? ',RecaptchaOptions' : ''});}
+ html << %{</script>\n}
+ else
+ html << %{<script type="text/javascript" src="#{uri}/challenge?k=#{key}}
+ html << %{#{error ? "&amp;error=#{CGI::escape(error)}" : ""}"></script>\n}
+ unless options[:noscript] == false
+ html << %{<noscript>\n }
+ html << %{<iframe src="#{uri}/noscript?k=#{key}" }
+ html << %{height="#{options[:iframe_height] ||= 300}" }
+ html << %{width="#{options[:iframe_width] ||= 500}" }
+ html << %{style="border:none;"></iframe><br/>\n }
+ html << %{<textarea name="recaptcha_challenge_field" }
+ html << %{rows="#{options[:textarea_rows] ||= 3}" }
+ html << %{cols="#{options[:textarea_cols] ||= 40}"></textarea>\n }
+ html << %{<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>}
+ html << %{</noscript>\n}
+ end
+ end
+ return html.html_safe
+ end # recaptcha_tags
+ end # ClientHelper
+end # Recaptcha
diff --git a/vendor/gems/recaptcha-0.3.1/lib/recaptcha/configuration.rb b/vendor/gems/recaptcha-0.3.1/lib/recaptcha/configuration.rb
new file mode 100644
index 000000000..210470a5b
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/lib/recaptcha/configuration.rb
@@ -0,0 +1,52 @@
+module Recaptcha
+ # This class enables detailed configuration of the recaptcha services.
+ #
+ # By calling
+ #
+ # Recaptcha.configuration # => instance of Recaptcha::Configuration
+ #
+ # or
+ # Recaptcha.configure do |config|
+ # config # => instance of Recaptcha::Configuration
+ # end
+ #
+ # you are able to perform configuration updates.
+ #
+ # Your are able to customize all attributes listed below. All values have
+ # sensitive default and will very likely not need to be changed.
+ #
+ # Please note that the public and private key for the reCAPTCHA API Access
+ # have no useful default value. The keys may be set via the Shell enviroment
+ # or using this configuration. Settings within this configuration always take
+ # precedence.
+ #
+ # Setting the keys with this Configuration
+ #
+ # Recaptcha.configure do |config|
+ # config.public_key = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
+ # config.private_key = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
+ # end
+ #
+ class Configuration
+ attr_accessor :nonssl_api_server_url,
+ :ssl_api_server_url,
+ :verify_url,
+ :skip_verify_env,
+ :private_key,
+ :public_key
+
+ def initialize #:nodoc:
+ @nonssl_api_server_url = RECAPTCHA_API_SERVER_URL
+ @ssl_api_server_url = RECAPTCHA_API_SECURE_SERVER_URL
+ @verify_url = RECAPTCHA_VERIFY_URL
+ @skip_verify_env = SKIP_VERIFY_ENV
+
+ @private_key = ENV['RECAPTCHA_PRIVATE_KEY']
+ @public_key = ENV['RECAPTCHA_PUBLIC_KEY']
+ end
+
+ def api_server_url(ssl = false) #:nodoc:
+ ssl ? ssl_api_server_url : nonssl_api_server_url
+ end
+ end
+end
diff --git a/vendor/gems/recaptcha-0.3.1/lib/recaptcha/merb.rb b/vendor/gems/recaptcha-0.3.1/lib/recaptcha/merb.rb
new file mode 100644
index 000000000..ed7b1928f
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/lib/recaptcha/merb.rb
@@ -0,0 +1,4 @@
+require 'recaptcha'
+
+Merb::GlobalHelpers.send(:include, Recaptcha::ClientHelper)
+Merb::Controller.send(:include, Recaptcha::Verify)
diff --git a/vendor/gems/recaptcha-0.3.1/lib/recaptcha/rails.rb b/vendor/gems/recaptcha-0.3.1/lib/recaptcha/rails.rb
new file mode 100644
index 000000000..08741cfd2
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/lib/recaptcha/rails.rb
@@ -0,0 +1,4 @@
+require 'recaptcha'
+
+ActionView::Base.send(:include, Recaptcha::ClientHelper)
+ActionController::Base.send(:include, Recaptcha::Verify) \ No newline at end of file
diff --git a/vendor/gems/recaptcha-0.3.1/lib/recaptcha/verify.rb b/vendor/gems/recaptcha-0.3.1/lib/recaptcha/verify.rb
new file mode 100644
index 000000000..733ce31be
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/lib/recaptcha/verify.rb
@@ -0,0 +1,51 @@
+module Recaptcha
+ module Verify
+ # Your private API can be specified in the +options+ hash or preferably
+ # using the Configuration.
+ def verify_recaptcha(options = {})
+ if !options.is_a? Hash
+ options = {:model => options}
+ end
+
+ env = options[:env] || ENV['RAILS_ENV']
+ return true if Recaptcha.configuration.skip_verify_env.include? env
+ model = options[:model]
+ attribute = options[:attribute] || :base
+ private_key = options[:private_key] || Recaptcha.configuration.private_key
+ raise RecaptchaError, "No private key specified." unless private_key
+
+ begin
+ recaptcha = nil
+ Timeout::timeout(options[:timeout] || 3) do
+ recaptcha = Net::HTTP.post_form URI.parse(Recaptcha.configuration.verify_url), {
+ "privatekey" => private_key,
+ "remoteip" => request.remote_ip,
+ "challenge" => params[:recaptcha_challenge_field],
+ "response" => params[:recaptcha_response_field]
+ }
+ end
+ answer, error = recaptcha.body.split.map { |s| s.chomp }
+ unless answer == 'true'
+ flash[:recaptcha_error] = error
+ if model
+ model.valid?
+ model.errors.add attribute, options[:message] || "Word verification response is incorrect, please try again."
+ end
+ return false
+ else
+ flash[:recaptcha_error] = nil
+ return true
+ end
+ rescue Timeout::Error
+ flash[:recaptcha_error] = "recaptcha-not-reachable"
+ if model
+ model.valid?
+ model.errors.add attribute, options[:message] || "Oops, we failed to validate your word verification response. Please try again."
+ end
+ return false
+ rescue Exception => e
+ raise RecaptchaError, e.message, e.backtrace
+ end
+ end # verify_recaptcha
+ end # Verify
+end # Recaptcha
diff --git a/vendor/gems/recaptcha-0.3.1/recaptcha.gemspec b/vendor/gems/recaptcha-0.3.1/recaptcha.gemspec
new file mode 100644
index 000000000..6456b8a0c
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/recaptcha.gemspec
@@ -0,0 +1,62 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{recaptcha}
+ s.version = "0.3.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Jason L. Perry"]
+ s.date = %q{2010-12-20}
+ s.description = %q{This plugin adds helpers for the reCAPTCHA API }
+ s.email = %q{jasper@ambethia.com}
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README.rdoc"
+ ]
+ s.files = [
+ "CHANGELOG",
+ "LICENSE",
+ "README.rdoc",
+ "Rakefile",
+ "VERSION",
+ "init.rb",
+ "lib/recaptcha.rb",
+ "lib/recaptcha/client_helper.rb",
+ "lib/recaptcha/configuration.rb",
+ "lib/recaptcha/merb.rb",
+ "lib/recaptcha/rails.rb",
+ "lib/recaptcha/verify.rb",
+ "recaptcha.gemspec",
+ "tasks/recaptcha_tasks.rake",
+ "test/recaptcha_test.rb",
+ "test/verify_recaptcha_test.rb"
+ ]
+ s.homepage = %q{http://ambethia.com/recaptcha}
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.7}
+ s.summary = %q{Helpers for the reCAPTCHA API}
+ s.test_files = [
+ "test/recaptcha_test.rb",
+ "test/verify_recaptcha_test.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ s.add_development_dependency(%q<mocha>, [">= 0"])
+ s.add_development_dependency(%q<activesupport>, [">= 0"])
+ else
+ s.add_dependency(%q<mocha>, [">= 0"])
+ s.add_dependency(%q<activesupport>, [">= 0"])
+ end
+ else
+ s.add_dependency(%q<mocha>, [">= 0"])
+ s.add_dependency(%q<activesupport>, [">= 0"])
+ end
+end
+
diff --git a/vendor/plugins/recaptcha/tasks/recaptcha_tasks.rake b/vendor/gems/recaptcha-0.3.1/tasks/recaptcha_tasks.rake
index a0cf1ad13..a0cf1ad13 100644
--- a/vendor/plugins/recaptcha/tasks/recaptcha_tasks.rake
+++ b/vendor/gems/recaptcha-0.3.1/tasks/recaptcha_tasks.rake
diff --git a/vendor/gems/recaptcha-0.3.1/test/recaptcha_test.rb b/vendor/gems/recaptcha-0.3.1/test/recaptcha_test.rb
new file mode 100644
index 000000000..82845a9cc
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/test/recaptcha_test.rb
@@ -0,0 +1,39 @@
+require 'test/unit'
+require 'cgi'
+require File.dirname(File.expand_path(__FILE__)) + '/../lib/recaptcha'
+
+class RecaptchaClientHelperTest < Test::Unit::TestCase
+ include Recaptcha
+ include Recaptcha::ClientHelper
+ include Recaptcha::Verify
+
+ attr_accessor :session
+
+ def setup
+ @session = {}
+ Recaptcha.configure do |config|
+ config.public_key = '0000000000000000000000000000000000000000'
+ config.private_key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
+ end
+ end
+
+ def test_recaptcha_tags
+ # Might as well match something...
+ assert_match /http:\/\/www.google.com\/recaptcha\/api\/challenge/, recaptcha_tags
+ end
+
+ def test_recaptcha_tags_with_ssl
+ assert_match /https:\/\/www.google.com\/recaptcha\/api\/challenge/, recaptcha_tags(:ssl => true)
+ end
+
+ def test_recaptcha_tags_without_noscript
+ assert_no_match /noscript/, recaptcha_tags(:noscript => false)
+ end
+
+ def test_should_raise_exception_without_public_key
+ assert_raise RecaptchaError do
+ Recaptcha.configuration.public_key = nil
+ recaptcha_tags
+ end
+ end
+end
diff --git a/vendor/gems/recaptcha-0.3.1/test/verify_recaptcha_test.rb b/vendor/gems/recaptcha-0.3.1/test/verify_recaptcha_test.rb
new file mode 100644
index 000000000..0e9afc8bb
--- /dev/null
+++ b/vendor/gems/recaptcha-0.3.1/test/verify_recaptcha_test.rb
@@ -0,0 +1,95 @@
+require 'test/unit'
+require 'active_support/core_ext/string'
+require 'rubygems'
+require 'mocha'
+require 'net/http'
+require File.dirname(File.expand_path(__FILE__)) + '/../lib/recaptcha'
+
+class RecaptchaVerifyTest < Test::Unit::TestCase
+ def setup
+ Recaptcha.configuration.private_key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
+ @controller = TestController.new
+ @controller.request = stub(:remote_ip => "1.1.1.1")
+ @controller.params = {:recaptcha_challenge_field => "challenge", :recaptcha_response_field => "response"}
+
+ @expected_post_data = {}
+ @expected_post_data["privatekey"] = Recaptcha.configuration.private_key
+ @expected_post_data["remoteip"] = @controller.request.remote_ip
+ @expected_post_data["challenge"] = "challenge"
+ @expected_post_data["response"] = "response"
+
+ @expected_uri = URI.parse(Recaptcha.configuration.verify_url)
+ end
+
+ def test_should_raise_exception_without_private_key
+ assert_raise Recaptcha::RecaptchaError do
+ Recaptcha.configuration.private_key = nil
+ @controller.verify_recaptcha
+ end
+ end
+
+ def test_should_return_false_when_key_is_invalid
+ expect_http_post(response_with_body("false\ninvalid-site-private-key"))
+
+ assert !@controller.verify_recaptcha
+ assert_equal "invalid-site-private-key", @controller.flash[:recaptcha_error]
+ end
+
+ def test_returns_true_on_success
+ @controller.flash[:recaptcha_error] = "previous error that should be cleared"
+ expect_http_post(response_with_body("true\n"))
+
+ assert @controller.verify_recaptcha
+ assert_nil @controller.flash[:recaptcha_error]
+ end
+
+ def test_errors_should_be_added_to_model
+ expect_http_post(response_with_body("false\nbad-news"))
+
+ errors = mock
+ errors.expects(:add).with(:base, "Word verification response is incorrect, please try again.")
+ model = mock(:valid? => false, :errors => errors)
+
+ assert !@controller.verify_recaptcha(:model => model)
+ assert_equal "bad-news", @controller.flash[:recaptcha_error]
+ end
+
+ def test_returns_true_on_success_with_optional_key
+ @controller.flash[:recaptcha_error] = "previous error that should be cleared"
+ # reset private key
+ @expected_post_data["privatekey"] = 'ADIFFERENTPRIVATEKEYXXXXXXXXXXXXXX'
+ expect_http_post(response_with_body("true\n"))
+
+ assert @controller.verify_recaptcha(:private_key => 'ADIFFERENTPRIVATEKEYXXXXXXXXXXXXXX')
+ assert_nil @controller.flash[:recaptcha_error]
+ end
+
+ def test_timeout
+ expect_http_post(Timeout::Error, :exception => true)
+ assert !@controller.verify_recaptcha()
+ assert_equal "recaptcha-not-reachable", @controller.flash[:recaptcha_error]
+ end
+
+ private
+
+ class TestController
+ include Recaptcha::Verify
+ attr_accessor :request, :params, :flash
+
+ def initialize
+ @flash = {}
+ end
+ end
+
+ def expect_http_post(response, options = {})
+ unless options[:exception]
+ Net::HTTP.expects(:post_form).with(@expected_uri, @expected_post_data).returns(response)
+ else
+ Net::HTTP.expects(:post_form).raises response
+ end
+ end
+
+ def response_with_body(body)
+ stub(:body => body)
+ end
+end
diff --git a/vendor/plugins/recaptcha/README b/vendor/plugins/recaptcha/README
deleted file mode 100644
index 8453064c6..000000000
--- a/vendor/plugins/recaptcha/README
+++ /dev/null
@@ -1,5 +0,0 @@
-NOTICE
-
-This plugin has moved to http://github.com/ambethia/recaptcha
-
-This subversion repository will no longer be updated, and eventually cease to exist.
diff --git a/vendor/plugins/recaptcha/Rakefile b/vendor/plugins/recaptcha/Rakefile
deleted file mode 100644
index 50d21099d..000000000
--- a/vendor/plugins/recaptcha/Rakefile
+++ /dev/null
@@ -1,23 +0,0 @@
-require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the recaptcha plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
-desc 'Generate documentation for the recaptcha plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'reCAPTCHA'
- rdoc.template = 'jamis'
- rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
diff --git a/vendor/plugins/recaptcha/init.rb b/vendor/plugins/recaptcha/init.rb
deleted file mode 100644
index 28494d250..000000000
--- a/vendor/plugins/recaptcha/init.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-require 'recaptcha.rb'
-ActionView::Base.send :include, Ambethia::ReCaptcha::Helper
-ActionController::Base.send :include, Ambethia::ReCaptcha::Controller \ No newline at end of file
diff --git a/vendor/plugins/recaptcha/install.rb b/vendor/plugins/recaptcha/install.rb
deleted file mode 100644
index a63be40f4..000000000
--- a/vendor/plugins/recaptcha/install.rb
+++ /dev/null
@@ -1 +0,0 @@
-puts IO.read(File.join(File.dirname(__FILE__), 'README')) \ No newline at end of file
diff --git a/vendor/plugins/recaptcha/lib/recaptcha.rb b/vendor/plugins/recaptcha/lib/recaptcha.rb
deleted file mode 100644
index 786555316..000000000
--- a/vendor/plugins/recaptcha/lib/recaptcha.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-# ReCAPTCHA
-module Ambethia
- module ReCaptcha
- RECAPTCHA_API_SERVER = 'http://api.recaptcha.net';
- RECAPTCHA_API_SECURE_SERVER = 'https://api-secure.recaptcha.net';
- RECAPTCHA_VERIFY_SERVER = 'api-verify.recaptcha.net';
-
- SKIP_VERIFY_ENV = ['test']
-
- module Helper
- # Your public API can be specified in the +options+ hash or preferably the environment
- # variable +RECAPTCHA_PUBLIC_KEY+.
- def recaptcha_tags(options = {})
- # Default options
- key = options[:public_key] ||= ENV['RECAPTCHA_PUBLIC_KEY']
- error = options[:error] ||= session[:recaptcha_error]
- uri = options[:ssl] ? RECAPTCHA_API_SECURE_SERVER : RECAPTCHA_API_SERVER
- xhtml = Builder::XmlMarkup.new :target => out=(''), :indent => 2 # Because I can.
- if options[:display]
- xhtml.script(:type => "text/javascript"){ xhtml.text! "var RecaptchaOptions = #{options[:display].to_json};\n"}
- end
- xhtml.script(:type => "text/javascript", :src => "#{uri}/challenge?k=#{key}&error=#{error}") {}
- unless options[:noscript] == false
- xhtml.noscript do
- xhtml.iframe(:src => "#{uri}/noscript?k=#{key}",
- :height => options[:iframe_height] ||= 300,
- :width => options[:iframe_width] ||= 500,
- :frameborder => 0) {}; xhtml.br
- xhtml.textarea(:name => "recaptcha_challenge_field", :rows => 3, :cols => 40) {}
- xhtml.input :name => "recaptcha_response_field",
- :type => "hidden", :value => "manual_challenge"
- end
- end
- raise ReCaptchaError, "No public key specified." unless key
- return out
- end # recaptcha_tags
- end # Helpers
-
- module Controller
- # Your private API key must be specified in the environment variable +RECAPTCHA_PRIVATE_KEY+
- def verify_recaptcha(model = nil)
- return true if SKIP_VERIFY_ENV.include? ENV['RAILS_ENV']
- raise ReCaptchaError, "No private key specified." unless ENV['RECAPTCHA_PRIVATE_KEY']
- begin
- recaptcha = Net::HTTP.post_form URI.parse("http://#{RECAPTCHA_VERIFY_SERVER}/verify"), {
- :privatekey => ENV['RECAPTCHA_PRIVATE_KEY'],
- :remoteip => request.remote_ip,
- :challenge => params[:recaptcha_challenge_field],
- :response => params[:recaptcha_response_field]
- }
- answer, error = recaptcha.body.split.map(&:chomp)
- unless answer == 'true'
- session[:recaptcha_error] = error
- model.errors.add_to_base "Captcha response is incorrect, please try again." if model
- return false
- else
- session[:recaptcha_error] = nil
- return true
- end
- rescue Exception => e
- raise ReCaptchaError, e
- end
- end # verify_recaptcha
- end # ControllerHelpers
-
- class ReCaptchaError < StandardError; end
-
- end # ReCaptcha
-end # Ambethia \ No newline at end of file
diff --git a/vendor/plugins/recaptcha/test/recaptcha_test.rb b/vendor/plugins/recaptcha/test/recaptcha_test.rb
deleted file mode 100644
index 0373d25b1..000000000
--- a/vendor/plugins/recaptcha/test/recaptcha_test.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-require 'test/unit'
-require 'builder'
-require File.dirname(__FILE__) + '/../lib/recaptcha'
-
-class ReCaptchaTest < Test::Unit::TestCase
- include Ambethia::ReCaptcha
- include Ambethia::ReCaptcha::Helper
- include Ambethia::ReCaptcha::Controller
-
- attr_accessor :session
-
- def setup
- @session = {}
- ENV['RECAPTCHA_PUBLIC_KEY'] = '0000000000000000000000000000000000000000'
- ENV['RECAPTCHA_PRIVATE_KEY'] = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
- end
-
- def test_recaptcha_tags
- # Might as well match something...
- assert_match /http:\/\/api.recaptcha.net/, recaptcha_tags
- end
-
- def test_recaptcha_tags_with_ssl
- assert_match /https:\/\/api-secure.recaptcha.net/, recaptcha_tags(:ssl => true)
- end
-
- def test_recaptcha_tags_without_noscript
- assert_no_match /noscript/, recaptcha_tags(:noscript => false)
- end
-
- def test_should_raise_exception_without_public_key
- assert_raise ReCaptchaError do
- ENV['RECAPTCHA_PUBLIC_KEY'] = nil
- recaptcha_tags
- end
- end
-
- def test_should_raise_exception_without_private_key
- assert_raise ReCaptchaError do
- ENV['RECAPTCHA_PRIVATE_KEY'] = nil
- verify_recaptcha
- end
- end
-
- def test_should_verify_recaptcha
- # TODO Mock this, or figure something out...
- end
-
-end
diff --git a/vendor/plugins/recaptcha/uninstall.rb b/vendor/plugins/recaptcha/uninstall.rb
deleted file mode 100644
index 973833346..000000000
--- a/vendor/plugins/recaptcha/uninstall.rb
+++ /dev/null
@@ -1 +0,0 @@
-# Uninstall hook code here