webs 0.1.48 → 0.1.49

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/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  require 'rake'
4
4
  require 'echoe'
5
5
 
6
- Echoe.new('webs', '0.1.48') do |p|
6
+ Echoe.new('webs', '0.1.49') do |p|
7
7
  p.description = "Reusable webs stuff."
8
8
  p.url = "https://colczak@github.com/websdev/websgem.git"
9
9
  p.author = "Chuck Olczak"
@@ -0,0 +1,23 @@
1
+ module Webs
2
+ module Controller
3
+ module AbuseGovernor
4
+ def webs_register_post(key_prefix, max_per_time_window)
5
+ key = "#{key_prefix}-#{request.env["HTTP_FW_IP_ADDRESS"]}"
6
+ list = cache_get(key) || []
7
+ list << Time.now
8
+ list = list[(list.size - max_per_time_window)..max_per_time_window] if list.size > max_per_time_window
9
+ cache_set(key, list)
10
+ end
11
+
12
+ def webs_require_captcha?(key_prefix, max_per_time_window)
13
+ key = "#{key_prefix}-#{request.env["HTTP_FW_IP_ADDRESS"]}"
14
+ list = cache_get(key)
15
+
16
+ return false if list.nil? || list.size < max_per_time_window
17
+
18
+ list[0].to_i > (Time.now-1.hour).to_i
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,18 @@
1
+ require 'iconv'
2
+
3
+ module Webs
4
+ module Helper
5
+ module Encoding
6
+ def to_utf8( s )
7
+ Iconv.conv("utf-8", "ISO-8859-1", s)
8
+ rescue
9
+ s
10
+ end
11
+ def to_iso8859( s )
12
+ Iconv.conv("ISO-8859-1", "utf-8", s )
13
+ rescue
14
+ s
15
+ end
16
+ end
17
+ end
18
+ end
data/lib/webs.rb CHANGED
@@ -7,7 +7,7 @@ require dir + 'helper/params'
7
7
  require dir + 'helper/tags'
8
8
 
9
9
  module Webs
10
- VERSION = '0.1.48'.freeze
10
+ VERSION = '0.1.49'.freeze
11
11
 
12
12
  def self.app_title
13
13
  APP_NAME.titleize
data/webs.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{webs}
5
- s.version = "0.1.48"
5
+ s.version = "0.1.49"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Chuck Olczak"]
9
- s.date = %q{2011-09-28}
9
+ s.date = %q{2011-10-04}
10
10
  s.description = %q{Reusable webs stuff.}
11
11
  s.email = %q{chuck@webs.com}
12
12
  gemfiles = Dir.glob( "**/*.{erb,rb,rdoc}" )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.48
4
+ version: 0.1.49
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-28 00:00:00.000000000 -04:00
12
+ date: 2011-10-04 00:00:00.000000000 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description: Reusable webs stuff.
@@ -17,54 +17,58 @@ email: chuck@webs.com
17
17
  executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files:
20
- - lib/views/layouts/webs_page.html.erb
21
20
  - lib/views/layouts/webs_utility.html.erb
22
- - lib/views/shared/_error_msgs.html.erb
23
- - lib/views/shared/_flash_msg.html.erb
21
+ - lib/views/layouts/webs_page.html.erb
24
22
  - lib/views/shared/_jquery_noconflict.html.erb
25
23
  - lib/views/shared/_webs_info.html.erb
26
- - lib/cache/cache.rb
27
- - lib/config/initializers/http_accept_patch.rb
28
- - lib/config/initializers/intl_select.rb
29
- - lib/config/initializers/webs_view_path.rb
30
- - lib/config/webs_constants.rb
31
- - lib/config/webs_initializer.rb
32
- - lib/controller/alive_controller.rb
24
+ - lib/views/shared/_flash_msg.html.erb
25
+ - lib/views/shared/_error_msgs.html.erb
33
26
  - lib/controller/info_controller.rb
34
- - lib/controller/permission_converter.rb
35
- - lib/controller/url_for_context_path.rb
36
27
  - lib/controller/webs_controller.rb
37
- - lib/helper/application.rb
38
- - lib/helper/params.rb
28
+ - lib/controller/url_for_context_path.rb
29
+ - lib/controller/abuse_governor.rb
30
+ - lib/controller/alive_controller.rb
31
+ - lib/controller/permission_converter.rb
32
+ - lib/helper/encoding.rb
39
33
  - lib/helper/tags.rb
34
+ - lib/helper/params.rb
35
+ - lib/helper/application.rb
40
36
  - lib/middleware/parameter_fixer.rb
41
- - lib/test/webs_test_helper.rb
42
37
  - lib/webs.rb
38
+ - lib/cache/cache.rb
39
+ - lib/test/webs_test_helper.rb
40
+ - lib/config/webs_constants.rb
41
+ - lib/config/initializers/http_accept_patch.rb
42
+ - lib/config/initializers/webs_view_path.rb
43
+ - lib/config/initializers/intl_select.rb
44
+ - lib/config/webs_initializer.rb
43
45
  - README.rdoc
44
46
  files:
45
- - lib/views/layouts/webs_page.html.erb
46
47
  - lib/views/layouts/webs_utility.html.erb
47
- - lib/views/shared/_error_msgs.html.erb
48
- - lib/views/shared/_flash_msg.html.erb
48
+ - lib/views/layouts/webs_page.html.erb
49
49
  - lib/views/shared/_jquery_noconflict.html.erb
50
50
  - lib/views/shared/_webs_info.html.erb
51
- - lib/cache/cache.rb
52
- - lib/config/initializers/http_accept_patch.rb
53
- - lib/config/initializers/intl_select.rb
54
- - lib/config/initializers/webs_view_path.rb
55
- - lib/config/webs_constants.rb
56
- - lib/config/webs_initializer.rb
57
- - lib/controller/alive_controller.rb
51
+ - lib/views/shared/_flash_msg.html.erb
52
+ - lib/views/shared/_error_msgs.html.erb
58
53
  - lib/controller/info_controller.rb
59
- - lib/controller/permission_converter.rb
60
- - lib/controller/url_for_context_path.rb
61
54
  - lib/controller/webs_controller.rb
62
- - lib/helper/application.rb
63
- - lib/helper/params.rb
55
+ - lib/controller/url_for_context_path.rb
56
+ - lib/controller/abuse_governor.rb
57
+ - lib/controller/alive_controller.rb
58
+ - lib/controller/permission_converter.rb
59
+ - lib/helper/encoding.rb
64
60
  - lib/helper/tags.rb
61
+ - lib/helper/params.rb
62
+ - lib/helper/application.rb
65
63
  - lib/middleware/parameter_fixer.rb
66
- - lib/test/webs_test_helper.rb
67
64
  - lib/webs.rb
65
+ - lib/cache/cache.rb
66
+ - lib/test/webs_test_helper.rb
67
+ - lib/config/webs_constants.rb
68
+ - lib/config/initializers/http_accept_patch.rb
69
+ - lib/config/initializers/webs_view_path.rb
70
+ - lib/config/initializers/intl_select.rb
71
+ - lib/config/webs_initializer.rb
68
72
  - README.rdoc
69
73
  - Rakefile
70
74
  - webs.gemspec