catptcha 0.0.4 → 0.1.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.
data/README.markdown CHANGED
@@ -5,7 +5,8 @@ asked to click the kittens. Distributed in the form of a Rails 2.3 plugin.
5
5
 
6
6
  This is based on a concept from [KittenAuth](http://thepcspy.com/kittenauth/).
7
7
 
8
- This is still experimental and incomplete. Don't use it.
8
+ This is still experimental and incomplete, but it's ready for others to try
9
+ out and offer help/feedback.
9
10
 
10
11
  ## Installation
11
12
 
@@ -46,6 +47,12 @@ Check the result in your controller.
46
47
  # failed
47
48
  end
48
49
 
50
+ ## TODO and Known Bugs
51
+
52
+ * lacks a review step for seeded photos
53
+ * lacks the ability to store or upload photos to external storage
54
+ * current implementation is closely tied to ActiveRecord and Flickr
55
+
49
56
  ## Author
50
57
 
51
58
  Copyright (c) 2012 ENTP, released under the MIT license
@@ -18,6 +18,7 @@ class Catptcha::PhotoGroup < ActiveRecord::Base
18
18
  def self.random count
19
19
  Catptcha::Photo.all(
20
20
  :conditions => ['photo_group_id in (?)', all.map(&:id)],
21
+ :order => 'catptcha_photos.key ASC',
21
22
  :offset => rand(photos_count-count).to_i,
22
23
  :limit => count
23
24
  )
data/lib/catptcha.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Catptcha
2
- VERSION = '0.0.4'
2
+ VERSION = '0.1.0'
3
3
 
4
4
  class << self
5
5
  # Get a list of 3 kitten photos
@@ -16,19 +16,31 @@ module Catptcha
16
16
  (kittens + not_kittens).sort_by {rand}
17
17
  end
18
18
 
19
+ def puzzle_js
20
+ return <<-EOJS
21
+ function catptcha_click(e) {
22
+ if (e.checked) {
23
+ e.parentNode.getElementsByTagName('img')[0].setAttribute("style","border: 2px inset black;");
24
+ } else {
25
+ e.parentNode.getElementsByTagName('img')[0].setAttribute("style", "padding: 2px");
26
+ }
27
+ }
28
+ EOJS
29
+ end
19
30
  def puzzle_tags
20
- tags = '<div class="catptcha" style="width:350px"><p>Click the kittens!</p>'
31
+ tags = '<div class="catptcha" style="width:340px"><p>Click the 3 kittens!</p>'
21
32
  puzzle.each do |photo|
22
33
  tags << <<-EOT
23
34
  <span class="catptcha_guess" style="float:left">
24
- <input type="checkbox" id="catptcha_guess_#{photo.key}" name="catptcha_guess[]" value="#{ photo.key }" />
25
- <label for="catptcha_guess_#{photo.key }">
26
- <img src="#{ photo.url }" />
35
+ <input type="checkbox" id="catptcha_guess_#{photo.key}" name="catptcha_guess[]" value="#{ photo.key }" onclick="catptcha_click(this)" style="opacity:0.0;width:0px;"/>
36
+ <label for="catptcha_guess_#{photo.key }" style="margin:2px">
37
+ <img src="#{ photo.url }" style="padding: 2px" />
27
38
  </label>
28
39
  </span>
29
40
  EOT
30
41
  end
31
42
  tags << '</div>'
43
+ tags << "<script>#{puzzle_js}</script>"
32
44
  tags
33
45
  end
34
46
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catptcha
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 4
10
- version: 0.0.4
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Zack Hobson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-17 00:00:00 -07:00
18
+ date: 2012-05-18 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency