simple_captcha2 0.2.0 → 0.2.1
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 +315 -0
- data/lib/simple_captcha/version.rb +1 -1
- metadata +5 -5
- data/README.rdoc +0 -244
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2435cbdac94d6efcb47ab21a0e11d5c0b5f32285
|
4
|
+
data.tar.gz: ace36262aa2c292c5e983409ecb31bf7f38c3352
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 376322ff32371ce0d9de2f453fd6733be995ef5fa0dec0636f8da75c10454196f3bda52860b7ec51b2f087a43e1e2253f7b23379177e4c5d94f9542db93f55fb
|
7
|
+
data.tar.gz: d02794f529977b6a37ba8704df8e03f36ed764574469dfff90804f0da1a7d5577b68f42d23a69d7f61745a40cc1b24bdae66d5003573ba04946867f4f5ed674a
|
data/README.md
ADDED
@@ -0,0 +1,315 @@
|
|
1
|
+
#SimpleCaptcha2
|
2
|
+
|
3
|
+
[](https://travis-ci.org/pludoni/simple-captcha)
|
4
|
+
|
5
|
+
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
|
+
SimpleCaptcha2 is available to be used with Rails 3 + 4.
|
7
|
+
This is a fork of the popular Rubygem ``simple_captcha`` which got abandoned.
|
8
|
+
|
9
|
+
##Features
|
10
|
+
|
11
|
+
* Zero FileSystem usage (secret code moved to db-store and image storage removed).
|
12
|
+
* Provides various image styles.
|
13
|
+
* Provides three level of complexity of images.
|
14
|
+
* Works absolutely fine in distributed environment(session and db based implementation works fine in distributed environment).
|
15
|
+
* Implementation is as easy as just writing a single line in your view. ```<%= show_simple_captcha %>``` within the 'form' tags.
|
16
|
+
* Flexible DOM and CSS handling(There is a separate view partial for rendering SimpleCaptcha DOM elements).
|
17
|
+
* Automated removal of 1 hour old unmatched simple_captcha data.
|
18
|
+
|
19
|
+
##Requirements
|
20
|
+
|
21
|
+
* Ruby >= 1.9.3
|
22
|
+
* Rails >= 3.2
|
23
|
+
* ImageMagick should be installed on your machine to use this plugin.
|
24
|
+
visit http://www.imagemagick.org/script/index.php for more details.
|
25
|
+
|
26
|
+
You might need to install Ghostscript on a Mac-System:
|
27
|
+
|
28
|
+
```
|
29
|
+
brew install ghostscript
|
30
|
+
```
|
31
|
+
|
32
|
+
##Installation
|
33
|
+
|
34
|
+
Put this into your Gemfile
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
gem 'simple_captcha2', require: 'simple_captcha'
|
38
|
+
```
|
39
|
+
|
40
|
+
and run ``bundle install``.
|
41
|
+
|
42
|
+
## Setup
|
43
|
+
|
44
|
+
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
|
+
```bash
|
47
|
+
rails generate simple_captcha
|
48
|
+
rake db:migrate
|
49
|
+
```
|
50
|
+
|
51
|
+
## Usage
|
52
|
+
|
53
|
+
There are two usage scenarios:
|
54
|
+
|
55
|
+
### Controller Based
|
56
|
+
|
57
|
+
Add the following line in the file "app/controllers/application.rb"
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
ApplicationController < ActionController::Base
|
61
|
+
include SimpleCaptcha::ControllerHelpers
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
In the view file within the form tags add this code
|
66
|
+
|
67
|
+
```erb
|
68
|
+
<%= show_simple_captcha %>
|
69
|
+
```
|
70
|
+
|
71
|
+
and in the controller's action authenticate it as
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
if simple_captcha_valid?
|
75
|
+
do this
|
76
|
+
else
|
77
|
+
do that
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
### Model Based
|
82
|
+
|
83
|
+
This is suggested, if you want to integrate the error message into the normal form validation flow.
|
84
|
+
|
85
|
+
In the view file within the form tags write this code
|
86
|
+
|
87
|
+
```erb
|
88
|
+
<%= show_simple_captcha(:object=>"user") %>
|
89
|
+
```
|
90
|
+
|
91
|
+
and in the model class add this code
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
class User < ActiveRecord::Base
|
95
|
+
apply_simple_captcha
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
99
|
+
####Form-Builder helper
|
100
|
+
|
101
|
+
```erb
|
102
|
+
<%= form_for @user do |form| -%>
|
103
|
+
...
|
104
|
+
<%= form.simple_captcha :label => "Enter numbers.." %>
|
105
|
+
...
|
106
|
+
<% end -%>
|
107
|
+
```
|
108
|
+
|
109
|
+
####Validating with captcha
|
110
|
+
|
111
|
+
NOTE: @user.valid? will still work as it should, it will not validate the captcha code.
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
@user.valid_with_captcha?
|
115
|
+
```
|
116
|
+
|
117
|
+
####Saving with captcha
|
118
|
+
|
119
|
+
NOTE: @user.save will still work as it should, it will not validate the captcha code.
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
@user.save_with_captcha
|
123
|
+
```
|
124
|
+
|
125
|
+
###Formtastic integration
|
126
|
+
|
127
|
+
SimpleCaptcha detects if you are using Formtastic:
|
128
|
+
|
129
|
+
```erb
|
130
|
+
<%= form.input :captcha, :as => :simple_captcha %>
|
131
|
+
```
|
132
|
+
|
133
|
+
### Tests
|
134
|
+
|
135
|
+
You can make the Captcha always pass with a initializer file: config/initializers/simple_captcha.rb
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
SimpleCaptcha.always_pass = Rails.env.test?
|
139
|
+
```
|
140
|
+
|
141
|
+
You can also ask for the value, e.g. Acceptance Tests/Features:
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
visit '/pages/form_tag'
|
145
|
+
assert_equal 1, SimpleCaptcha::SimpleCaptchaData.count
|
146
|
+
fill_in 'captcha', with: SimpleCaptcha::SimpleCaptchaData.first.value
|
147
|
+
```
|
148
|
+
|
149
|
+
##Options & Examples
|
150
|
+
|
151
|
+
###View Options
|
152
|
+
|
153
|
+
* ``:label`` - provides the custom text b/w the image and the text field, the default is "type the code from the image"
|
154
|
+
* ``:object`` - the name of the object of the model class, to implement the model based captcha.
|
155
|
+
* ``:code_type`` - return numeric only if set to 'numeric'
|
156
|
+
|
157
|
+
###Global options
|
158
|
+
|
159
|
+
* ``:image_style`` - provides the specific image style for the captcha image.
|
160
|
+
There are eight different styles available with the plugin as...
|
161
|
+
|
162
|
+
1. simply_blue
|
163
|
+
2. simply_red
|
164
|
+
3. simply_green
|
165
|
+
4. charcoal_grey
|
166
|
+
5. embosed_silver
|
167
|
+
6. all_black
|
168
|
+
7. distorted_black
|
169
|
+
8. almost_invisible
|
170
|
+
|
171
|
+
Default style is 'simply_blue'.
|
172
|
+
You can also specify 'random' to select the random image style.
|
173
|
+
|
174
|
+
* ``:distortion`` - handles the complexity of the image. The :distortion can be set to 'low', 'medium' or 'high'. Default is 'low'.
|
175
|
+
|
176
|
+
Create "./config/initializers/simple_captcha.rb"
|
177
|
+
|
178
|
+
```ruby
|
179
|
+
SimpleCaptcha.setup do |sc|
|
180
|
+
# default: 100x28
|
181
|
+
sc.image_size = '120x40'
|
182
|
+
|
183
|
+
# default: 5
|
184
|
+
sc.length = 6
|
185
|
+
|
186
|
+
# default: simply_blue
|
187
|
+
# possible values:
|
188
|
+
# 'embosed_silver',
|
189
|
+
# 'simply_red',
|
190
|
+
# 'simply_green',
|
191
|
+
# 'simply_blue',
|
192
|
+
# 'distorted_black',
|
193
|
+
# 'all_black',
|
194
|
+
# 'charcoal_grey',
|
195
|
+
# 'almost_invisible'
|
196
|
+
# 'random'
|
197
|
+
sc.image_style = 'simply_green'
|
198
|
+
|
199
|
+
# default: low
|
200
|
+
# possible values: 'low', 'medium', 'high', 'random'
|
201
|
+
sc.distortion = 'medium'
|
202
|
+
end
|
203
|
+
```
|
204
|
+
|
205
|
+
You can add your own style:
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
SimpleCaptcha.setup do |sc|
|
209
|
+
sc.image_style = 'mycaptha'
|
210
|
+
sc.add_image_style('mycaptha', [
|
211
|
+
"-background '#F4F7F8'",
|
212
|
+
"-fill '#86818B'",
|
213
|
+
"-border 1",
|
214
|
+
"-bordercolor '#E0E2E3'"])
|
215
|
+
end
|
216
|
+
```
|
217
|
+
|
218
|
+
You can provide the path where image_magick is installed as well:
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
SimpleCaptcha.setup do |sc|
|
222
|
+
sc.image_magick_path = '/usr/bin' # you can check this from console by running: which convert
|
223
|
+
end
|
224
|
+
```
|
225
|
+
|
226
|
+
You can provide the path where should be stored tmp files.
|
227
|
+
It's usefull when you dont have acces to /tmp (default directory)
|
228
|
+
|
229
|
+
```ruby
|
230
|
+
SimpleCaptcha.setup do |sc|
|
231
|
+
sc.tmp_path = '/tmp' # or somewhere in project eg. Rails.root.join('tmp/simple_captcha').to_s, make shure directory exists
|
232
|
+
end
|
233
|
+
```
|
234
|
+
|
235
|
+
|
236
|
+
### How to change the CSS for SimpleCaptcha DOM elements?
|
237
|
+
|
238
|
+
You can change the CSS of the SimpleCaptcha DOM elements as per your need in this file.
|
239
|
+
|
240
|
+
``app/views/simple_captcha/_simple_captcha.erb``
|
241
|
+
|
242
|
+
###View's Examples
|
243
|
+
####Controller Based Example
|
244
|
+
|
245
|
+
```erb
|
246
|
+
<%= show_simple_captcha %>
|
247
|
+
|
248
|
+
<%= show_simple_captcha(:label => "human authentication") %>
|
249
|
+
```
|
250
|
+
|
251
|
+
####Model Based Example
|
252
|
+
|
253
|
+
```erb
|
254
|
+
<%= show_simple_captcha(:object => 'user', :label => "human authentication") %>
|
255
|
+
```
|
256
|
+
|
257
|
+
####Model Options
|
258
|
+
|
259
|
+
* ``:message`` - provides the custom message on failure of captcha authentication the default is "Secret Code did not match with the Image"
|
260
|
+
|
261
|
+
* ``:add_to_base`` - if set to true, appends the error message to the base.
|
262
|
+
|
263
|
+
#####Model's Example
|
264
|
+
|
265
|
+
```ruby
|
266
|
+
class User < ActiveRecord::Base
|
267
|
+
apply_simple_captcha
|
268
|
+
end
|
269
|
+
|
270
|
+
class User < ActiveRecord::Base
|
271
|
+
apply_simple_captcha :message => "The secret Image and code were different", :add_to_base => true
|
272
|
+
end
|
273
|
+
```
|
274
|
+
|
275
|
+
|
276
|
+
##I18n
|
277
|
+
|
278
|
+
```yaml
|
279
|
+
en:
|
280
|
+
simple_captcha:
|
281
|
+
placeholder: "Enter the image value"
|
282
|
+
label: "Enter the code in the box:"
|
283
|
+
message:
|
284
|
+
default: "Secret Code did not match with the Image"
|
285
|
+
user: "The secret Image and code were different"
|
286
|
+
```
|
287
|
+
|
288
|
+
##Contributing
|
289
|
+
|
290
|
+
For testing, generate a temporary Rails dummy app inside test:
|
291
|
+
|
292
|
+
```bash
|
293
|
+
rake dummy:setup
|
294
|
+
rake app:db:migrate
|
295
|
+
rake app:db:migrate RAILS_ENV=test
|
296
|
+
export BUNDLE_GEMFILE=$PWD/Gemfile
|
297
|
+
cd test/dummy && rake db:migrate db:test:prepare
|
298
|
+
rake test
|
299
|
+
```
|
300
|
+
|
301
|
+
Please add test cases when adding new functionality. I started with some basic example integration tests for a very basic coverage.
|
302
|
+
|
303
|
+
The tests will be run on [Travis-CI](https://travis-ci.org/pludoni/simple-captcha).
|
304
|
+
|
305
|
+
##Who's who?
|
306
|
+
|
307
|
+
Enjoy the simplest captcha implementation.
|
308
|
+
|
309
|
+
Original Author of the Version for Rails 2:
|
310
|
+
Author: Sur, Blog: http://expressica.com, Contact: sur.max@gmail.com
|
311
|
+
Plugin Homepage: http://expressica.com/simple_captcha
|
312
|
+
|
313
|
+
Plugin update for rails 3: http://github.com/galetahub
|
314
|
+
|
315
|
+
update for Rails 4, tests and forked by Stefan Wienert (pludoni GmbH)
|
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.2.
|
4
|
+
version: 0.2.1
|
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: 2013-12-
|
13
|
+
date: 2013-12-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -74,7 +74,7 @@ email: stwienert@gmail.com
|
|
74
74
|
executables: []
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files:
|
77
|
-
- README.
|
77
|
+
- README.md
|
78
78
|
files:
|
79
79
|
- lib/generators/templates/migration.rb
|
80
80
|
- lib/generators/templates/partial.erb
|
@@ -94,7 +94,7 @@ files:
|
|
94
94
|
- lib/simple_captcha/formtastic.rb
|
95
95
|
- lib/simple_captcha/version.rb
|
96
96
|
- Rakefile
|
97
|
-
- README.
|
97
|
+
- README.md
|
98
98
|
homepage: http://github.com/pludoni/simple-captcha
|
99
99
|
licenses: []
|
100
100
|
metadata: {}
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.1.11
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: SimpleCaptcha is the simplest and a robust captcha plugin.
|
data/README.rdoc
DELETED
@@ -1,244 +0,0 @@
|
|
1
|
-
=SimpleCaptcha2
|
2
|
-
|
3
|
-
SimpleCaptcha(2) is the simplest and a robust captcha plugin. Its implementation requires
|
4
|
-
adding up a single line in views and in controllers/models.
|
5
|
-
SimpleCaptcha2 is available to be used with Rails 3 + 4.
|
6
|
-
This is a fork of the popular Rubygem simple_captcha which got abandoned.
|
7
|
-
|
8
|
-
==Features
|
9
|
-
|
10
|
-
* Zero FileSystem usage (secret code moved to db-store and image storage removed).
|
11
|
-
* Provides various image styles.
|
12
|
-
* Provides three level of complexity of images.
|
13
|
-
* Works absolutely fine in distributed environment(session and db based implementation works fine in distributed environment).
|
14
|
-
* Implementation is as easy as just writing a single line in your view. "<%= show_simple_captcha %>" within the 'form' tags.
|
15
|
-
* Flexible DOM and CSS handling(There is a separate view partial for rendering SimpleCaptcha DOM elements).
|
16
|
-
* Automated removal of 1 hour old unmatched simple_captcha data.
|
17
|
-
|
18
|
-
==Requirements
|
19
|
-
|
20
|
-
* {Ruby}[http://ruby-lang.org/] >= 1.8.7
|
21
|
-
* {Rails}[http://github.com/rails/rails] >= 3
|
22
|
-
* ImageMagick should be installed on your machine to use this plugin.
|
23
|
-
visit http://www.imagemagick.org/script/index.php for more details.
|
24
|
-
|
25
|
-
==Installation
|
26
|
-
|
27
|
-
gem 'simple_captcha2'
|
28
|
-
|
29
|
-
# OR
|
30
|
-
|
31
|
-
gem 'simple_captcha', :git => 'git://github.com/pludoni/simple-captcha.git'
|
32
|
-
|
33
|
-
==Setup
|
34
|
-
|
35
|
-
After installation, follow these simple steps to setup the plugin. The setup will depend
|
36
|
-
on the version of rails your application is using.
|
37
|
-
|
38
|
-
rails generate simple_captcha
|
39
|
-
|
40
|
-
rake db:migrate
|
41
|
-
|
42
|
-
==Usage
|
43
|
-
|
44
|
-
===Controller Based
|
45
|
-
|
46
|
-
Add the following line in the file "app/controllers/application.rb"
|
47
|
-
|
48
|
-
ApplicationController < ActionController::Base
|
49
|
-
include SimpleCaptcha::ControllerHelpers
|
50
|
-
end
|
51
|
-
|
52
|
-
In the view file within the form tags add this code
|
53
|
-
|
54
|
-
<%= show_simple_captcha %>
|
55
|
-
|
56
|
-
and in the controller's action authenticate it as
|
57
|
-
|
58
|
-
if simple_captcha_valid?
|
59
|
-
do this
|
60
|
-
else
|
61
|
-
do that
|
62
|
-
end
|
63
|
-
|
64
|
-
===Model Based
|
65
|
-
|
66
|
-
In the view file within the form tags write this code
|
67
|
-
|
68
|
-
<%= show_simple_captcha(:object=>"user") %>
|
69
|
-
|
70
|
-
and in the model class add this code
|
71
|
-
|
72
|
-
class User < ActiveRecord::Base
|
73
|
-
apply_simple_captcha
|
74
|
-
end
|
75
|
-
|
76
|
-
====FormBuilder helper
|
77
|
-
|
78
|
-
<%= form_for @user do |form| -%>
|
79
|
-
...
|
80
|
-
<%= form.simple_captcha :label => "Enter numbers.." %>
|
81
|
-
...
|
82
|
-
<% end -%>
|
83
|
-
|
84
|
-
====Validating with captcha
|
85
|
-
NOTE: @user.valid? will still work as it should, it will not validate the captcha code.
|
86
|
-
|
87
|
-
@user.valid_with_captcha?
|
88
|
-
|
89
|
-
====Saving with captcha
|
90
|
-
NOTE: @user.save will still work as it should, it will not validate the captcha code.
|
91
|
-
|
92
|
-
@user.save_with_captcha
|
93
|
-
|
94
|
-
===Formtastic integration
|
95
|
-
SimpleCaptcha detects if your use Formtastic and appends "SimpleCaptcha::CustomFormBuilder".
|
96
|
-
|
97
|
-
<%= form.input :captcha, :as => :simple_captcha %>
|
98
|
-
|
99
|
-
==Options & Examples
|
100
|
-
===View Options
|
101
|
-
|
102
|
-
* *label* - provides the custom text b/w the image and the text field, the default is "type the code from the image"
|
103
|
-
|
104
|
-
* *object* - the name of the object of the model class, to implement the model based captcha.
|
105
|
-
|
106
|
-
* *code_type* - return numeric only if set to 'numeric'
|
107
|
-
|
108
|
-
===Global options
|
109
|
-
|
110
|
-
* *image_style* - provides the specific image style for the captcha image.
|
111
|
-
There are eight different styles available with the plugin as...
|
112
|
-
1) simply_blue
|
113
|
-
2) simply_red
|
114
|
-
3) simply_green
|
115
|
-
4) charcoal_grey
|
116
|
-
5) embosed_silver
|
117
|
-
6) all_black
|
118
|
-
7) distorted_black
|
119
|
-
8) almost_invisible
|
120
|
-
Default style is 'simply_blue'.
|
121
|
-
You can also specify 'random' to select the random image style.
|
122
|
-
|
123
|
-
* *distortion* - handles the complexity of the image. The :distortion can be set to 'low', 'medium' or 'high'. Default is 'low'.
|
124
|
-
|
125
|
-
Create "rails_root/config/initializers/simple_captcha.rb"
|
126
|
-
|
127
|
-
SimpleCaptcha.setup do |sc|
|
128
|
-
# default: 100x28
|
129
|
-
sc.image_size = '120x40'
|
130
|
-
|
131
|
-
# default: 5
|
132
|
-
sc.length = 6
|
133
|
-
|
134
|
-
# default: simply_blue
|
135
|
-
# possible values:
|
136
|
-
# 'embosed_silver',
|
137
|
-
# 'simply_red',
|
138
|
-
# 'simply_green',
|
139
|
-
# 'simply_blue',
|
140
|
-
# 'distorted_black',
|
141
|
-
# 'all_black',
|
142
|
-
# 'charcoal_grey',
|
143
|
-
# 'almost_invisible'
|
144
|
-
# 'random'
|
145
|
-
sc.image_style = 'simply_green'
|
146
|
-
|
147
|
-
# default: low
|
148
|
-
# possible values: 'low', 'medium', 'high', 'random'
|
149
|
-
sc.distortion = 'medium'
|
150
|
-
end
|
151
|
-
|
152
|
-
You can add your own style:
|
153
|
-
|
154
|
-
SimpleCaptcha.setup do |sc|
|
155
|
-
sc.image_style = 'mycaptha'
|
156
|
-
sc.add_image_style('mycaptha', [
|
157
|
-
"-background '#F4F7F8'",
|
158
|
-
"-fill '#86818B'",
|
159
|
-
"-border 1",
|
160
|
-
"-bordercolor '#E0E2E3'"])
|
161
|
-
end
|
162
|
-
|
163
|
-
You can provide the path where image_magick is installed as well:
|
164
|
-
|
165
|
-
SimpleCaptcha.setup do |sc|
|
166
|
-
sc.image_magick_path = '/usr/bin' # you can check this from console by running: which convert
|
167
|
-
end
|
168
|
-
|
169
|
-
You can provide the path where should be stored tmp files.
|
170
|
-
It's usefull when you dont have acces to /tmp (default directory)
|
171
|
-
|
172
|
-
SimpleCaptcha.setup do |sc|
|
173
|
-
sc.tmp_path = '/tmp' # or somewhere in project eg. Rails.root.join('tmp/simple_captcha').to_s, make shure directory exists
|
174
|
-
end
|
175
|
-
|
176
|
-
|
177
|
-
===How to change the CSS for SimpleCaptcha DOM elements?
|
178
|
-
You can change the CSS of the SimpleCaptcha DOM elements as per your need in this file.
|
179
|
-
/app/views/simple_captcha/_simple_captcha.erb
|
180
|
-
|
181
|
-
===View's Examples
|
182
|
-
====Controller Based Example
|
183
|
-
|
184
|
-
<%= show_simple_captcha %>
|
185
|
-
|
186
|
-
<%= show_simple_captcha(:label => "human authentication") %>
|
187
|
-
|
188
|
-
====Model Based Example
|
189
|
-
|
190
|
-
<%= show_simple_captcha(:object => 'user', :label => "human authentication") %>
|
191
|
-
|
192
|
-
====Model Options
|
193
|
-
|
194
|
-
* *message* - provides the custom message on failure of captcha authentication the default is "Secret Code did not match with the Image"
|
195
|
-
|
196
|
-
* *add_to_base* - if set to true, appends the error message to the base.
|
197
|
-
|
198
|
-
=====Model's Example
|
199
|
-
|
200
|
-
class User < ActiveRecord::Base
|
201
|
-
apply_simple_captcha
|
202
|
-
end
|
203
|
-
|
204
|
-
class User < ActiveRecord::Base
|
205
|
-
apply_simple_captcha :message => "The secret Image and code were different", :add_to_base => true
|
206
|
-
end
|
207
|
-
|
208
|
-
==I18n
|
209
|
-
|
210
|
-
simple_captcha:
|
211
|
-
placeholder: "Enter the image value"
|
212
|
-
label: "Enter the code in the box:"
|
213
|
-
message:
|
214
|
-
default: "Secret Code did not match with the Image"
|
215
|
-
user: "The secret Image and code were different"
|
216
|
-
|
217
|
-
==Contributing
|
218
|
-
|
219
|
-
For testing, generate a temporary Rails dummy app inside test:
|
220
|
-
|
221
|
-
rake dummy:setup
|
222
|
-
rake app:db:migrate
|
223
|
-
rake app:db:migrate RAILS_ENV=test
|
224
|
-
export BUNDLE_GEMFILE=$PWD/Gemfile
|
225
|
-
cd test/dummy && rake db:migrate db:test:prepare
|
226
|
-
rake test
|
227
|
-
|
228
|
-
Please add test cases when adding new functionality. I started with some basic example integration tests for a very basic coverage.
|
229
|
-
|
230
|
-
==Who's who?
|
231
|
-
|
232
|
-
Enjoy the simplest captcha implementation.
|
233
|
-
|
234
|
-
Author: Sur
|
235
|
-
|
236
|
-
Blog: http://expressica.com
|
237
|
-
|
238
|
-
Contact: sur.max@gmail.com
|
239
|
-
|
240
|
-
Plugin Homepage: http://expressica.com/simple_captcha
|
241
|
-
|
242
|
-
Plugin update for rails 3: http://github.com/galetahub
|
243
|
-
|
244
|
-
Any feedback/comment/issue/donation is welcome!
|