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,80 @@
1
+ module TheComments
2
+ module CommentStates
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ # :draft | :published | :deleted
7
+ state_machine :state, :initial => TheComments.config.default_state do
8
+
9
+ # events
10
+ event :to_draft do
11
+ transition all - :draft => :draft
12
+ end
13
+
14
+ event :to_published do
15
+ transition all - :published => :published
16
+ end
17
+
18
+ event :to_deleted do
19
+ transition any - :deleted => :deleted
20
+ end
21
+
22
+ # transition callbacks
23
+ after_transition any => any do |comment|
24
+ @comment = comment
25
+ @owner = comment.user
26
+ @holder = comment.holder
27
+ @commentable = comment.commentable
28
+ end
29
+
30
+ # between draft and published
31
+ after_transition [:draft, :published] => [:draft, :published] do |comment, transition|
32
+ from = transition.from_name
33
+ to = transition.to_name
34
+
35
+ if @holder
36
+ @holder.send :try, :define_denormalize_flags
37
+ @holder.increment! "#{to}_comcoms_count"
38
+ @holder.decrement! "#{from}_comcoms_count"
39
+ end
40
+
41
+ if @commentable
42
+ @commentable.send :define_denormalize_flags
43
+ @commentable.increment! "#{to}_comments_count"
44
+ @commentable.decrement! "#{from}_comments_count"
45
+ end
46
+ end
47
+
48
+ # to deleted (cascade like query)
49
+ after_transition [:draft, :published] => :deleted do |comment|
50
+ ids = comment.self_and_descendants.map(&:id)
51
+ ::Comment.where(id: ids).update_all(state: :deleted)
52
+
53
+ @owner.try :recalculate_my_comments_counter!
54
+ @holder.try :recalculate_comcoms_counters!
55
+ @commentable.try :recalculate_comments_counters!
56
+ end
57
+
58
+ # from deleted
59
+ after_transition :deleted => [:draft, :published] do |comment, transition|
60
+ to = transition.to_name
61
+ comment.mark_as_not_spam
62
+
63
+ @owner.try :recalculate_my_comments_counter!
64
+
65
+ if @holder
66
+ @holder.send :try, :define_denormalize_flags
67
+ @holder.decrement! :deleted_comcoms_count
68
+ @holder.increment! "#{to}_comcoms_count"
69
+ end
70
+
71
+ if @commentable
72
+ @commentable.send :define_denormalize_flags
73
+ @commentable.decrement! :deleted_comments_count
74
+ @commentable.increment! "#{to}_comments_count"
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,69 @@
1
+ module TheComments
2
+ module Commentable
3
+
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ has_many :comments, as: :commentable
8
+
9
+ # *define_denormalize_flags* - should be placed before title or url builder filters
10
+ before_validation :define_denormalize_flags
11
+ after_save :denormalize_for_comments, if: -> { !id_changed? }
12
+ end
13
+
14
+ # Default Denormalization methods
15
+ # Overwrite it with your Application
16
+ def commentable_title
17
+ # My first blog post
18
+ try(:title) || TheComments.config.default_title
19
+ end
20
+
21
+ def commentable_url
22
+ # /posts/1
23
+ ['', self.class.to_s.tableize, self.to_param].join('/')
24
+ end
25
+
26
+ def commentable_state
27
+ # 'draft'
28
+ try(:state)
29
+ end
30
+
31
+ # Helper methods
32
+ def comments_sum
33
+ published_comments_count + draft_comments_count
34
+ end
35
+
36
+ def recalculate_comments_counters!
37
+ update_attributes!({
38
+ draft_comments_count: comments.with_state(:draft).count,
39
+ published_comments_count: comments.with_state(:published).count,
40
+ deleted_comments_count: comments.with_state(:deleted).count
41
+ })
42
+ end
43
+
44
+ private
45
+
46
+ def define_denormalize_flags
47
+ @trackable_commentable_title = commentable_title
48
+ @trackable_commentable_state = commentable_state
49
+ @trackable_commentable_url = commentable_url
50
+ end
51
+
52
+ def denormalization_fields_changed?
53
+ a = @trackable_commentable_title != commentable_title
54
+ b = @trackable_commentable_state != commentable_state
55
+ c = @trackable_commentable_url != commentable_url
56
+ a || b || c
57
+ end
58
+
59
+ def denormalize_for_comments
60
+ if denormalization_fields_changed?
61
+ comments.update_all({
62
+ commentable_title: commentable_title,
63
+ commentable_state: commentable_state,
64
+ commentable_url: commentable_url
65
+ })
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,52 @@
1
+ module TheComments
2
+ module User
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ has_many :comcoms, class_name: :Comment, foreign_key: :holder_id
7
+ end
8
+
9
+ def my_comments; ::Comment.where(user: self); end
10
+
11
+ %w[draft published deleted].each do |state|
12
+ define_method "my_#{state}_comments" do
13
+ my_comments.with_state state
14
+ end
15
+
16
+ define_method "#{state}_comcoms" do
17
+ comcoms.with_state state
18
+ end
19
+ end
20
+
21
+ # I think we shouldn't to have my_deleted_comments cache counter
22
+ def recalculate_my_comments_counter!
23
+ dcount = my_draft_comments.count
24
+ pcount = my_published_comments.count
25
+ update_attributes!({
26
+ my_draft_comments_count: dcount,
27
+ my_published_comments_count: pcount,
28
+ my_comments_count: dcount + pcount
29
+ })
30
+ end
31
+
32
+ def recalculate_comcoms_counters!
33
+ update_attributes!({
34
+ draft_comcoms_count: draft_comcoms.count,
35
+ published_comcoms_count: published_comcoms.count,
36
+ deleted_comcoms_count: deleted_comcoms.count
37
+ })
38
+ end
39
+
40
+ def update_comcoms_spam_counter
41
+ update!(spam_comcoms_count: comcoms.where(spam: true).count)
42
+ end
43
+
44
+ def comments_sum
45
+ published_comments_count + draft_comments_count
46
+ end
47
+
48
+ def comcoms_sum
49
+ published_comcoms_count + draft_comcoms_count
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,3 @@
1
+ <%= render partial: "the_comments/#{TheComments.config.template_engine}/tree",
2
+ locals: { commentable: commentable, comments_tree: comments_tree }
3
+ %>
@@ -0,0 +1,13 @@
1
+ .additional_info{ style: "display:none" }
2
+ %br
3
+ %table.table.table-striped.table-hover
4
+ %tr
5
+ %th Tolerance time:
6
+ %th IP:
7
+ %th User Agent:
8
+ %th Referer:
9
+ %tr
10
+ %td= comment.tolerance_time || :none
11
+ %td= comment.ip
12
+ %td= comment.user_agent
13
+ %td= comment.referer
@@ -0,0 +1,20 @@
1
+ %table.comment_body.table.table-striped.table-hover
2
+ %tr
3
+ %td{ style: "width: 120px;"}
4
+ %b= comment.commentable_type
5
+ &rarr;
6
+ %td
7
+ = link_to comment.commentable_title, comment.commentable_url
8
+ (#{comment.try(:commentable_state)})
9
+ %tr
10
+ %td
11
+ %b= t('the_comments.title')
12
+ %td= comment.title.blank? ? t('the_comments.guest_name') : comment.title
13
+ %tr
14
+ %td
15
+ %b= t('the_comments.contacts')
16
+ %td= comment.contacts
17
+ %tr.success
18
+ %td
19
+ %b= t('the_comments.content')
20
+ %td= comment.content
@@ -0,0 +1,26 @@
1
+ .edit_form{ style: "display:none" }
2
+ = form_for [comments, comment], remote: true, html:{ role: :form } do |f|
3
+ %table.table.table-striped.table-hover
4
+ %tr{ style: "width: 100px;"}
5
+ %td
6
+ %b= comment.commentable_type
7
+ &rarr;
8
+ %td
9
+ = link_to comment.commentable_title, comment.commentable_url
10
+ (#{comment.try(:commentable_state)})
11
+ %tr
12
+ %td
13
+ %b= t('the_comments.title')
14
+ %td= f.text_field :title, class: "form-control"
15
+ %tr
16
+ %td
17
+ %b= t('the_comments.contacts')
18
+ %td= f.text_field :contacts, class: "form-control"
19
+ %tr
20
+ %td
21
+ %b= t('the_comments.content')
22
+ %td= f.text_area :raw_content, class: "form-control", rows: 7
23
+ %tr
24
+ %td
25
+ %td= f.submit t('the_comments.update'), class: "btn btn-success"
26
+ %hr
@@ -1,15 +1,15 @@
1
1
  %h3
2
- = link_to 'New Comment', '#', id: :new_root_comment
2
+ = link_to t('the_comments.new'), '#', id: :new_root_comment
3
3
 
4
- = form_for Comment.new, remote: true, authenticity_token: true do |f|
4
+ = form_for [comments, Comment.new], remote: true, authenticity_token: true do |f|
5
5
  .error_notifier{ style: "display:none" }
6
- %label title:
6
+ %label= t('the_comments.form.title')
7
7
  %p= f.text_field :title
8
8
 
9
- %label contacts:
9
+ %label= t('the_comments.form.contacts')
10
10
  %p= f.text_field :contacts
11
11
 
12
- %label content*:
12
+ %label= t('the_comments.form.content')
13
13
  %p= f.text_area :raw_content
14
14
 
15
15
  %p.trap
@@ -22,4 +22,6 @@
22
22
  = f.hidden_field :commentable_id, value: commentable.id
23
23
  = f.hidden_field :parent_id, class: :parent_id
24
24
 
25
- %p= f.submit 'Create Comment', class: :btn
25
+ %p
26
+ = f.submit t('the_comments.form.create'), class: :btn
27
+ = t('the_comments.form.thank_you')
@@ -0,0 +1,27 @@
1
+ - hidden = "display:none"
2
+
3
+ .row.controls
4
+ .col-md-9
5
+ = link_to t('the_comments.edit'), "#", class: "edit btn btn-success"
6
+ = link_to t('the_comments.cancel'), "#", class: "btn btn-warning edit", style: "display:none"
7
+
8
+ - to_hide = comment.published? ? hidden : nil
9
+ - opts = { remote: true, style: to_hide, method: :post }
10
+ = link_to [comments, :to_published, comment], opts.merge(class: "btn btn-primary to_published") do
11
+ = t('the_comments.to_published')
12
+
13
+ - to_hide = comment.draft? ? hidden : nil
14
+ - opts = { remote: true, style: to_hide, method: :post }
15
+ = link_to [comments, :to_draft, comment], opts.merge(class: "btn btn-warning to_draft") do
16
+ = t('the_comments.to_draft')
17
+
18
+ - to_hide = comment.deleted? ? hidden : nil
19
+ - opts = { remote: true, style: to_hide, method: :delete, data: { confirm: t('the_comments.delete_confirm') } }
20
+ = link_to [comments, :to_deleted, comment], opts.merge(class: "btn btn-danger to_deleted") do
21
+ = t('the_comments.to_deleted')
22
+
23
+ - opts = { remote: true, method: :post}
24
+ = link_to [comments, :to_spam, comment], opts.merge(class: "btn btn-danger to_spam") do
25
+ = t('the_comments.to_spam')
26
+ .col-md-3.text-right
27
+ = link_to t('the_comments.additional_info'), "#", class: "additional_info btn btn-info"
@@ -0,0 +1,28 @@
1
+ - cuser = current_user
2
+
3
+ .panel.panel-primary
4
+ .panel-heading= t "the_comments.nav.header"
5
+ .panel-body
6
+ %p= link_to raw(t('the_comments.back_to_root')), '/'
7
+ %hr
8
+
9
+ %h5= t 'the_comments.incoming'
10
+ %ul
11
+ %li= link_to t("the_comments.draft_comments", num: cuser.draft_comcoms_count), [comments, :draft, :comments]
12
+ %li= link_to t("the_comments.published_comments", num: cuser.published_comcoms_count), [comments, :published, :comments]
13
+ %li= link_to t("the_comments.deleted_comments", num: cuser.deleted_comcoms_count), [comments, :deleted, :comments]
14
+ %li= link_to t("the_comments.spam_comments", num: cuser.spam_comcoms_count), [comments, :spam, :comments]
15
+
16
+ %h5= t 'the_comments.written_by_me'
17
+ %ul
18
+ %li= link_to t("the_comments.draft_comments", num: cuser.my_draft_comments.count), [comments, :my_draft, :comments]
19
+ %li= link_to t("the_comments.published_comments", num: cuser.my_published_comments.count), [comments, :my_published, :comments]
20
+ %li= link_to t("the_comments.my_comments", num: cuser.my_comments_count), [comments, :my_comments, :comments]
21
+
22
+ - if cuser.comments_admin?
23
+ %h5= t 'the_comments.in_system'
24
+ %ul
25
+ %li= link_to t("the_comments.draft_comments", num: Comment.with_state(:draft).count), [comments, :total_draft, :comments]
26
+ %li= link_to t("the_comments.published_comments", num: Comment.with_state(:published).count), [comments, :total_published, :comments]
27
+ %li= link_to t("the_comments.deleted_comments", num: Comment.with_state(:deleted).count), [comments, :total_deleted, :comments]
28
+ %li= link_to t("the_comments.spam_comments", num: Comment.where(spam: true).count), [comments, :total_spam, :comments]
@@ -0,0 +1,4 @@
1
+ .comments#comments
2
+ %ol.comments_tree{ data: { comments: { tolarance_time: TheComments.config.tolerance_time } } }
3
+ = render partial: 'the_comments/haml/comment', locals: { tree: comments_tree }
4
+ = render partial: 'the_comments/haml/form', locals: { commentable: commentable }
@@ -0,0 +1,18 @@
1
+ - content_for :title do
2
+ = t "the_comments.management"
3
+
4
+ - content_for :comments_sidebar do
5
+ = render partial: 'the_comments/haml/sidebar'
6
+
7
+ - content_for :comments_main do
8
+ = paginate @comments
9
+
10
+ .comments
11
+ - @comments.each do |comment|
12
+ - klass = { published: :primary, draft: :warning, deleted: :danger }[comment.state.to_sym]
13
+ .panel{ class: "panel-#{klass}" }
14
+ .panel-heading= comment.title
15
+ .panel-body
16
+ = render partial: 'the_comments/haml/comment_body', locals: { comment: comment }
17
+
18
+ = paginate @comments
@@ -0,0 +1,25 @@
1
+ - content_for :title do
2
+ = t "the_comments.management"
3
+
4
+ - content_for :comments_sidebar do
5
+ = render partial: 'the_comments/haml/sidebar'
6
+
7
+ - content_for :comments_main do
8
+ = paginate @comments
9
+
10
+ - if @comments.blank?
11
+ .alert.alert-info= t 'the_comments.no_comments_here'
12
+
13
+ .comments
14
+ - @comments.each do |comment|
15
+ - klass = { published: :primary, draft: :warning, deleted: :danger }[comment.state.to_sym]
16
+ .panel{ class: "panel-#{klass}" }
17
+ .panel-heading= comment.title
18
+ .panel-body
19
+ = render partial: 'the_comments/haml/comment_edit', locals: { comment: comment }
20
+ = render partial: 'the_comments/haml/comment_body', locals: { comment: comment }
21
+
22
+ = render partial: 'the_comments/haml/manage_controls', locals: { comment: comment }
23
+ = render partial: 'the_comments/haml/additional_info', locals: { comment: comment }
24
+
25
+ = paginate @comments
@@ -0,0 +1,28 @@
1
+ - cuser = current_user
2
+
3
+ - content_for :title do
4
+ = t "the_comments.management"
5
+
6
+ - content_for :comments_sidebar do
7
+ = render partial: 'the_comments/haml/sidebar'
8
+
9
+ - content_for :comments_main do
10
+ = paginate @comments
11
+
12
+ - if @comments.blank?
13
+ .alert.alert-info= t 'the_comments.no_comments_here'
14
+
15
+ .comments
16
+ - @comments.each do |comment|
17
+ - klass = { published: :primary, draft: :warning, deleted: :danger }[comment.state.to_sym]
18
+ .panel{ class: "panel-#{klass}" }
19
+ .panel-heading= comment.title
20
+ .panel-body
21
+ = render partial: 'the_comments/haml/comment_body', locals: { comment: comment }
22
+
23
+ - if cuser.comments_admin?
24
+ = render partial: 'the_comments/haml/comment_edit', locals: { comment: comment }
25
+ = render partial: 'the_comments/haml/manage_controls', locals: { comment: comment }
26
+ = render partial: 'the_comments/haml/additional_info', locals: { comment: comment }
27
+
28
+ = paginate @comments
@@ -0,0 +1,13 @@
1
+ .additional_info style: "display:none"
2
+ br
3
+ table.table.table-striped.table-hover
4
+ tr
5
+ th Tolerance time:
6
+ th IP:
7
+ th User Agent:
8
+ th Referer:
9
+ tr
10
+ td= comment.tolerance_time || :none
11
+ td= comment.ip
12
+ td= comment.user_agent
13
+ td= comment.referer
@@ -0,0 +1 @@
1
+ = build_server_tree(tree, render_module: RenderCommentsTreeHelper, controller: controller)
@@ -0,0 +1,20 @@
1
+ table.comment_body.table.table-striped.table-hover
2
+ tr
3
+ td style: "width: 120px;"
4
+ b= comment.commentable_type
5
+ | &rarr;
6
+ td
7
+ = link_to comment.commentable_title, comment.commentable_url
8
+ | (#{comment.try(:commentable_state)})
9
+ tr
10
+ td
11
+ b= t('the_comments.title')
12
+ td= comment.title.blank? ? t('the_comments.guest_name') : comment.title
13
+ tr
14
+ td
15
+ b= t('the_comments.contacts')
16
+ td= comment.contacts
17
+ tr.success
18
+ td
19
+ b= t('the_comments.content')
20
+ td= comment.content
@@ -0,0 +1,26 @@
1
+ .edit_form style: "display:none"
2
+ = form_for [comments, comment], remote: true, html:{ role: :form } do |f|
3
+ table.table.table-striped.table-hover
4
+ tr style: "width: 100px;"
5
+ td
6
+ b= comment.commentable_type
7
+ | &rarr;
8
+ td
9
+ = link_to comment.commentable_title, comment.commentable_url
10
+ | (#{comment.try(:commentable_state)})
11
+ tr
12
+ td
13
+ b= t('the_comments.title')
14
+ td= f.text_field :title, class: "form-control"
15
+ tr
16
+ td
17
+ b= t('the_comments.contacts')
18
+ td= f.text_field :contacts, class: "form-control"
19
+ tr
20
+ td
21
+ b= t('the_comments.content')
22
+ td= f.text_area :raw_content, class: "form-control", rows: 7
23
+ tr
24
+ td
25
+ td= f.submit t('the_comments.update'), class: "btn btn-success"
26
+ hr
@@ -0,0 +1,27 @@
1
+ h3
2
+ = link_to t('the_comments.new'), '#', id: :new_root_comment
3
+
4
+ = form_for [comments, Comment.new], remote: true, authenticity_token: true do |f|
5
+ .error_notifier style: "display:none"
6
+ label= t('the_comments.form.title')
7
+ p= f.text_field :title
8
+
9
+ label= t('the_comments.form.contacts')
10
+ p= f.text_field :contacts
11
+
12
+ label= t('the_comments.form.content')
13
+ p= f.text_area :raw_content
14
+
15
+ p.trap
16
+ - TheComments.config.empty_inputs.each do |name|
17
+ = text_field_tag name, nil, autocomplete: :off, tabindex: -1, id: nil
18
+
19
+ = hidden_field_tag :tolerance_time, 0, id: nil, class: :tolerance_time
20
+
21
+ = f.hidden_field :commentable_type, value: commentable.class
22
+ = f.hidden_field :commentable_id, value: commentable.id
23
+ = f.hidden_field :parent_id, class: :parent_id
24
+
25
+ p
26
+ = f.submit t('the_comments.form.create'), class: :btn
27
+ = t('the_comments.form.thank_you')
@@ -0,0 +1,27 @@
1
+ - hidden = "display:none"
2
+
3
+ .row.controls
4
+ .col-md-9
5
+ = link_to t('the_comments.edit'), "#", class: "edit btn btn-success"
6
+ = link_to t('the_comments.cancel'), "#", class: "btn btn-warning edit", style: "display:none"
7
+
8
+ - to_hide = comment.published? ? hidden : nil
9
+ - opts = { remote: true, style: to_hide, method: :post }
10
+ = link_to [comments, :to_published, comment], opts.merge(class: "btn btn-primary to_published") do
11
+ = t('the_comments.to_published')
12
+
13
+ - to_hide = comment.draft? ? hidden : nil
14
+ - opts = { remote: true, style: to_hide, method: :post }
15
+ = link_to [comments, :to_draft, comment], opts.merge(class: "btn btn-warning to_draft") do
16
+ = t('the_comments.to_draft')
17
+
18
+ - to_hide = comment.deleted? ? hidden : nil
19
+ - opts = { remote: true, style: to_hide, method: :delete, data: { confirm: t('the_comments.delete_confirm') } }
20
+ = link_to [comments, :to_deleted, comment], opts.merge(class: "btn btn-danger to_deleted") do
21
+ = t('the_comments.to_deleted')
22
+
23
+ - opts = { remote: true, method: :post}
24
+ = link_to [comments, :to_spam, comment], opts.merge(class: "btn btn-danger to_spam") do
25
+ = t('the_comments.to_spam')
26
+ .col-md-3.text-right
27
+ = link_to t('the_comments.additional_info'), "#", class: "additional_info btn btn-info"
@@ -0,0 +1,28 @@
1
+ - cuser = current_user
2
+
3
+ .panel.panel-primary
4
+ .panel-heading= t "the_comments.nav.header"
5
+ .panel-body
6
+ p= link_to raw(t('the_comments.back_to_root')), '/'
7
+ hr
8
+
9
+ h5= t 'the_comments.incoming'
10
+ ul
11
+ li= link_to t("the_comments.draft_comments", num: cuser.draft_comcoms_count), [comments, :draft, :comments]
12
+ li= link_to t("the_comments.published_comments", num: cuser.published_comcoms_count), [comments, :published, :comments]
13
+ li= link_to t("the_comments.deleted_comments", num: cuser.deleted_comcoms_count), [comments, :deleted, :comments]
14
+ li= link_to t("the_comments.spam_comments", num: cuser.spam_comcoms_count), [comments, :spam, :comments]
15
+
16
+ h5= t 'the_comments.written_by_me'
17
+ ul
18
+ li= link_to t("the_comments.draft_comments", num: cuser.my_draft_comments.count), [comments, :my_draft, :comments]
19
+ li= link_to t("the_comments.published_comments", num: cuser.my_published_comments.count), [comments, :my_published, :comments]
20
+ li= link_to t("the_comments.my_comments", num: cuser.my_comments_count), [comments, :my_comments, :comments]
21
+
22
+ - if cuser.comments_admin?
23
+ h5= t 'the_comments.in_system'
24
+ ul
25
+ li= link_to t("the_comments.draft_comments", num: Comment.with_state(:draft).count), [comments, :total_draft, :comments]
26
+ li= link_to t("the_comments.published_comments", num: Comment.with_state(:published).count), [comments, :total_published, :comments]
27
+ li= link_to t("the_comments.deleted_comments", num: Comment.with_state(:deleted).count), [comments, :total_deleted, :comments]
28
+ li= link_to t("the_comments.spam_comments", num: Comment.where(spam: true).count), [comments, :total_spam, :comments]
@@ -0,0 +1,4 @@
1
+ .comments#comments
2
+ ol.comments_tree data: { comments: { tolarance_time: TheComments.config.tolerance_time } }
3
+ = render partial: 'the_comments/slim/comment', locals: { tree: comments_tree }
4
+ = render partial: 'the_comments/slim/form', locals: { commentable: commentable }
@@ -0,0 +1,18 @@
1
+ - content_for :title do
2
+ = t "the_comments.management"
3
+
4
+ - content_for :comments_sidebar do
5
+ = render partial: 'the_comments/slim/sidebar'
6
+
7
+ - content_for :comments_main do
8
+ = paginate @comments
9
+
10
+ .comments
11
+ - @comments.each do |comment|
12
+ - klass = { published: :primary, draft: :warning, deleted: :danger }[comment.state.to_sym]
13
+ .panel class: "panel-#{klass}"
14
+ .panel-heading= comment.title
15
+ .panel-body
16
+ = render partial: 'the_comments/slim/comment_body', locals: { comment: comment }
17
+
18
+ = paginate @comments
@@ -0,0 +1,25 @@
1
+ - content_for :title do
2
+ = t "the_comments.management"
3
+
4
+ - content_for :comments_sidebar do
5
+ = render partial: 'the_comments/slim/sidebar'
6
+
7
+ - content_for :comments_main do
8
+ = paginate @comments
9
+
10
+ - if @comments.blank?
11
+ .alert.alert-info= t 'the_comments.no_comments_here'
12
+
13
+ .comments
14
+ - @comments.each do |comment|
15
+ - klass = { published: :primary, draft: :warning, deleted: :danger }[comment.state.to_sym]
16
+ .panel class: "panel-#{klass}"
17
+ .panel-heading= comment.title
18
+ .panel-body
19
+ = render partial: 'the_comments/slim/comment_edit', locals: { comment: comment }
20
+ = render partial: 'the_comments/slim/comment_body', locals: { comment: comment }
21
+
22
+ = render partial: 'the_comments/slim/manage_controls', locals: { comment: comment }
23
+ = render partial: 'the_comments/slim/additional_info', locals: { comment: comment }
24
+
25
+ = paginate @comments