the_comments 0.9.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,12 +1,10 @@
1
1
  # TheComments 1.0.0
2
2
 
3
- TheComments - just comment system for my Ruby on Rails 4 projects
4
-
5
- P.S: and for me it's best prototype of comment system for Rails 4
3
+ TheComments - just comment system for my Ruby on Rails 4 projects. [(rubygems)](http://rubygems.org/gems/the_comments)
6
4
 
7
5
  ## Keywords
8
6
 
9
- Comments for Rails 4, Comments with threading, Nested Comments, Polymorphic comments, Acts as commentable, Comment functionality, Comments, Threading, Rails 4, Comments with moderation, I hate captcha for comments!
7
+ Comments for Rails 4, Comments with threading, Nested Comments, Polymorphic comments, Acts as commentable, Comment functionality, Comments, Threading, Rails 4, Comments with moderation, I hate captcha!
10
8
 
11
9
  ## Screenshots
12
10
 
@@ -21,11 +19,11 @@ Comments for Rails 4, Comments with threading, Nested Comments, Polymorphic comm
21
19
  <td width="20%">Recent comments & Denormalization</td>
22
20
  </tr>
23
21
  <tr>
24
- <td width="20%"><img width="100%" height="100%" src="https://raw.github.com/open-cook/the_comments/master/docs/the_comments_view_2.gif" alt="the_comments"></td>
25
- <td width="20%"><img width="100%" height="100%" src="https://raw.github.com/open-cook/the_comments/master/docs/the_comments_view_1.gif" alt="the_comments"></td>
26
- <td width="20%"><img width="100%" height="100%" src="https://raw.github.com/open-cook/the_comments/master/docs/the_comments_view_4.gif" alt="the_comments"></td>
27
- <td width="20%"><img width="100%" height="100%" src="https://raw.github.com/open-cook/the_comments/master/docs/the_comments_view_3.gif" alt="the_comments"></td>
28
- <td width="20%"><img width="100%" height="100%" src="https://raw.github.com/open-cook/the_comments/master/docs/the_comments_view_5.gif" alt="the_comments"></td>
22
+ <td width="20%"><img width="100%" height="100%" src="https://raw.github.com/the-teacher/the_comments/master/docs/the_comments_view_2.gif" alt="the_comments"></td>
23
+ <td width="20%"><img width="100%" height="100%" src="https://raw.github.com/the-teacher/the_comments/master/docs/the_comments_view_1.gif" alt="the_comments"></td>
24
+ <td width="20%"><img width="100%" height="100%" src="https://raw.github.com/the-teacher/the_comments/master/docs/the_comments_view_4.gif" alt="the_comments"></td>
25
+ <td width="20%"><img width="100%" height="100%" src="https://raw.github.com/the-teacher/the_comments/master/docs/the_comments_view_3.gif" alt="the_comments"></td>
26
+ <td width="20%"><img width="100%" height="100%" src="https://raw.github.com/the-teacher/the_comments/master/docs/the_comments_view_5.gif" alt="the_comments"></td>
29
27
  </tr>
30
28
  </table>
31
29
 
@@ -51,6 +49,8 @@ Comments for Rails 4, Comments with threading, Nested Comments, Polymorphic comm
51
49
  * [Commentable methods](#commentable-methods)
52
50
  * [Online Support](#online-support)
53
51
  * [About author](#about-author)
52
+ * [What about specs?](#what-about-specs)
53
+
54
54
 
55
55
  ## Installation
56
56
 
@@ -176,20 +176,22 @@ end
176
176
 
177
177
  ### Any Commentable Model (Page, Blog, Article, User(!) ...)
178
178
 
179
+ Read more about **commentable_title**, **commentable_url** and **commentable_state** methods here: [Denormalization and Recent comments](#denormalization)
180
+
179
181
  ```ruby
180
182
  class Blog < ActiveRecord::Base
181
183
  include TheCommentsCommentable
182
184
 
183
185
  def commentable_title
184
- # by default: try(:title) || 'Undefined title'
186
+ # by default: try(:title) || TheComments.config.default_title
185
187
  # for example: "My first blog post"
186
188
  blog_post_name
187
189
  end
188
190
 
189
191
  def commentable_url
190
192
  # by default: ['', self.class.to_s.tableize, self.to_param].join('/')
191
- # for example: "blogs/1-my-first-blog-post"
192
- [self.class.to_s.tableize, slug_id].join('/')
193
+ # for example: "/blogs/1-my-first-blog-post"
194
+ ['', self.class.to_s.tableize, slug_id].join('/')
193
195
  end
194
196
 
195
197
  def commentable_state
@@ -202,6 +204,7 @@ end
202
204
 
203
205
  ### Comment Model
204
206
 
207
+
205
208
  ```ruby
206
209
  class Comment < ActiveRecord::Base
207
210
  include TheCommentsBase
@@ -264,7 +267,7 @@ end
264
267
  * Spam traps instead Captcha. *I hate Captcha*
265
268
  * Blacklists for IP and UserAgent
266
269
  * Denormalization for fast and Request-free Recent comments building
267
- * Ready for external content filters (<b>sanitize</b>, <b>RedCloth</b>, <b>Markdown</b>)
270
+ * Ready for external content filters (<b>sanitize</b>, <b>RedCloth</b>, <b>Markdown</b>, etc)
268
271
  * Highlighting and Jumping to comment via anchor
269
272
  * Ready for Rails4 (and Rails::Engine)
270
273
  * Ready for JQuery 1.9+
@@ -279,7 +282,7 @@ Just look at [Ruby-Toolbox](https://www.ruby-toolbox.com/categories/rails_commen
279
282
  * [opinio](https://github.com/Draiken/opinio) - looks better, but there is no threading. I want to have more!
280
283
  * [has_threaded_comments](https://github.com/aarongough/has_threaded_comments) - Nice work! Nice gem! Models, controllers, views, view helper for tree rendering! **But**, last activity 2 years ago, I need few features, I think - I can make it better.
281
284
 
282
- ![TheComments](https://raw.github.com/open-cook/the_comments/master/docs/the_comments.jpg)
285
+ ![TheComments](https://raw.github.com/the-teacher/the_comments/master/docs/the_comments.jpg)
283
286
 
284
287
  ## Comments, Posted comments, ComComs
285
288
 
@@ -344,11 +347,11 @@ Set of All <b>COM</b>ments of All <b>COM</b>mentable objects of this User
344
347
 
345
348
  For building of Recent comments list (for polymorphic relationship) we need to have many additional requests to database. It's classic problem of polymorphic comments.
346
349
 
347
- I use denormalization of commentable objects for solve of this problem.
350
+ I use denormalization of commentable objects to solve this problem.
348
351
 
349
352
  My practice shows - We need 3 denormalized fields into comment for (request-free) building of recent comments list:
350
353
 
351
- <img src="https://raw.github.com/open-cook/the_comments/master/docs/the_comments_view_5.gif" alt="the_comments">
354
+ <img src="https://raw.github.com/open-cook/the-teacher/master/docs/the_comments_view_5.gif" alt="the_comments">
352
355
 
353
356
  * **Comment#commentable_title** - for example: "My first post about Ruby On Rails"
354
357
  * **Comment#commentable_url** - for example: "/posts/1-my-first-post-about-ruby-on-rails"
@@ -358,7 +361,7 @@ That is why any **Commentable Model should have few methods** to provide denorma
358
361
 
359
362
  ## Recent comments building
360
363
 
361
- Denormalization makes, building of Recent comments (for polymorphic relationship) is very easy!
364
+ Denormalization makes building of Recent comments (for polymorphic relationship) very easy!
362
365
 
363
366
  Controller:
364
367
 
@@ -489,9 +492,20 @@ I need your opinion, ideas, user experience - that is why you can ask me about t
489
492
 
490
493
  Yes, It's true - I was a school teacher in the past.
491
494
  That's why my login is the-teacher.
492
- Now I'm ruby & frontend developer.
495
+ Now I'm ruby/frontend developer and [food-blogger](http://open-cook.ru).
493
496
  I learn, I teach, I make a code. And sorry for my English.
494
497
 
498
+ ## What about specs?
499
+
500
+ This gem - just first prototype of my ideas about comment system.
501
+ Unfortunatly, I have no time to write many tests for this gem.
502
+ Release 1.0.0 works for my pet projects - it's enough for me.
503
+ If you have a problem with gem and you can to create coverage tests for this problem - I will be happy to get your pull request.
504
+
505
+ ### Where I can find example of application with the_comments?
506
+
507
+ This gem is part of new version of my food-blog about modern russian home cuisine. There is code of my tasty CMS [open-cook](https://github.com/open-cook/open-cook)
508
+
495
509
  ## Contributing
496
510
 
497
511
  1. Fork it
@@ -70,7 +70,7 @@ module TheCommentsController
70
70
  end
71
71
 
72
72
  def new
73
- @comments = current_user.my_comments.with_state(:draft).order('created_at DESC').page(params[:page])
73
+ @comments = current_user.comcoms.with_state(:draft).order('created_at DESC').page(params[:page])
74
74
  render template: 'the_comments/manage'
75
75
  end
76
76
 
@@ -63,7 +63,7 @@ module TheCommentsBase
63
63
 
64
64
  def update_cache_counters
65
65
  user.try :recalculate_my_comments_counter!
66
- commentable.try :increment!, :draft_comments_count
67
- holder.try :increment!, :draft_comcoms_count
66
+ commentable.try :increment!, "#{state}_comments_count"
67
+ holder.try :increment!, "#{state}_comcoms_count"
68
68
  end
69
69
  end
@@ -9,7 +9,10 @@ module TheCommentsCommentable
9
9
  after_save :denormalize_for_comments
10
10
  end
11
11
 
12
+ # Default Denormalization methods
13
+ # Overwrite it with your Application
12
14
  def commentable_title
15
+ # My first blog post
13
16
  try(:title) || TheComments.config.default_title
14
17
  end
15
18
 
@@ -23,6 +26,7 @@ module TheCommentsCommentable
23
26
  try(:state)
24
27
  end
25
28
 
29
+ # Helper methods
26
30
  def comments_sum
27
31
  published_comments_count + draft_comments_count
28
32
  end
@@ -42,6 +42,7 @@ module TheCommentsStates
42
42
  after_transition [:draft, :published] => :deleted do |comment|
43
43
  ids = comment.self_and_descendants.map(&:id)
44
44
  Comment.where(id: ids).update_all(state: :deleted)
45
+
45
46
  @owner.try :recalculate_my_comments_counter!
46
47
  @holder.try :recalculate_comcoms_counters!
47
48
  @commentable.try :recalculate_comments_counters!
@@ -76,7 +76,7 @@ class CreateComments < ActiveRecord::Migration
76
76
  t.integer :spam_comcoms_count, default: 0
77
77
  end
78
78
 
79
- # Uncomment this. Add fields Commentable Models
79
+ # Uncomment this. Add fields to Commentable Models
80
80
  #
81
81
  # [:posts, :blogs, :articles, :pages].each do |table_name|
82
82
  # change_table table_name do |t|
@@ -15,6 +15,7 @@ class CommentsController < ApplicationController
15
15
  # Application side methods:
16
16
  # Overwrite following default methods if it's need
17
17
  # Following methods based on *current_user* helper method
18
+ # Look here: https://github.com/the-teacher/the_comments/blob/master/app/controllers/concerns/the_comments_controller.rb#L62
18
19
  #
19
20
  # [:my, :incoming, :edit, :trash]
20
21
 
@@ -1,10 +1,10 @@
1
1
  # TheComments.config.param_name => value
2
2
 
3
3
  TheComments.configure do |config|
4
- config.max_reply_depth = 3
5
- config.tolerance_time = 5
6
- config.default_state = :draft
7
- config.default_owner_state = :published
8
- config.empty_inputs = [:commentBody]
9
- config.default_title = 'Undefined title'
4
+ config.max_reply_depth = 3 # comments tree depth
5
+ config.tolerance_time = 5 # sec - after this delay user can post a comment
6
+ config.default_state = :draft # default state for comment
7
+ config.default_owner_state = :published # default state for comment for Moderator
8
+ config.empty_inputs = [:commentBody] # array of spam trap fields
9
+ config.default_title = 'Undefined title' # default commentable_title for denormalization
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module TheComments
2
- VERSION = "0.9.9"
2
+ VERSION = "1.0.0"
3
3
  end
data/the_comments.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
8
8
  gem.version = TheComments::VERSION
9
9
  gem.authors = ["Ilya N. Zykin"]
10
10
  gem.email = ["zykin-ilya@ya.ru"]
11
- gem.description = %q{ Nested Comments }
12
- gem.summary = %q{ Nested Comments form TheTeacher }
11
+ gem.description = %q{ Comments with threading for Rails 4 }
12
+ gem.summary = %q{ the_comments by the-teacher }
13
13
  gem.homepage = "https://github.com/open-cook/the_comments"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
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: 0.9.9
4
+ version: 1.0.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-06 00:00:00.000000000 Z
12
+ date: 2013-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: state_machine
16
- requirement: &78089010 !ruby/object:Gem::Requirement
16
+ requirement: &78157620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *78089010
24
+ version_requirements: *78157620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: the_sortable_tree
27
- requirement: &78088800 !ruby/object:Gem::Requirement
27
+ requirement: &78157410 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,8 +32,8 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *78088800
36
- description: ! ' Nested Comments '
35
+ version_requirements: *78157410
36
+ description: ! ' Comments with threading for Rails 4 '
37
37
  email:
38
38
  - zykin-ilya@ya.ru
39
39
  executables: []
@@ -110,5 +110,5 @@ rubyforge_project:
110
110
  rubygems_version: 1.8.15
111
111
  signing_key:
112
112
  specification_version: 3
113
- summary: Nested Comments form TheTeacher
113
+ summary: the_comments by the-teacher
114
114
  test_files: []