the_comments 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. data/.rvmrc.example +1 -0
  2. data/.travis.yml +5 -0
  3. data/README.md +105 -425
  4. data/app/assets/javascripts/the_comments.js.coffee +12 -9
  5. data/app/assets/javascripts/the_comments_manage.js.coffee +19 -49
  6. data/app/assets/stylesheets/the_comments.css.scss +20 -29
  7. data/app/controllers/_templates_/comments_controller.rb +44 -0
  8. data/app/controllers/concerns/controller.rb +216 -0
  9. data/app/helpers/render_comments_tree_helper.rb +4 -7
  10. data/app/models/_templates_/comment.rb +38 -0
  11. data/app/models/concerns/comment.rb +103 -0
  12. data/app/models/concerns/comment_states.rb +80 -0
  13. data/app/models/concerns/commentable.rb +69 -0
  14. data/app/models/concerns/user.rb +52 -0
  15. data/app/views/the_comments/_tree.html.erb +3 -0
  16. data/app/views/the_comments/haml/_additional_info.html.haml +13 -0
  17. data/app/views/the_comments/{_comment.html.haml → haml/_comment.html.haml} +0 -0
  18. data/app/views/the_comments/haml/_comment_body.html.haml +20 -0
  19. data/app/views/the_comments/haml/_comment_edit.html.haml +26 -0
  20. data/app/views/the_comments/{_form.html.haml → haml/_form.html.haml} +8 -6
  21. data/app/views/the_comments/haml/_manage_controls.html.haml +27 -0
  22. data/app/views/the_comments/haml/_sidebar.html.haml +28 -0
  23. data/app/views/the_comments/haml/_tree.html.haml +4 -0
  24. data/app/views/the_comments/haml/index.html.haml +18 -0
  25. data/app/views/the_comments/haml/manage.html.haml +25 -0
  26. data/app/views/the_comments/haml/my_comments.html.haml +28 -0
  27. data/app/views/the_comments/slim/_additional_info.html.slim +13 -0
  28. data/app/views/the_comments/slim/_comment.html.slim +1 -0
  29. data/app/views/the_comments/slim/_comment_body.html.slim +20 -0
  30. data/app/views/the_comments/slim/_comment_edit.html.slim +26 -0
  31. data/app/views/the_comments/slim/_form.html.slim +27 -0
  32. data/app/views/the_comments/slim/_manage_controls.html.slim +27 -0
  33. data/app/views/the_comments/slim/_sidebar.html.slim +28 -0
  34. data/app/views/the_comments/slim/_tree.html.slim +4 -0
  35. data/app/views/the_comments/slim/index.html.slim +18 -0
  36. data/app/views/the_comments/slim/manage.html.slim +25 -0
  37. data/app/views/the_comments/slim/my_comments.html.slim +28 -0
  38. data/{lib/generators/the_comments/templates → config/initializers}/the_comments.rb +3 -0
  39. data/config/locales/en.yml +39 -14
  40. data/config/locales/ru.yml +67 -0
  41. data/config/routes.rb +17 -13
  42. data/db/migrate/20130101010101_change_user.rb +18 -0
  43. data/db/migrate/20130101010102_create_comments.rb +50 -0
  44. data/db/migrate/20130101010103_change_commentable.rb +13 -0
  45. data/docs/admin_ui_installation.md +145 -0
  46. data/docs/advanced_installation.md +182 -0
  47. data/docs/comment_api.md +58 -0
  48. data/docs/commentable_api.md +59 -0
  49. data/docs/config_file.md +27 -0
  50. data/docs/content_preprocessors.md +73 -0
  51. data/docs/customazation_of_views.md +30 -0
  52. data/docs/denormalization_and_recent_comments.md +40 -0
  53. data/docs/documentation.md +28 -0
  54. data/docs/mountable_routes.md +80 -0
  55. data/docs/pagination.md +123 -0
  56. data/docs/screencast.jpg +0 -0
  57. data/docs/user_api.md +75 -0
  58. data/docs/what_is_comcoms.md +63 -0
  59. data/docs/whats_wrong_with_other_gems.md +18 -0
  60. data/docs/where_is_example_application.md +37 -0
  61. data/gem_version.rb +3 -0
  62. data/lib/generators/the_comments/USAGE +31 -20
  63. data/lib/generators/the_comments/the_comments_generator.rb +35 -18
  64. data/lib/generators/the_comments/views_generator.rb +52 -16
  65. data/lib/the_comments/config.rb +14 -1
  66. data/lib/the_comments/version.rb +1 -3
  67. data/lib/the_comments.rb +10 -0
  68. data/spec/dummy_app/.gitignore +17 -0
  69. data/spec/dummy_app/.rspec +1 -0
  70. data/spec/dummy_app/.ruby-gemset +1 -0
  71. data/spec/dummy_app/.ruby-version +1 -0
  72. data/spec/dummy_app/Gemfile +43 -0
  73. data/spec/dummy_app/README.md +50 -0
  74. data/spec/dummy_app/Rakefile +6 -0
  75. data/spec/dummy_app/app/assets/images/.keep +0 -0
  76. data/spec/dummy_app/app/assets/javascripts/admin_panel.js +5 -0
  77. data/spec/dummy_app/app/assets/javascripts/application.js +16 -0
  78. data/spec/dummy_app/app/assets/stylesheets/admin_panel.css +3 -0
  79. data/spec/dummy_app/app/assets/stylesheets/app.css.scss +4 -0
  80. data/spec/dummy_app/app/assets/stylesheets/application.css +16 -0
  81. data/spec/dummy_app/app/controllers/application_controller.rb +7 -0
  82. data/{lib/generators/the_comments/templates → spec/dummy_app/app/controllers}/comments_controller.rb +3 -1
  83. data/spec/dummy_app/app/controllers/concerns/.keep +0 -0
  84. data/spec/dummy_app/app/controllers/posts_controller.rb +13 -0
  85. data/spec/dummy_app/app/controllers/users_controller.rb +7 -0
  86. data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
  87. data/spec/dummy_app/app/mailers/.keep +0 -0
  88. data/spec/dummy_app/app/models/.keep +0 -0
  89. data/spec/dummy_app/app/models/comment.rb +32 -0
  90. data/spec/dummy_app/app/models/concerns/.keep +0 -0
  91. data/spec/dummy_app/app/models/post.rb +17 -0
  92. data/spec/dummy_app/app/models/user.rb +21 -0
  93. data/spec/dummy_app/app/views/layouts/admin.html.haml +25 -0
  94. data/spec/dummy_app/app/views/layouts/application.html.haml +20 -0
  95. data/spec/dummy_app/app/views/posts/index.html.haml +22 -0
  96. data/spec/dummy_app/app/views/posts/show.html.haml +7 -0
  97. data/spec/dummy_app/bin/bundle +3 -0
  98. data/spec/dummy_app/bin/rails +4 -0
  99. data/spec/dummy_app/bin/rake +4 -0
  100. data/spec/dummy_app/config/application.rb +23 -0
  101. data/spec/dummy_app/config/boot.rb +4 -0
  102. data/spec/dummy_app/config/database.yml +11 -0
  103. data/spec/dummy_app/config/environment.rb +5 -0
  104. data/spec/dummy_app/config/environments/development.rb +29 -0
  105. data/spec/dummy_app/config/environments/production.rb +80 -0
  106. data/spec/dummy_app/config/environments/test.rb +36 -0
  107. data/spec/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
  108. data/spec/dummy_app/config/initializers/filter_parameter_logging.rb +4 -0
  109. data/spec/dummy_app/config/initializers/inflections.rb +16 -0
  110. data/spec/dummy_app/config/initializers/mime_types.rb +5 -0
  111. data/spec/dummy_app/config/initializers/secret_token.rb +12 -0
  112. data/spec/dummy_app/config/initializers/session_store.rb +3 -0
  113. data/spec/dummy_app/config/initializers/sorcery.rb +437 -0
  114. data/spec/dummy_app/config/initializers/the_comments.rb +13 -0
  115. data/spec/dummy_app/config/initializers/wrap_parameters.rb +14 -0
  116. data/spec/dummy_app/config/locales/en.yml +23 -0
  117. data/spec/dummy_app/config/routes.rb +15 -0
  118. data/spec/dummy_app/config.ru +4 -0
  119. data/spec/dummy_app/db/migrate/20130712061503_sorcery_core.rb +16 -0
  120. data/spec/dummy_app/db/migrate/20130712065951_create_posts.rb +11 -0
  121. data/spec/dummy_app/db/migrate/20131027185332_change_user.the_comments_engine.rb +19 -0
  122. data/spec/dummy_app/db/migrate/20131027185333_create_comments.the_comments_engine.rb +51 -0
  123. data/spec/dummy_app/db/migrate/20131027185334_change_commentable.the_comments_engine.rb +14 -0
  124. data/spec/dummy_app/db/schema.rb +74 -0
  125. data/spec/dummy_app/db/seeds.rb +42 -0
  126. data/spec/dummy_app/lib/assets/.keep +0 -0
  127. data/spec/dummy_app/lib/tasks/.keep +0 -0
  128. data/spec/dummy_app/lib/tasks/app_bootstrap.rake +15 -0
  129. data/spec/dummy_app/log/.keep +0 -0
  130. data/spec/dummy_app/public/404.html +58 -0
  131. data/spec/dummy_app/public/422.html +58 -0
  132. data/spec/dummy_app/public/500.html +57 -0
  133. data/spec/dummy_app/public/favicon.ico +0 -0
  134. data/spec/dummy_app/public/robots.txt +5 -0
  135. data/spec/dummy_app/spec/factories/post.rb +6 -0
  136. data/spec/dummy_app/spec/factories/user.rb +6 -0
  137. data/spec/dummy_app/spec/models/user_counters_spec.rb +339 -0
  138. data/spec/dummy_app/spec/spec_helper.rb +29 -0
  139. data/spec/dummy_app/test/controllers/.keep +0 -0
  140. data/spec/dummy_app/test/fixtures/.keep +0 -0
  141. data/spec/dummy_app/test/helpers/.keep +0 -0
  142. data/spec/dummy_app/test/integration/.keep +0 -0
  143. data/spec/dummy_app/test/mailers/.keep +0 -0
  144. data/spec/dummy_app/test/models/.keep +0 -0
  145. data/spec/dummy_app/test/test_helper.rb +15 -0
  146. data/spec/dummy_app/vendor/assets/javascripts/.keep +0 -0
  147. data/spec/dummy_app/vendor/assets/stylesheets/.keep +0 -0
  148. data/views_converter.rb +16 -0
  149. metadata +223 -45
  150. data/app/controllers/concerns/the_comments_controller.rb +0 -229
  151. data/app/controllers/concerns/the_comments_ip_controller.rb +0 -17
  152. data/app/controllers/concerns/the_comments_user_agent_controller.rb +0 -15
  153. data/app/models/concerns/the_comments_base.rb +0 -69
  154. data/app/models/concerns/the_comments_black_ip.rb +0 -9
  155. data/app/models/concerns/the_comments_black_user_agent.rb +0 -9
  156. data/app/models/concerns/the_comments_commentable.rb +0 -66
  157. data/app/models/concerns/the_comments_states.rb +0 -65
  158. data/app/models/concerns/the_comments_user.rb +0 -32
  159. data/app/views/ip_black_lists/index.html.haml +0 -17
  160. data/app/views/the_comments/_comment_body.html.haml +0 -30
  161. data/app/views/the_comments/_manage_controls.html.haml +0 -4
  162. data/app/views/the_comments/_tree.html.haml +0 -4
  163. data/app/views/the_comments/index.html.haml +0 -19
  164. data/app/views/the_comments/manage.html.haml +0 -29
  165. data/app/views/user_agent_black_lists/index.html.haml +0 -17
  166. data/db/migrate/20130101010101_create_comments.rb +0 -90
  167. data/lib/generators/the_comments/templates/ip_black_list.rb +0 -3
  168. data/lib/generators/the_comments/templates/ip_black_lists_controller.rb +0 -10
  169. data/lib/generators/the_comments/templates/the_comments_black_ip.rb +0 -9
  170. data/lib/generators/the_comments/templates/the_comments_black_user_agent.rb +0 -9
  171. data/lib/generators/the_comments/templates/user_agent_black_list.rb +0 -3
  172. data/lib/generators/the_comments/templates/user_agent_black_lists_controller.rb +0 -10
@@ -0,0 +1,29 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+ require File.expand_path("../../config/environment", __FILE__)
3
+
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+
7
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
8
+ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
9
+
10
+ RSpec.configure do |config|
11
+ config.infer_base_class_for_anonymous_controllers = false
12
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
13
+ config.use_transactional_fixtures = true
14
+ config.order = "random"
15
+
16
+ # DatabaseCleaner
17
+ # config.before(:suite) do
18
+ # DatabaseCleaner.strategy = :transaction
19
+ # DatabaseCleaner.clean_with(:truncation)
20
+ # end
21
+
22
+ # config.before(:each) do
23
+ # DatabaseCleaner.start
24
+ # end
25
+
26
+ # config.after(:each) do
27
+ # DatabaseCleaner.clean
28
+ # end
29
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ ActiveRecord::Migration.check_pending!
7
+
8
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
9
+ #
10
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
11
+ # -- they do not yet inherit this setting
12
+ fixtures :all
13
+
14
+ # Add more helper methods to be used by all tests here...
15
+ end
File without changes
File without changes
@@ -0,0 +1,16 @@
1
+ # gem install haml2slim --nori --nordoc
2
+ # ruby views_converter.rb
3
+
4
+ from = "./app/views/the_comments/haml"
5
+ to = "./app/views/the_comments/slim"
6
+
7
+ `haml2slim #{from} #{to} --trace`
8
+
9
+ Dir.glob("#{to}/*.slim") do |slim_file|
10
+ content = File.read slim_file
11
+ content = content.gsub "haml", "slim"
12
+
13
+ file = File.open slim_file, "w"
14
+ file.write content
15
+ file.close
16
+ 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: 1.1.0
4
+ version: 2.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-23 00:00:00.000000000 Z
12
+ date: 2013-11-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: state_machine
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &85480050 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,15 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
24
+ version_requirements: *85480050
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: the_sortable_tree
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &85479700 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ! '>='
@@ -37,12 +32,7 @@ dependencies:
37
32
  version: '0'
38
33
  type: :runtime
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
35
+ version_requirements: *85479700
46
36
  description: ! ' Comments with threading for Rails 4 '
47
37
  email:
48
38
  - zykin-ilya@ya.ru
@@ -51,6 +41,8 @@ extensions: []
51
41
  extra_rdoc_files: []
52
42
  files:
53
43
  - .gitignore
44
+ - .rvmrc.example
45
+ - .travis.yml
54
46
  - Gemfile
55
47
  - LICENSE.txt
56
48
  - README.md
@@ -58,49 +50,155 @@ files:
58
50
  - app/assets/javascripts/the_comments.js.coffee
59
51
  - app/assets/javascripts/the_comments_manage.js.coffee
60
52
  - app/assets/stylesheets/the_comments.css.scss
61
- - app/controllers/concerns/the_comments_controller.rb
62
- - app/controllers/concerns/the_comments_ip_controller.rb
63
- - app/controllers/concerns/the_comments_user_agent_controller.rb
53
+ - app/controllers/_templates_/comments_controller.rb
54
+ - app/controllers/concerns/controller.rb
64
55
  - app/helpers/render_comments_tree_helper.rb
65
- - app/models/concerns/the_comments_base.rb
66
- - app/models/concerns/the_comments_black_ip.rb
67
- - app/models/concerns/the_comments_black_user_agent.rb
68
- - app/models/concerns/the_comments_commentable.rb
69
- - app/models/concerns/the_comments_states.rb
70
- - app/models/concerns/the_comments_user.rb
71
- - app/views/ip_black_lists/index.html.haml
72
- - app/views/the_comments/_comment.html.haml
73
- - app/views/the_comments/_comment_body.html.haml
74
- - app/views/the_comments/_form.html.haml
75
- - app/views/the_comments/_manage_controls.html.haml
76
- - app/views/the_comments/_tree.html.haml
77
- - app/views/the_comments/index.html.haml
78
- - app/views/the_comments/manage.html.haml
79
- - app/views/user_agent_black_lists/index.html.haml
56
+ - app/models/_templates_/comment.rb
57
+ - app/models/concerns/comment.rb
58
+ - app/models/concerns/comment_states.rb
59
+ - app/models/concerns/commentable.rb
60
+ - app/models/concerns/user.rb
61
+ - app/views/the_comments/_tree.html.erb
62
+ - app/views/the_comments/haml/_additional_info.html.haml
63
+ - app/views/the_comments/haml/_comment.html.haml
64
+ - app/views/the_comments/haml/_comment_body.html.haml
65
+ - app/views/the_comments/haml/_comment_edit.html.haml
66
+ - app/views/the_comments/haml/_form.html.haml
67
+ - app/views/the_comments/haml/_manage_controls.html.haml
68
+ - app/views/the_comments/haml/_sidebar.html.haml
69
+ - app/views/the_comments/haml/_tree.html.haml
70
+ - app/views/the_comments/haml/index.html.haml
71
+ - app/views/the_comments/haml/manage.html.haml
72
+ - app/views/the_comments/haml/my_comments.html.haml
73
+ - app/views/the_comments/slim/_additional_info.html.slim
74
+ - app/views/the_comments/slim/_comment.html.slim
75
+ - app/views/the_comments/slim/_comment_body.html.slim
76
+ - app/views/the_comments/slim/_comment_edit.html.slim
77
+ - app/views/the_comments/slim/_form.html.slim
78
+ - app/views/the_comments/slim/_manage_controls.html.slim
79
+ - app/views/the_comments/slim/_sidebar.html.slim
80
+ - app/views/the_comments/slim/_tree.html.slim
81
+ - app/views/the_comments/slim/index.html.slim
82
+ - app/views/the_comments/slim/manage.html.slim
83
+ - app/views/the_comments/slim/my_comments.html.slim
84
+ - config/initializers/the_comments.rb
80
85
  - config/locales/en.yml
86
+ - config/locales/ru.yml
81
87
  - config/routes.rb
82
- - db/migrate/20130101010101_create_comments.rb
88
+ - db/migrate/20130101010101_change_user.rb
89
+ - db/migrate/20130101010102_create_comments.rb
90
+ - db/migrate/20130101010103_change_commentable.rb
91
+ - docs/admin_ui_installation.md
92
+ - docs/advanced_installation.md
93
+ - docs/comment_api.md
94
+ - docs/commentable_api.md
95
+ - docs/config_file.md
96
+ - docs/content_preprocessors.md
97
+ - docs/customazation_of_views.md
98
+ - docs/denormalization_and_recent_comments.md
99
+ - docs/documentation.md
100
+ - docs/mountable_routes.md
101
+ - docs/pagination.md
102
+ - docs/screencast.jpg
83
103
  - docs/the_comments.jpg
84
104
  - docs/the_comments_view_1.gif
85
105
  - docs/the_comments_view_2.gif
86
106
  - docs/the_comments_view_3.gif
87
107
  - docs/the_comments_view_4.gif
88
108
  - docs/the_comments_view_5.gif
109
+ - docs/user_api.md
110
+ - docs/what_is_comcoms.md
111
+ - docs/whats_wrong_with_other_gems.md
112
+ - docs/where_is_example_application.md
113
+ - gem_version.rb
89
114
  - lib/generators/the_comments/USAGE
90
- - lib/generators/the_comments/templates/comments_controller.rb
91
- - lib/generators/the_comments/templates/ip_black_list.rb
92
- - lib/generators/the_comments/templates/ip_black_lists_controller.rb
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
97
- - lib/generators/the_comments/templates/user_agent_black_lists_controller.rb
98
115
  - lib/generators/the_comments/the_comments_generator.rb
99
116
  - lib/generators/the_comments/views_generator.rb
100
117
  - lib/the_comments.rb
101
118
  - lib/the_comments/config.rb
102
119
  - lib/the_comments/version.rb
120
+ - spec/dummy_app/.gitignore
121
+ - spec/dummy_app/.rspec
122
+ - spec/dummy_app/.ruby-gemset
123
+ - spec/dummy_app/.ruby-version
124
+ - spec/dummy_app/Gemfile
125
+ - spec/dummy_app/README.md
126
+ - spec/dummy_app/Rakefile
127
+ - spec/dummy_app/app/assets/images/.keep
128
+ - spec/dummy_app/app/assets/javascripts/admin_panel.js
129
+ - spec/dummy_app/app/assets/javascripts/application.js
130
+ - spec/dummy_app/app/assets/stylesheets/admin_panel.css
131
+ - spec/dummy_app/app/assets/stylesheets/app.css.scss
132
+ - spec/dummy_app/app/assets/stylesheets/application.css
133
+ - spec/dummy_app/app/controllers/application_controller.rb
134
+ - spec/dummy_app/app/controllers/comments_controller.rb
135
+ - spec/dummy_app/app/controllers/concerns/.keep
136
+ - spec/dummy_app/app/controllers/posts_controller.rb
137
+ - spec/dummy_app/app/controllers/users_controller.rb
138
+ - spec/dummy_app/app/helpers/application_helper.rb
139
+ - spec/dummy_app/app/mailers/.keep
140
+ - spec/dummy_app/app/models/.keep
141
+ - spec/dummy_app/app/models/comment.rb
142
+ - spec/dummy_app/app/models/concerns/.keep
143
+ - spec/dummy_app/app/models/post.rb
144
+ - spec/dummy_app/app/models/user.rb
145
+ - spec/dummy_app/app/views/layouts/admin.html.haml
146
+ - spec/dummy_app/app/views/layouts/application.html.haml
147
+ - spec/dummy_app/app/views/posts/index.html.haml
148
+ - spec/dummy_app/app/views/posts/show.html.haml
149
+ - spec/dummy_app/bin/bundle
150
+ - spec/dummy_app/bin/rails
151
+ - spec/dummy_app/bin/rake
152
+ - spec/dummy_app/config.ru
153
+ - spec/dummy_app/config/application.rb
154
+ - spec/dummy_app/config/boot.rb
155
+ - spec/dummy_app/config/database.yml
156
+ - spec/dummy_app/config/environment.rb
157
+ - spec/dummy_app/config/environments/development.rb
158
+ - spec/dummy_app/config/environments/production.rb
159
+ - spec/dummy_app/config/environments/test.rb
160
+ - spec/dummy_app/config/initializers/backtrace_silencers.rb
161
+ - spec/dummy_app/config/initializers/filter_parameter_logging.rb
162
+ - spec/dummy_app/config/initializers/inflections.rb
163
+ - spec/dummy_app/config/initializers/mime_types.rb
164
+ - spec/dummy_app/config/initializers/secret_token.rb
165
+ - spec/dummy_app/config/initializers/session_store.rb
166
+ - spec/dummy_app/config/initializers/sorcery.rb
167
+ - spec/dummy_app/config/initializers/the_comments.rb
168
+ - spec/dummy_app/config/initializers/wrap_parameters.rb
169
+ - spec/dummy_app/config/locales/en.yml
170
+ - spec/dummy_app/config/routes.rb
171
+ - spec/dummy_app/db/migrate/20130712061503_sorcery_core.rb
172
+ - spec/dummy_app/db/migrate/20130712065951_create_posts.rb
173
+ - spec/dummy_app/db/migrate/20131027185332_change_user.the_comments_engine.rb
174
+ - spec/dummy_app/db/migrate/20131027185333_create_comments.the_comments_engine.rb
175
+ - spec/dummy_app/db/migrate/20131027185334_change_commentable.the_comments_engine.rb
176
+ - spec/dummy_app/db/schema.rb
177
+ - spec/dummy_app/db/seeds.rb
178
+ - spec/dummy_app/lib/assets/.keep
179
+ - spec/dummy_app/lib/tasks/.keep
180
+ - spec/dummy_app/lib/tasks/app_bootstrap.rake
181
+ - spec/dummy_app/log/.keep
182
+ - spec/dummy_app/public/404.html
183
+ - spec/dummy_app/public/422.html
184
+ - spec/dummy_app/public/500.html
185
+ - spec/dummy_app/public/favicon.ico
186
+ - spec/dummy_app/public/robots.txt
187
+ - spec/dummy_app/spec/factories/post.rb
188
+ - spec/dummy_app/spec/factories/user.rb
189
+ - spec/dummy_app/spec/models/user_counters_spec.rb
190
+ - spec/dummy_app/spec/spec_helper.rb
191
+ - spec/dummy_app/test/controllers/.keep
192
+ - spec/dummy_app/test/fixtures/.keep
193
+ - spec/dummy_app/test/helpers/.keep
194
+ - spec/dummy_app/test/integration/.keep
195
+ - spec/dummy_app/test/mailers/.keep
196
+ - spec/dummy_app/test/models/.keep
197
+ - spec/dummy_app/test/test_helper.rb
198
+ - spec/dummy_app/vendor/assets/javascripts/.keep
199
+ - spec/dummy_app/vendor/assets/stylesheets/.keep
103
200
  - the_comments.gemspec
201
+ - views_converter.rb
104
202
  homepage: https://github.com/open-cook/the_comments
105
203
  licenses: []
106
204
  post_install_message:
@@ -121,8 +219,88 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
219
  version: '0'
122
220
  requirements: []
123
221
  rubyforge_project:
124
- rubygems_version: 1.8.25
222
+ rubygems_version: 1.8.15
125
223
  signing_key:
126
224
  specification_version: 3
127
225
  summary: the_comments by the-teacher
128
- test_files: []
226
+ test_files:
227
+ - spec/dummy_app/.gitignore
228
+ - spec/dummy_app/.rspec
229
+ - spec/dummy_app/.ruby-gemset
230
+ - spec/dummy_app/.ruby-version
231
+ - spec/dummy_app/Gemfile
232
+ - spec/dummy_app/README.md
233
+ - spec/dummy_app/Rakefile
234
+ - spec/dummy_app/app/assets/images/.keep
235
+ - spec/dummy_app/app/assets/javascripts/admin_panel.js
236
+ - spec/dummy_app/app/assets/javascripts/application.js
237
+ - spec/dummy_app/app/assets/stylesheets/admin_panel.css
238
+ - spec/dummy_app/app/assets/stylesheets/app.css.scss
239
+ - spec/dummy_app/app/assets/stylesheets/application.css
240
+ - spec/dummy_app/app/controllers/application_controller.rb
241
+ - spec/dummy_app/app/controllers/comments_controller.rb
242
+ - spec/dummy_app/app/controllers/concerns/.keep
243
+ - spec/dummy_app/app/controllers/posts_controller.rb
244
+ - spec/dummy_app/app/controllers/users_controller.rb
245
+ - spec/dummy_app/app/helpers/application_helper.rb
246
+ - spec/dummy_app/app/mailers/.keep
247
+ - spec/dummy_app/app/models/.keep
248
+ - spec/dummy_app/app/models/comment.rb
249
+ - spec/dummy_app/app/models/concerns/.keep
250
+ - spec/dummy_app/app/models/post.rb
251
+ - spec/dummy_app/app/models/user.rb
252
+ - spec/dummy_app/app/views/layouts/admin.html.haml
253
+ - spec/dummy_app/app/views/layouts/application.html.haml
254
+ - spec/dummy_app/app/views/posts/index.html.haml
255
+ - spec/dummy_app/app/views/posts/show.html.haml
256
+ - spec/dummy_app/bin/bundle
257
+ - spec/dummy_app/bin/rails
258
+ - spec/dummy_app/bin/rake
259
+ - spec/dummy_app/config.ru
260
+ - spec/dummy_app/config/application.rb
261
+ - spec/dummy_app/config/boot.rb
262
+ - spec/dummy_app/config/database.yml
263
+ - spec/dummy_app/config/environment.rb
264
+ - spec/dummy_app/config/environments/development.rb
265
+ - spec/dummy_app/config/environments/production.rb
266
+ - spec/dummy_app/config/environments/test.rb
267
+ - spec/dummy_app/config/initializers/backtrace_silencers.rb
268
+ - spec/dummy_app/config/initializers/filter_parameter_logging.rb
269
+ - spec/dummy_app/config/initializers/inflections.rb
270
+ - spec/dummy_app/config/initializers/mime_types.rb
271
+ - spec/dummy_app/config/initializers/secret_token.rb
272
+ - spec/dummy_app/config/initializers/session_store.rb
273
+ - spec/dummy_app/config/initializers/sorcery.rb
274
+ - spec/dummy_app/config/initializers/the_comments.rb
275
+ - spec/dummy_app/config/initializers/wrap_parameters.rb
276
+ - spec/dummy_app/config/locales/en.yml
277
+ - spec/dummy_app/config/routes.rb
278
+ - spec/dummy_app/db/migrate/20130712061503_sorcery_core.rb
279
+ - spec/dummy_app/db/migrate/20130712065951_create_posts.rb
280
+ - spec/dummy_app/db/migrate/20131027185332_change_user.the_comments_engine.rb
281
+ - spec/dummy_app/db/migrate/20131027185333_create_comments.the_comments_engine.rb
282
+ - spec/dummy_app/db/migrate/20131027185334_change_commentable.the_comments_engine.rb
283
+ - spec/dummy_app/db/schema.rb
284
+ - spec/dummy_app/db/seeds.rb
285
+ - spec/dummy_app/lib/assets/.keep
286
+ - spec/dummy_app/lib/tasks/.keep
287
+ - spec/dummy_app/lib/tasks/app_bootstrap.rake
288
+ - spec/dummy_app/log/.keep
289
+ - spec/dummy_app/public/404.html
290
+ - spec/dummy_app/public/422.html
291
+ - spec/dummy_app/public/500.html
292
+ - spec/dummy_app/public/favicon.ico
293
+ - spec/dummy_app/public/robots.txt
294
+ - spec/dummy_app/spec/factories/post.rb
295
+ - spec/dummy_app/spec/factories/user.rb
296
+ - spec/dummy_app/spec/models/user_counters_spec.rb
297
+ - spec/dummy_app/spec/spec_helper.rb
298
+ - spec/dummy_app/test/controllers/.keep
299
+ - spec/dummy_app/test/fixtures/.keep
300
+ - spec/dummy_app/test/helpers/.keep
301
+ - spec/dummy_app/test/integration/.keep
302
+ - spec/dummy_app/test/mailers/.keep
303
+ - spec/dummy_app/test/models/.keep
304
+ - spec/dummy_app/test/test_helper.rb
305
+ - spec/dummy_app/vendor/assets/javascripts/.keep
306
+ - spec/dummy_app/vendor/assets/stylesheets/.keep
@@ -1,229 +0,0 @@
1
- module TheCommentsController
2
- COMMENTS_COOKIES_TOKEN = 'JustTheCommentsCookies'
3
-
4
- # Cookies and View token for spam protection
5
- #
6
- # class ApplicationController < ActionController::Base
7
- # include TheCommentsController::ViewToken
8
- # end
9
- module ViewToken
10
- extend ActiveSupport::Concern
11
- included { before_action :set_the_comments_cookies }
12
-
13
- def comments_view_token
14
- cookies[:comments_view_token]
15
- end
16
-
17
- private
18
-
19
- def set_the_comments_cookies
20
- cookies[:the_comment_cookies] = { value: TheCommentsController::COMMENTS_COOKIES_TOKEN, expires: 1.year.from_now }
21
- cookies[:comments_view_token] = { value: SecureRandom.hex, expires: 7.days.from_now } unless cookies[:comments_view_token]
22
- end
23
- end
24
-
25
- # Base functionality of Comments Controller
26
- #
27
- # class CommentsController < ApplicationController
28
- # include TheCommentsController::Base
29
- # end
30
- module Base
31
- extend ActiveSupport::Concern
32
-
33
- included do
34
- include TheCommentsController::ViewToken
35
-
36
- before_action -> { @errors = [] }
37
-
38
- # Attention! We should not set TheComments cookie before create
39
- skip_before_action :set_the_comments_cookies, only: [:create]
40
-
41
- # Black lists
42
- before_action :stop_black_ip, only: [:create]
43
- before_action :stop_black_user_agent, only: [:create]
44
-
45
- # Spam protection
46
- before_action :ajax_requests_required, only: [:create]
47
- before_action :cookies_required, only: [:create]
48
- before_action :empty_trap_required, only: [:create]
49
- before_action :tolerance_time_required, only: [:create]
50
-
51
- # preparation
52
- before_action :define_commentable, only: [:create]
53
- end
54
-
55
- # App side methods (overwrite it)
56
- def index
57
- @comments = Comment.with_state(:published).order('created_at DESC').page(params[:page])
58
- render template: 'the_comments/index'
59
- end
60
-
61
- # Methods based on *current_user* helper
62
- def edit
63
- @comments = current_user.comcoms.where(id: params[:id]).page(params[:page])
64
- render template: 'the_comments/manage'
65
- end
66
-
67
- def my
68
- @comments = current_user.my_comments.order('created_at DESC').page(params[:page])
69
- render template: 'the_comments/index'
70
- end
71
-
72
- def new
73
- @comments = current_user.comcoms.with_state(:draft).order('created_at DESC').page(params[:page])
74
- render template: 'the_comments/manage'
75
- end
76
-
77
- def incoming
78
- @comments = current_user.comcoms.with_state(:draft, :published).order('created_at DESC').page(params[:page])
79
- render template: 'the_comments/manage'
80
- end
81
-
82
- def trash
83
- @comments = current_user.comcoms.with_state(:deleted).order('created_at DESC').page(params[:page])
84
- render template: 'the_comments/manage'
85
- end
86
-
87
- # BASE METHODS
88
-
89
- # Public methods
90
-
91
- def update
92
- comment = Comment.where(id: params[:id]).first
93
- comment.update_attributes!(patch_comment_params)
94
- render(layout: false, partial: 'the_comments/comment_body', locals: { comment: comment })
95
- end
96
-
97
- def create
98
- @comment = @commentable.comments.new comment_params
99
- if @comment.valid?
100
- @comment.save
101
- return render layout: false, partial: 'the_comments/comment', locals: { tree: @comment }
102
- end
103
- render json: { errors: @comment.errors.full_messages }
104
- end
105
-
106
- # Protected methods
107
-
108
- def to_published
109
- Comment.where(id: params[:id]).first.to_published
110
- render nothing: :true
111
- end
112
-
113
- def to_draft
114
- Comment.where(id: params[:id]).first.to_draft
115
- render nothing: :true
116
- end
117
-
118
- def to_spam
119
- comment = Comment.where(id: params[:id]).first
120
- IpBlackList.where(ip: comment.ip).first_or_create.increment!(:count)
121
- UserAgentBlackList.where(user_agent: comment.user_agent).first_or_create.increment!(:count)
122
- comment.to_deleted
123
- render nothing: :true
124
- end
125
-
126
- def to_trash
127
- Comment.where(id: params[:id]).first.to_deleted
128
- render nothing: :true
129
- end
130
-
131
- private
132
-
133
- def denormalized_fields
134
- title = @commentable.commentable_title
135
- url = @commentable.commentable_url
136
- @commentable ? { commentable_title: title, commentable_url: url } : {}
137
- end
138
-
139
- def request_data_for_black_lists
140
- r = request
141
- { ip: r.ip, referer: CGI::unescape(r.referer || 'direct_visit'), user_agent: r.user_agent }
142
- end
143
-
144
- def define_commentable
145
- commentable_klass = params[:comment][:commentable_type].constantize
146
- commentable_id = params[:comment][:commentable_id]
147
-
148
- @commentable = commentable_klass.where(id: commentable_id).first
149
- return render(json: { errors: ['Commentable object is undefined'] }) unless @commentable
150
- end
151
-
152
- def comment_params
153
- params
154
- .require(:comment)
155
- .permit(:title, :contacts, :raw_content, :parent_id)
156
- .merge(user: current_user, view_token: comments_view_token)
157
- .merge(denormalized_fields)
158
- .merge( tolerance_time: params[:tolerance_time].to_i )
159
- .merge(request_data_for_black_lists)
160
- end
161
-
162
- def patch_comment_params
163
- params
164
- .require(:comment)
165
- .permit(:title, :contacts, :raw_content, :parent_id)
166
- end
167
-
168
- # Protection tricks
169
- def cookies_required
170
- unless cookies[:the_comment_cookies] == TheCommentsController::COMMENTS_COOKIES_TOKEN
171
- @errors << [t('the_comments.cookies'), t('the_comments.cookies_required')].join(' ')
172
- return render(json: { errors: @errors })
173
- end
174
- end
175
-
176
- def ajax_requests_required
177
- unless request.xhr?
178
- IpBlackList.where(ip: request.ip).first_or_create.increment!(:count)
179
- UserAgentBlackList.where(user_agent: request.user_agent).first_or_create.increment!(:count)
180
- return render(text: t('the_comments.ajax_requests_required'))
181
- end
182
- end
183
-
184
- def empty_trap_required
185
- # TODO: 1) inject ?, 2) fields can be removed on client site
186
- is_user = true
187
- params.slice(*TheComments.config.empty_inputs).values.each{|v| is_user = is_user && v.blank? }
188
-
189
- unless is_user
190
- IpBlackList.where(ip: request.ip).first_or_create.increment!(:count)
191
- UserAgentBlackList.where(user_agent: request.user_agent).first_or_create.increment!(:count)
192
- @errors << [t('the_comments.trap'), t('the_comments.trap_message')].join(' ')
193
- return render(json: { errors: @errors })
194
- end
195
- end
196
-
197
- def tolerance_time_required
198
- min_time = TheComments.config.tolerance_time
199
- this_time = params[:tolerance_time].to_i
200
- if this_time < min_time
201
- @errors << [t('the_comments.tolerance_time'), t('the_comments.tolerance_time_message', time: min_time - this_time )].join(' ')
202
- return render(json: { errors: @errors })
203
- end
204
- end
205
-
206
- def stop_black_ip
207
- if IpBlackList.where(ip: request.ip, state: :banned).first
208
- @errors << [t('the_comments.black_ip'), t('the_comments.black_ip_message')].join(' ')
209
- return render(json: { errors: @errors })
210
- end
211
- end
212
-
213
- def stop_black_user_agent
214
- if UserAgentBlackList.where(user_agent: request.user_agent, state: :banned).first
215
- @errors << [t('the_comments.black_user_agent'), t('the_comments.black_user_agent_message')].join(' ')
216
- return render(json: { errors: @errors })
217
- end
218
- end
219
-
220
- def time_tolerance_required
221
- if params[:time_tolerance].to_i < TheComments.config.tolerance_time
222
- errors = {}
223
- errors[t('the_comments.time_tolerance')] = [t('the_comments.time_tolerance_message')]
224
- return render(json: { errors: errors })
225
- end
226
- end
227
-
228
- end#Base
229
- end
@@ -1,17 +0,0 @@
1
- module TheCommentsIpController
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- def index
6
- @ip_black_lists = if params[:ip]
7
- IpBlackList.where(ip: params[:ip])
8
- else
9
- IpBlackList.order('count DESC').page(params[:page])
10
- end
11
- end
12
-
13
- def to_state
14
- return render text: IpBlackList.where(id: params[:ip_black_list_id]).first.update!(state: params[:state])
15
- end
16
- end
17
- end
@@ -1,15 +0,0 @@
1
- module TheCommentsUserAgentController
2
- # extend ActiveSupport::Concern
3
- # included do; end
4
- def index
5
- @ip_black_lists = if params[:ip]
6
- UserAgentBlackList.where(ip: params[:ip])
7
- else
8
- UserAgentBlackList.order('count DESC').page(params[:page])
9
- end
10
- end
11
-
12
- def to_state
13
- return render text: UserAgentBlackList.where(id: params[:user_agent_black_list_id]).first.update!(state: params[:state])
14
- end
15
- end