simple_captcha2 0.3.4 → 0.4.0
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.
- checksums.yaml +4 -4
- data/README.md +2 -10
- data/lib/generators/USAGE +5 -2
- data/lib/generators/simple_captcha_generator.rb +2 -1
- data/lib/generators/templates/partial.haml +28 -0
- data/lib/simple_captcha/controller.rb +3 -2
- data/lib/simple_captcha/form_builder.rb +9 -9
- data/lib/simple_captcha/image.rb +3 -1
- data/lib/simple_captcha/simple_captcha_data.rb +1 -1
- data/lib/simple_captcha/version.rb +1 -1
- data/lib/simple_captcha/view.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e59bb7e3f61e3c9f11d561c0bd8d4092bd8d2777
|
4
|
+
data.tar.gz: 8463a940c3d8388a788ce4f0284c84e23b363d71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9b3b883001bef8e12d2a00ce43c9c3e090a7249db8c196679879bd537ceb7e72e6cc227414f586aa10a21a92a1bdb7011c838cdc931e0fd86c81ab327e3a38b
|
7
|
+
data.tar.gz: 3754be1742f26b3210adcd52bdd85fcd1565e003756692a2f2d4cfba6f8d7db305c39d9e4ccfea24cc2e5390a91541a23b1e0e53e8a2ccc7b18468d07e069b12
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#SimpleCaptcha2
|
2
2
|
|
3
3
|
[](https://travis-ci.org/pludoni/simple-captcha)
|
4
|
+
[](https://badge.fury.io/rb/simple_captcha2)
|
4
5
|
|
5
6
|
SimpleCaptcha(2) is the simplest and a robust captcha plugin. Its implementation requires adding up a single line in views and in controllers/models.
|
6
7
|
SimpleCaptcha2 is available to be used with Rails 3 + 4.
|
@@ -44,7 +45,7 @@ and run ``bundle install``.
|
|
44
45
|
After installation, follow these simple steps to setup the plugin. The setup will depend on the version of rails your application is using.
|
45
46
|
|
46
47
|
```bash
|
47
|
-
rails generate simple_captcha
|
48
|
+
rails generate simple_captcha [template_format] # Available options erb, haml. Default: erb
|
48
49
|
rake db:migrate # Mongoid: skip this step and remove the migration
|
49
50
|
```
|
50
51
|
|
@@ -247,15 +248,6 @@ SimpleCaptcha.setup do |sc|
|
|
247
248
|
end
|
248
249
|
```
|
249
250
|
|
250
|
-
You can provide the path where should be stored tmp files.
|
251
|
-
It's usefull when you dont have acces to /tmp (default directory)
|
252
|
-
|
253
|
-
```ruby
|
254
|
-
SimpleCaptcha.setup do |sc|
|
255
|
-
sc.tmp_path = '/tmp' # or somewhere in project eg. Rails.root.join('tmp/simple_captcha').to_s, make shure directory exists
|
256
|
-
end
|
257
|
-
```
|
258
|
-
|
259
251
|
|
260
252
|
### How to change the CSS for SimpleCaptcha DOM elements?
|
261
253
|
|
data/lib/generators/USAGE
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
SimpleCaptcha
|
2
2
|
=============
|
3
3
|
# Generate migration and copy view partial
|
4
|
-
rails generate simple_captcha
|
4
|
+
rails generate simple_captcha [template_format]
|
5
|
+
template_format Sets template format to be generated
|
6
|
+
Available options: erb, haml
|
7
|
+
Default: erb
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rails/generators'
|
2
2
|
|
3
3
|
class SimpleCaptchaGenerator < Rails::Generators::Base
|
4
|
+
argument :template_format, :type => :string, :default => 'erb'
|
4
5
|
include Rails::Generators::Migration
|
5
6
|
|
6
7
|
def self.source_root
|
@@ -12,7 +13,7 @@ class SimpleCaptchaGenerator < Rails::Generators::Base
|
|
12
13
|
end
|
13
14
|
|
14
15
|
def create_partial
|
15
|
-
template "partial
|
16
|
+
template "partial.#{template_format}", File.join('app/views', 'simple_captcha', "_simple_captcha.#{template_format}")
|
16
17
|
end
|
17
18
|
|
18
19
|
def create_captcha_migration
|
@@ -0,0 +1,28 @@
|
|
1
|
+
:css
|
2
|
+
.simple_captcha{border: 1px solid #ccc; padding: 5px !important;}
|
3
|
+
.simple_captcha,
|
4
|
+
.simple_captcha div{display: table;}
|
5
|
+
.simple_captcha .simple_captcha_field,
|
6
|
+
.simple_captcha .simple_captcha_image{
|
7
|
+
border: 1px solid #ccc;
|
8
|
+
margin: 0px 0px 2px 0px !important;
|
9
|
+
padding: 0px !important;
|
10
|
+
}
|
11
|
+
.simple_captcha .simple_captcha_image img{
|
12
|
+
margin: 0px !important;
|
13
|
+
padding: 0px !important;
|
14
|
+
width: 110px !important;
|
15
|
+
}
|
16
|
+
.simple_captcha .simple_captcha_label{font-size: 12px;}
|
17
|
+
.simple_captcha .simple_captcha_field input{
|
18
|
+
width: 150px !important;
|
19
|
+
font-size: 16px;
|
20
|
+
border: none;
|
21
|
+
background-color: #efefef;
|
22
|
+
}
|
23
|
+
|
24
|
+
.simple_captcha
|
25
|
+
.simple_captcha_image= simple_captcha_options[:image]
|
26
|
+
.simple_captcha_field= simple_captcha_options[:field]
|
27
|
+
.simple_captcha_label= simple_captcha_options[:label]
|
28
|
+
.simple_captcha_refresh_button= simple_captcha_options[:refresh_button]
|
@@ -18,9 +18,10 @@ module SimpleCaptcha #:nodoc
|
|
18
18
|
return @_simple_captcha_result unless @_simple_captcha_result.nil?
|
19
19
|
|
20
20
|
if params[:captcha]
|
21
|
-
|
21
|
+
captcha_key = params[:captcha_key] || session[:captcha]
|
22
|
+
data = SimpleCaptcha::Utils::simple_captcha_value(captcha_key)
|
22
23
|
result = data == params[:captcha].delete(" ").upcase
|
23
|
-
SimpleCaptcha::Utils::simple_captcha_passed!(
|
24
|
+
SimpleCaptcha::Utils::simple_captcha_passed!(captcha_key) if result
|
24
25
|
@_simple_captcha_result = result
|
25
26
|
result
|
26
27
|
else
|
@@ -14,14 +14,14 @@ module SimpleCaptcha
|
|
14
14
|
|
15
15
|
module ClassMethods
|
16
16
|
# Example:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
# <% form_for :post, :url => posts_path do |form| %>
|
18
|
+
# ...
|
19
|
+
# <%= form.simple_captcha :label => "Enter numbers.." %>
|
20
|
+
# <% end %>
|
21
|
+
#
|
22
|
+
def simple_captcha(options = {})
|
23
|
+
options.update :object => @object_name
|
24
|
+
show_simple_captcha(objectify_options(options))
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
@@ -31,7 +31,7 @@ module SimpleCaptcha
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def simple_captcha_field(options={})
|
34
|
-
html = {:autocomplete => 'off', :required => 'required', :value => ''}
|
34
|
+
html = {:autocomplete => 'off', :autocorrect => 'off', :autocapitalize => 'off', :required => 'required', :value => ''}
|
35
35
|
html.merge!(options[:input_html] || {})
|
36
36
|
html[:placeholder] = options[:placeholder] || I18n.t('simple_captcha.placeholder')
|
37
37
|
|
data/lib/simple_captcha/image.rb
CHANGED
@@ -75,7 +75,9 @@ module SimpleCaptcha #:nodoc
|
|
75
75
|
params << "-pointsize 22"
|
76
76
|
params << "-implode #{ImageHelpers.implode}"
|
77
77
|
params << "label:#{text}"
|
78
|
-
|
78
|
+
if SimpleCaptcha.noise and SimpleCaptcha.noise > 0
|
79
|
+
params << "-evaluate Uniform-noise #{SimpleCaptcha.noise}"
|
80
|
+
end
|
79
81
|
params << "jpeg:-"
|
80
82
|
|
81
83
|
SimpleCaptcha::Utils::run("convert", params.join(' '))
|
data/lib/simple_captcha/view.rb
CHANGED
@@ -90,7 +90,7 @@ module SimpleCaptcha #:nodoc
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def simple_captcha_field(options={})
|
93
|
-
html = {:autocomplete => 'off', :required => 'required'}
|
93
|
+
html = {:autocomplete => 'off', :autocorrect => 'off', :autocapitalize => 'off', :required => 'required'}
|
94
94
|
html.merge!(options[:input_html] || {})
|
95
95
|
html[:placeholder] = options[:placeholder] || I18n.t('simple_captcha.placeholder')
|
96
96
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_captcha2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavlo Galeta
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-12-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- lib/generators/simple_captcha_generator.rb
|
97
97
|
- lib/generators/templates/migration.rb
|
98
98
|
- lib/generators/templates/partial.erb
|
99
|
+
- lib/generators/templates/partial.haml
|
99
100
|
- lib/simple_captcha.rb
|
100
101
|
- lib/simple_captcha/controller.rb
|
101
102
|
- lib/simple_captcha/engine.rb
|
@@ -129,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
130
|
version: '0'
|
130
131
|
requirements: []
|
131
132
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.
|
133
|
+
rubygems_version: 2.4.8
|
133
134
|
signing_key:
|
134
135
|
specification_version: 4
|
135
136
|
summary: SimpleCaptcha is the simplest and a robust captcha plugin.
|