the_comments 0.9.0 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,24 +2,31 @@ module TheCommentsUser
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  included do
5
- has_many :comments
6
- has_many :comcoms, class_name: :Comment, foreign_key: :holder_id
5
+ has_many :posted_comments, class_name: :Comment, foreign_key: :user_id
6
+ has_many :comcoms, class_name: :Comment, foreign_key: :holder_id
7
+ end
8
+
9
+ def my_comments
10
+ posted_comments.with_state([:draft,:published])
11
+ end
7
12
 
8
- def recalculate_comments_counters
9
- [:comments, :comcoms].each do |name|
10
- send "draft_#{name}_count=", send(name).with_state(:draft).count
11
- send "published_#{name}_count=", send(name).with_state(:published).count
12
- send "deleted_#{name}_count=", send(name).with_state(:deleted).count
13
- end
14
- save
15
- end
13
+ def recalculate_my_comments_counter!
14
+ self.my_comments_count = my_comments.count
15
+ save
16
+ end
16
17
 
17
- def comments_sum
18
- published_comments_count + draft_comments_count
19
- end
18
+ def recalculate_comcoms_counters!
19
+ self.draft_comcoms_count = comcoms.with_state(:draft).count
20
+ self.published_comcoms_count = comcoms.with_state(:published).count
21
+ self.deleted_comcoms_count = comcoms.with_state(:deleted).count
22
+ save
23
+ end
24
+
25
+ def comments_sum
26
+ published_comments_count + draft_comments_count
27
+ end
20
28
 
21
- def comcoms_sum
22
- published_comcoms_count + draft_comcoms_count
23
- end
29
+ def comcoms_sum
30
+ published_comcoms_count + draft_comcoms_count
24
31
  end
25
32
  end
data/config/routes.rb CHANGED
@@ -8,17 +8,17 @@ Rails.application.routes.draw do
8
8
  end
9
9
 
10
10
  resources :comments do
11
- collection do
12
- get :my
13
- get :incoming
14
- get :trash
15
- end
16
-
17
11
  member do
18
12
  post :to_spam
19
13
  post :to_draft
20
14
  post :to_published
21
15
  delete :to_trash
22
16
  end
17
+
18
+ collection do
19
+ get :my
20
+ get :incoming
21
+ get :trash
22
+ end
23
23
  end
24
24
  end
@@ -36,6 +36,9 @@ class CreateComments < ActiveRecord::Migration
36
36
  t.string :user_agent, default: :undefined
37
37
  t.integer :tolerance_time
38
38
 
39
+ # unusable: for future versions
40
+ t.boolean :spam, default: false
41
+
39
42
  # nested set
40
43
  t.integer :parent_id
41
44
  t.integer :lft
@@ -58,18 +61,24 @@ class CreateComments < ActiveRecord::Migration
58
61
  t.string :state, default: :warning
59
62
  end
60
63
 
61
- # Add fields to User and Commentable Object
64
+ # Add fields to User Model
62
65
  change_table :users do |t|
66
+ # posted_comments.with_state([:draft,:published])
67
+ t.integer :my_comments_count, default: 0
68
+
63
69
  # commentable's comments => comcoms (cache)
64
70
  # Relation through Comment#holder_id field
65
71
  t.integer :draft_comcoms_count, default: 0
66
72
  t.integer :published_comcoms_count, default: 0
67
73
  t.integer :deleted_comcoms_count, default: 0
74
+
75
+ # unusable: for future versions
76
+ t.integer :spam_comcoms_count, default: 0
68
77
  end
69
78
 
70
- # Uncomment this. Add fields to User model and Commentable models
79
+ # Uncomment this. Add fields Commentable Models
71
80
  #
72
- # [:users, :posts].each do |table_name|
81
+ # [:posts, :blogs, :articles, :pages].each do |table_name|
73
82
  # change_table table_name do |t|
74
83
  # t.integer :draft_comments_count, default: 0
75
84
  # t.integer :published_comments_count, default: 0
File without changes
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,7 +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.empty_inputs = [:commentBody]
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'
7
10
  end
@@ -28,7 +28,9 @@ BANNER
28
28
  copy_file "../assets/javascripts/the_comments", "app/assets/javascripts/the_comments"
29
29
  copy_file "../assets/stylesheets/the_comments", "app/assets/stylesheets/the_comments"
30
30
  elsif param_name == 'views'
31
- directory "../views/the_comments", "app/views/the_comments"
31
+ directory "../views/the_comments", "app/views/the_comments"
32
+ directory "../views/ip_black_lists", "app/views/ip_black_lists"
33
+ directory "../views/user_agent_black_lists", "app/views/user_agent_black_lists"
32
34
  elsif param_name == 'helper'
33
35
  copy_file "../helpers/render_comments_tree_helper.rb", "app/helpers/render_comments_tree_helper.rb"
34
36
  else
@@ -10,12 +10,15 @@ module TheComments
10
10
  # Configuration class
11
11
  class Configuration
12
12
  include ActiveSupport::Configurable
13
- config_accessor :tolerance_time, :empty_inputs, :max_reply_depth
13
+ config_accessor :tolerance_time, :empty_inputs, :max_reply_depth, :default_state, :default_owner_state, :default_title
14
14
  end
15
15
 
16
16
  configure do |config|
17
- config.max_reply_depth = 3
18
- config.tolerance_time = 5
19
- config.empty_inputs = [:message]
17
+ config.max_reply_depth = 3
18
+ config.tolerance_time = 5
19
+ config.default_state = :draft
20
+ config.default_owner_state = :published
21
+ config.empty_inputs = [:message]
22
+ config.default_title = 'Undefined title'
20
23
  end
21
24
  end
@@ -1,3 +1,3 @@
1
1
  module TheComments
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.9"
3
3
  end
data/lib/the_comments.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'haml'
2
1
  require 'state_machine'
3
2
  require 'the_sortable_tree'
4
3
 
data/the_comments.gemspec CHANGED
@@ -17,7 +17,8 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_dependency 'haml'
21
20
  gem.add_dependency 'state_machine'
22
21
  gem.add_dependency 'the_sortable_tree'
22
+
23
+ # gem.add_dependency 'rails', '>= 4.0'
23
24
  end
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.0
4
+ version: 0.9.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-15 00:00:00.000000000 Z
12
+ date: 2013-04-06 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: haml
16
- requirement: &80817540 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *80817540
25
14
  - !ruby/object:Gem::Dependency
26
15
  name: state_machine
27
- requirement: &80817330 !ruby/object:Gem::Requirement
16
+ requirement: &78089010 !ruby/object:Gem::Requirement
28
17
  none: false
29
18
  requirements:
30
19
  - - ! '>='
@@ -32,10 +21,10 @@ dependencies:
32
21
  version: '0'
33
22
  type: :runtime
34
23
  prerelease: false
35
- version_requirements: *80817330
24
+ version_requirements: *78089010
36
25
  - !ruby/object:Gem::Dependency
37
26
  name: the_sortable_tree
38
- requirement: &80817120 !ruby/object:Gem::Requirement
27
+ requirement: &78088800 !ruby/object:Gem::Requirement
39
28
  none: false
40
29
  requirements:
41
30
  - - ! '>='
@@ -43,7 +32,7 @@ dependencies:
43
32
  version: '0'
44
33
  type: :runtime
45
34
  prerelease: false
46
- version_requirements: *80817120
35
+ version_requirements: *78088800
47
36
  description: ! ' Nested Comments '
48
37
  email:
49
38
  - zykin-ilya@ya.ru
@@ -81,6 +70,12 @@ files:
81
70
  - config/locales/en.yml
82
71
  - config/routes.rb
83
72
  - db/migrate/20130101010101_create_comments.rb
73
+ - docs/the_comments.jpg
74
+ - docs/the_comments_view_1.gif
75
+ - docs/the_comments_view_2.gif
76
+ - docs/the_comments_view_3.gif
77
+ - docs/the_comments_view_4.gif
78
+ - docs/the_comments_view_5.gif
84
79
  - lib/generators/the_comments/USAGE
85
80
  - lib/generators/the_comments/templates/comments_controller.rb
86
81
  - lib/generators/the_comments/templates/ip_black_lists_controller.rb
@@ -92,7 +87,6 @@ files:
92
87
  - lib/the_comments/config.rb
93
88
  - lib/the_comments/version.rb
94
89
  - the_comments.gemspec
95
- - the_comments.jpg
96
90
  homepage: https://github.com/open-cook/the_comments
97
91
  licenses: []
98
92
  post_install_message: