the_comments 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -1
- data/app/models/concerns/the_comments_base.rb +4 -4
- data/app/models/concerns/the_comments_black_ip.rb +1 -2
- data/app/models/concerns/the_comments_black_user_agent.rb +1 -2
- data/lib/generators/the_comments/USAGE +4 -0
- data/lib/generators/the_comments/templates/ip_black_list.rb +3 -0
- data/lib/generators/the_comments/templates/the_comments_black_ip.rb +9 -0
- data/lib/generators/the_comments/templates/the_comments_black_user_agent.rb +9 -0
- data/lib/generators/the_comments/templates/user_agent_black_list.rb +3 -0
- data/lib/generators/the_comments/the_comments_generator.rb +7 -0
- data/lib/the_comments/version.rb +1 -1
- metadata +21 -7
data/README.md
CHANGED
@@ -134,6 +134,9 @@ bundle exec rails g the_comments install
|
|
134
134
|
```ruby
|
135
135
|
config/initializers/the_comments.rb
|
136
136
|
|
137
|
+
app/models/ip_black_list.rb
|
138
|
+
app/models/user_agent_black_list.rb
|
139
|
+
|
137
140
|
app/controllers/comments_controller.rb
|
138
141
|
app/controllers/ip_black_lists_controller.rb
|
139
142
|
app/controllers/user_agent_black_lists_controller.rb
|
@@ -351,7 +354,7 @@ I use denormalization of commentable objects to solve this problem.
|
|
351
354
|
|
352
355
|
My practice shows - We need 3 denormalized fields into comment for (request-free) building of recent comments list:
|
353
356
|
|
354
|
-
<img src="https://raw.github.com/
|
357
|
+
<img src="https://raw.github.com/the-teacher/the_comments/master/docs/the_comments_view_5.gif" alt="the_comments">
|
355
358
|
|
356
359
|
* **Comment#commentable_title** - for example: "My first post about Ruby On Rails"
|
357
360
|
* **Comment#commentable_url** - for example: "/posts/1-my-first-post-about-ruby-on-rails"
|
@@ -2,8 +2,11 @@ module TheCommentsBase
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
included do
|
5
|
+
# attr_accessible :parent_id
|
6
|
+
# attr_accessible :ip, :referer, :user_agent, :tolerance_time
|
7
|
+
# attr_accessible :user, :title, :contacts, :raw_content, :view_token, :state
|
8
|
+
|
5
9
|
# Nested Set
|
6
|
-
attr_accessible :parent_id
|
7
10
|
acts_as_nested_set scope: [:commentable_type, :commentable_id]
|
8
11
|
|
9
12
|
# Comments State Machine
|
@@ -12,9 +15,6 @@ module TheCommentsBase
|
|
12
15
|
# TheSortableTree
|
13
16
|
include TheSortableTree::Scopes
|
14
17
|
|
15
|
-
attr_accessible :user, :title, :contacts, :raw_content, :view_token, :state
|
16
|
-
attr_accessible :ip, :referer, :user_agent, :tolerance_time
|
17
|
-
|
18
18
|
validates :raw_content, presence: true
|
19
19
|
|
20
20
|
# relations
|
@@ -9,6 +9,10 @@ Generators:
|
|
9
9
|
|
10
10
|
This will create:
|
11
11
|
config/initializers/the_comments.rb
|
12
|
+
|
13
|
+
app/models/ip_black_list.rb
|
14
|
+
app/models/user_agent_black_list.rb
|
15
|
+
|
12
16
|
app/controllers/comments_controller.rb
|
13
17
|
app/controllers/ip_black_lists_controller.rb
|
14
18
|
app/controllers/user_agent_black_lists_controller.rb
|
@@ -8,6 +8,8 @@ class TheCommentsGenerator < Rails::Generators::NamedBase
|
|
8
8
|
cp_controllers
|
9
9
|
elsif gen_name == 'controllers'
|
10
10
|
cp_controllers
|
11
|
+
elsif gen_name == 'models'
|
12
|
+
cp_models
|
11
13
|
else
|
12
14
|
puts 'TheComments Generator - wrong Name'
|
13
15
|
puts 'Try to use [install|controllers]'
|
@@ -24,6 +26,11 @@ class TheCommentsGenerator < Rails::Generators::NamedBase
|
|
24
26
|
copy_file 'the_comments.rb', 'config/initializers/the_comments.rb'
|
25
27
|
end
|
26
28
|
|
29
|
+
def cp_models
|
30
|
+
copy_file 'ip_black_list.rb', 'app/models/ip_black_list.rb'
|
31
|
+
copy_file 'user_agent_black_list.rb', 'app/models/user_agent_black_list.rb'
|
32
|
+
end
|
33
|
+
|
27
34
|
def cp_controllers
|
28
35
|
copy_file 'comments_controller.rb', 'app/controllers/comments_controller.rb'
|
29
36
|
copy_file 'ip_black_lists_controller.rb', 'app/controllers/ip_black_lists_controller.rb'
|
data/lib/the_comments/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_comments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: state_machine
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: the_sortable_tree
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,7 +37,12 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
description: ! ' Comments with threading for Rails 4 '
|
37
47
|
email:
|
38
48
|
- zykin-ilya@ya.ru
|
@@ -78,8 +88,12 @@ files:
|
|
78
88
|
- docs/the_comments_view_5.gif
|
79
89
|
- lib/generators/the_comments/USAGE
|
80
90
|
- lib/generators/the_comments/templates/comments_controller.rb
|
91
|
+
- lib/generators/the_comments/templates/ip_black_list.rb
|
81
92
|
- lib/generators/the_comments/templates/ip_black_lists_controller.rb
|
82
93
|
- lib/generators/the_comments/templates/the_comments.rb
|
94
|
+
- lib/generators/the_comments/templates/the_comments_black_ip.rb
|
95
|
+
- lib/generators/the_comments/templates/the_comments_black_user_agent.rb
|
96
|
+
- lib/generators/the_comments/templates/user_agent_black_list.rb
|
83
97
|
- lib/generators/the_comments/templates/user_agent_black_lists_controller.rb
|
84
98
|
- lib/generators/the_comments/the_comments_generator.rb
|
85
99
|
- lib/generators/the_comments/views_generator.rb
|
@@ -107,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
121
|
version: '0'
|
108
122
|
requirements: []
|
109
123
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.8.
|
124
|
+
rubygems_version: 1.8.25
|
111
125
|
signing_key:
|
112
126
|
specification_version: 3
|
113
127
|
summary: the_comments by the-teacher
|