the_comments 2.2.2 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +104 -20
  3. data/app/assets/javascripts/the_comments.js.coffee +7 -6
  4. data/app/assets/stylesheets/the_comments.css.scss +11 -8
  5. data/app/controllers/concerns/{controller.rb → the_comments/controller.rb} +29 -48
  6. data/app/controllers/concerns/the_comments/view_token.rb +20 -0
  7. data/app/models/concerns/{comment.rb → the_comments/comment.rb} +22 -9
  8. data/app/models/concerns/{comment_states.rb → the_comments/comment_states.rb} +2 -8
  9. data/app/models/concerns/{commentable.rb → the_comments/commentable.rb} +0 -0
  10. data/app/models/concerns/{user.rb → the_comments/user.rb} +6 -2
  11. data/app/views/the_comments/haml/_additional_info.html.haml +1 -1
  12. data/app/views/the_comments/haml/_comment_body.html.haml +7 -2
  13. data/app/views/the_comments/haml/_comment_edit.html.haml +1 -1
  14. data/app/views/the_comments/haml/_form.html.haml +4 -23
  15. data/app/views/the_comments/haml/_guest_form.html.haml +22 -0
  16. data/app/views/the_comments/haml/_logined_form.html.haml +18 -0
  17. data/app/views/the_comments/haml/_manage_controls.html.haml +20 -17
  18. data/app/views/the_comments/haml/_sidebar.html.haml +6 -25
  19. data/app/views/the_comments/haml/_sidebar_admin.html.haml +12 -0
  20. data/app/views/the_comments/haml/_sidebar_backlink.html.haml +3 -0
  21. data/app/views/the_comments/haml/_sidebar_user.html.haml +29 -0
  22. data/app/views/the_comments/haml/_tree.html.haml +13 -1
  23. data/app/views/the_comments/haml/manage.html.haml +8 -7
  24. data/app/views/the_comments/slim/_comment_body.html.slim +5 -1
  25. data/app/views/the_comments/slim/_form.html.slim +4 -23
  26. data/app/views/the_comments/slim/_guest_form.html.slim +22 -0
  27. data/app/views/the_comments/slim/_logined_form.html.slim +18 -0
  28. data/app/views/the_comments/slim/_manage_controls.html.slim +19 -16
  29. data/app/views/the_comments/slim/_sidebar.html.slim +6 -25
  30. data/app/views/the_comments/slim/_sidebar_admin.html.slim +12 -0
  31. data/app/views/the_comments/slim/_sidebar_backlink.html.slim +3 -0
  32. data/app/views/the_comments/slim/_sidebar_user.html.slim +29 -0
  33. data/app/views/the_comments/slim/_tree.html.slim +13 -1
  34. data/app/views/the_comments/slim/index.html.slim +2 -2
  35. data/app/views/the_comments/slim/manage.html.slim +7 -6
  36. data/config/initializers/the_comments.rb +0 -1
  37. data/config/locales/ru.yml +14 -10
  38. data/config/routes.rb +4 -2
  39. data/docs/whats_wrong_with_other_gems.md +13 -13
  40. data/docs/where_is_example_application.md +3 -3
  41. data/gem_version.rb +2 -2
  42. data/lib/the_comments.rb +26 -7
  43. data/lib/the_comments/config.rb +1 -4
  44. data/spec/dummy_app/Gemfile +2 -2
  45. data/spec/dummy_app/config/routes.rb +1 -0
  46. data/spec/dummy_app/spec/models/user_counters_spec.rb +5 -5
  47. data/the_comments.gemspec +3 -2
  48. data/views_converter.rb +2 -2
  49. metadata +49 -26
  50. data/app/views/the_comments/haml/index.html.haml +0 -18
  51. data/app/views/the_comments/haml/my_comments.html.haml +0 -28
@@ -0,0 +1,20 @@
1
+ module TheComments
2
+ # Cookies and View token for spam protection
3
+ # include TheComments::ViewToken
4
+ module ViewToken
5
+ extend ActiveSupport::Concern
6
+
7
+ included { before_action :set_the_comments_cookies }
8
+
9
+ def comments_view_token
10
+ cookies[:comments_view_token]
11
+ end
12
+
13
+ private
14
+
15
+ def set_the_comments_cookies
16
+ cookies[:the_comment_cookies] = { value: TheComments::COMMENTS_COOKIES_TOKEN, expires: 1.year.from_now }
17
+ cookies[:comments_view_token] = { value: SecureRandom.hex, expires: 7.days.from_now } unless cookies[:comments_view_token]
18
+ end
19
+ end
20
+ end
@@ -4,16 +4,19 @@ module TheComments
4
4
 
5
5
  included do
6
6
  scope :active, -> { with_state [:draft, :published] }
7
- scope :recent, -> { order('created_at DESC') }
7
+ scope :with_users, -> { includes(:user) }
8
8
 
9
9
  # Nested Set
10
10
  acts_as_nested_set scope: [:commentable_type, :commentable_id]
11
11
 
12
- # Comments State Machine
13
- include TheComments::CommentStates
12
+ # simple sort scopes
13
+ include ::TheSimpleSort::Base
14
14
 
15
15
  # TheSortableTree
16
- include TheSortableTree::Scopes
16
+ include ::TheSortableTree::Scopes
17
+
18
+ # Comments State Machine
19
+ include TheComments::CommentStates
17
20
 
18
21
  validates :raw_content, presence: true
19
22
 
@@ -28,6 +31,14 @@ module TheComments
28
31
  before_save :prepare_content
29
32
  end
30
33
 
34
+ def header_title
35
+ title.present? ? title : I18n.t('the_comments.guest_name')
36
+ end
37
+
38
+ def user_name
39
+ user.try(:username) || user.try(:login) || header_title
40
+ end
41
+
31
42
  def avatar_url
32
43
  src = id.to_s
33
44
  src = title unless title.blank?
@@ -35,7 +46,7 @@ module TheComments
35
46
  hash = Digest::MD5.hexdigest(src)
36
47
  "https://2.gravatar.com/avatar/#{hash}?s=42&d=https://identicons.github.com/#{hash}.png"
37
48
  end
38
-
49
+
39
50
  def mark_as_spam
40
51
  count = self_and_descendants.update_all({spam: true})
41
52
  update_spam_counter
@@ -86,18 +97,20 @@ module TheComments
86
97
  # We have few unuseful requests
87
98
  # I impressed that I found it and reduce DB requests
88
99
  # Awesome logic pazzl! I'm really pedant :D
89
- def update_cache_counters
100
+ def update_cache_counters
90
101
  user.try :recalculate_my_comments_counter!
91
102
 
92
103
  if holder
93
104
  holder.send :try, :define_denormalize_flags
94
- holder.increment! "#{state}_comcoms_count"
105
+ holder.increment! "#{ state }_comcoms_count"
106
+ # holder.class.increment_counter("#{ state }_comcoms_count", holder.id)
95
107
  end
96
108
 
97
109
  if commentable
98
110
  commentable.send :define_denormalize_flags
99
- commentable.increment! "#{state}_comments_count"
111
+ commentable.increment! "#{ state }_comments_count"
112
+ # holder.class.increment_counter("#{ state }_comments_count", holder.id)
100
113
  end
101
114
  end
102
115
  end
103
- end
116
+ end
@@ -47,14 +47,8 @@ module TheComments
47
47
 
48
48
  # to deleted (cascade like query)
49
49
  after_transition [:draft, :published] => :deleted do |comment|
50
-
51
- if TheComments.config.delete_descendants_on_node_delete
52
- ids = comment.self_and_descendants.map(&:id)
53
- ::Comment.where(id: ids).update_all(state: :deleted)
54
- else
55
- id = comment.id
56
- ::Comment.where(id: id).update_all(state: :deleted)
57
- end
50
+ ids = comment.self_and_descendants.map(&:id)
51
+ ::Comment.where(id: ids).update_all(state: :deleted)
58
52
 
59
53
  @owner.try :recalculate_my_comments_counter!
60
54
  @holder.try :recalculate_comcoms_counters!
@@ -1,7 +1,7 @@
1
1
  module TheComments
2
2
  module User
3
3
  extend ActiveSupport::Concern
4
-
4
+
5
5
  included do
6
6
  has_many :comcoms, class_name: :Comment, foreign_key: :holder_id
7
7
  end
@@ -18,6 +18,10 @@ module TheComments
18
18
  end
19
19
  end
20
20
 
21
+ def my_spam_comments
22
+ my_comments.where(spam: true)
23
+ end
24
+
21
25
  # I think we shouldn't to have my_deleted_comments cache counter
22
26
  def recalculate_my_comments_counter!
23
27
  dcount = my_draft_comments.count
@@ -49,4 +53,4 @@ module TheComments
49
53
  published_comcoms_count + draft_comcoms_count
50
54
  end
51
55
  end
52
- end
56
+ end
@@ -10,4 +10,4 @@
10
10
  %td= comment.tolerance_time || :none
11
11
  %td= comment.ip
12
12
  %td= comment.user_agent
13
- %td= comment.referer
13
+ %td= comment.referer
@@ -9,7 +9,11 @@
9
9
  %tr
10
10
  %td
11
11
  %b= t('the_comments.title')
12
- %td= comment.title.blank? ? t('the_comments.guest_name') : comment.title
12
+ %td
13
+ - if comment.try(:user)
14
+ = link_to comment.user_name, comment.user
15
+ - else
16
+ = comment.header_title
13
17
  %tr
14
18
  %td
15
19
  %b= t('the_comments.contacts')
@@ -17,4 +21,5 @@
17
21
  %tr.success
18
22
  %td
19
23
  %b= t('the_comments.content')
20
- %td= comment.content
24
+ %td{ style: 'word-break: break-all;' }= raw comment.content
25
+
@@ -23,4 +23,4 @@
23
23
  %tr
24
24
  %td
25
25
  %td= f.submit t('the_comments.update'), class: "btn btn-success"
26
- %hr
26
+ %hr
@@ -2,26 +2,7 @@
2
2
  = link_to t('the_comments.new'), '#', id: :new_root_comment
3
3
 
4
4
  = form_for 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')
5
+ - if current_user
6
+ = render partial: 'the_comments/haml/logined_form', locals: { f: f, commentable: commentable }
7
+ - else
8
+ = render partial: 'the_comments/haml/guest_form', locals: { f: f, commentable: commentable }
@@ -0,0 +1,22 @@
1
+ %label= t('the_comments.form.title')
2
+ %p= f.text_field :title, class: 'form-control'
3
+
4
+ %label= t('the_comments.form.contacts')
5
+ %p= f.text_field :contacts, class: 'form-control'
6
+
7
+ %label= t('the_comments.form.content')
8
+ %p= f.text_area :raw_content, class: 'form-control'
9
+
10
+ %p.trap
11
+ - TheComments.config.empty_inputs.each do |name|
12
+ = text_field_tag name, nil, autocomplete: :off, tabindex: -1, id: nil
13
+
14
+ = hidden_field_tag :tolerance_time, 0, id: nil, class: :tolerance_time
15
+
16
+ = f.hidden_field :commentable_type, value: commentable.class
17
+ = f.hidden_field :commentable_id, value: commentable.id
18
+ = f.hidden_field :parent_id, class: :parent_id
19
+
20
+ %p
21
+ = f.submit t('the_comments.form.create'), class: :btn
22
+ = t('the_comments.form.thank_you')
@@ -0,0 +1,18 @@
1
+ .logined_comment_form
2
+ .user_data
3
+ = link_to user_path(current_user), nopin: :nopin do
4
+ = image_tag current_user.try(:avatar).try(:url, :thumb)
5
+ .comment_data
6
+ = hidden_field_tag :tolerance_time, 0, id: nil, class: :tolerance_time
7
+ = f.hidden_field :commentable_type, value: commentable.class
8
+ = f.hidden_field :commentable_id, value: commentable.id
9
+ = f.hidden_field :parent_id, class: :parent_id
10
+
11
+ .user_name
12
+ %b= current_user.username.present? ? current_user.username : current_user.login
13
+ %label= t('the_comments.form.content')
14
+ %p= f.text_area :raw_content
15
+
16
+ %p
17
+ = f.submit t('the_comments.form.create'), class: :btn
18
+ = t('the_comments.form.thank_you')
@@ -1,27 +1,30 @@
1
1
  - hidden = "display:none"
2
2
 
3
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"
4
+ .col-md-9.action_btns
5
+ = link_to '#', class: "edit btn btn-success" do
6
+ = t('the_comments.edit')
7
7
 
8
- - to_hide = comment.published? ? hidden : nil
9
- - opts = { remote: true, style: to_hide, method: :post }
10
- = link_to [: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 [:to_draft, comment], opts.merge(class: "btn btn-warning to_draft") do
16
- = t('the_comments.to_draft')
8
+ = link_to '#', class: "btn btn-warning edit", style: "display:none" do
9
+ = t('the_comments.cancel')
17
10
 
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 [:to_deleted, comment], opts.merge(class: "btn btn-danger to_deleted") do
21
- = t('the_comments.to_deleted')
11
+ - unless to_hide = comment.published? ? hidden : nil
12
+ - opts = { remote: true, style: to_hide, method: :post }
13
+ = link_to [:to_published, comment], opts.merge(class: "btn btn-primary to_published") do
14
+ = t('the_comments.to_published')
15
+
16
+ - unless to_hide = comment.draft? ? hidden : nil
17
+ - opts = { remote: true, style: to_hide, method: :post }
18
+ = link_to [:to_draft, comment], opts.merge(class: "btn btn-warning to_draft") do
19
+ = t('the_comments.to_draft')
20
+
21
+ - unless to_hide = comment.deleted? ? hidden : nil
22
+ - opts = { remote: true, style: to_hide, method: :delete, data: { confirm: t('the_comments.delete_confirm') } }
23
+ = link_to [:to_deleted, comment], opts.merge(class: "btn btn-danger to_deleted") do
24
+ = t('the_comments.to_deleted')
22
25
 
23
26
  - opts = { remote: true, method: :post}
24
27
  = link_to [:to_spam, comment], opts.merge(class: "btn btn-danger to_spam") do
25
28
  = t('the_comments.to_spam')
26
29
  .col-md-3.text-right
27
- = link_to t('the_comments.additional_info'), "#", class: "additional_info btn btn-info"
30
+ = link_to t('the_comments.additional_info'), "#", class: "additional_info btn btn-info"
@@ -1,28 +1,9 @@
1
- - cuser = current_user
2
-
3
- .panel.panel-primary
1
+ .panel.panel-default
4
2
  .panel-heading= t "the_comments.nav.header"
5
3
  .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), [:draft, :comments]
12
- %li= link_to t("the_comments.published_comments", num: cuser.published_comcoms_count), [:published, :comments]
13
- %li= link_to t("the_comments.deleted_comments", num: cuser.deleted_comcoms_count), [:deleted, :comments]
14
- %li= link_to t("the_comments.spam_comments", num: cuser.spam_comcoms_count), [: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), [:my_draft, :comments]
19
- %li= link_to t("the_comments.published_comments", num: cuser.my_published_comments.count), [:my_published, :comments]
20
- %li= link_to t("the_comments.my_comments", num: cuser.my_comments_count), [:my_comments, :comments]
4
+ = render partial: 'the_comments/haml/sidebar_backlink'
21
5
 
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), [:total_draft, :comments]
26
- %li= link_to t("the_comments.published_comments", num: Comment.with_state(:published).count), [:total_published, :comments]
27
- %li= link_to t("the_comments.deleted_comments", num: Comment.with_state(:deleted).count), [:total_deleted, :comments]
28
- %li= link_to t("the_comments.spam_comments", num: Comment.where(spam: true).count), [:total_spam, :comments]
6
+ - if current_user.comments_admin?
7
+ = render partial: 'the_comments/haml/sidebar_admin'
8
+ - else
9
+ = render partial: 'the_comments/haml/sidebar_user'
@@ -0,0 +1,12 @@
1
+ - cuser = current_user
2
+
3
+ = render partial: 'the_comments/haml/sidebar_user'
4
+
5
+ - if cuser.comments_admin?
6
+ %br
7
+ %h5= t 'the_comments.in_system', num: Comment.count
8
+ %p= link_to t("the_comments.published_comments", num: Comment.with_state(:published).count), [:total_published, :comments], class: 'btn btn-success btn-sm'
9
+ %p= link_to t("the_comments.draft_comments", num: Comment.with_state(:draft).count), [:total_draft, :comments], class: 'btn btn-info btn-sm'
10
+ %p
11
+ = link_to t("the_comments.deleted_comments", num: Comment.with_state(:deleted).count), [:total_deleted, :comments], class: 'btn btn-default btn-sm'
12
+ = link_to t("the_comments.spam_comments", num: Comment.where(spam: true).count), [:total_spam, :comments], class: 'btn btn-default btn-sm'
@@ -0,0 +1,3 @@
1
+ %p= link_to t('the_comments.nav.to_root'), root_path
2
+ %p= link_to t('the_comments.nav.all_incoming'), manage_comments_url
3
+ %hr
@@ -0,0 +1,29 @@
1
+ - cuser = current_user
2
+
3
+ %h5=t 'the_comments.written_by_me', num: cuser.my_comments.count
4
+
5
+ %p= link_to t("the_comments.published_comments", num: cuser.my_published_comments.count), [:my_published, :comments], class: 'btn btn-success btn-sm'
6
+ %p= link_to t("the_comments.draft_comments", num: cuser.my_draft_comments.count), [:my_draft, :comments], class: 'btn btn-info btn-sm'
7
+
8
+ %p
9
+ - if cuser.comments_admin?
10
+ = link_to t("the_comments.deleted_comments", num: cuser.my_deleted_comments.count), [:my_deleted, :comments], class: 'btn btn-default btn-sm'
11
+ = link_to t("the_comments.spam_comments", num: cuser.my_spam_comments.count), [:my_spam, :comments], class: 'btn btn-default btn-sm'
12
+ - else
13
+ %span.btn.btn-default.btn-sm= t("the_comments.deleted_comments", num: cuser.my_deleted_comments.count)
14
+ %span.btn.btn-default.btn-sm= t("the_comments.spam_comments", num: cuser.my_spam_comments.count)
15
+
16
+ %br
17
+ %h5= t 'the_comments.for_my_posts', num: cuser.comcoms.count
18
+
19
+ %p= link_to t("the_comments.published_comments", num: cuser.published_comcoms_count), [:published, :comments], class: 'btn btn-success btn-sm'
20
+ %p= link_to t("the_comments.draft_comments", num: cuser.draft_comcoms_count), [:draft, :comments], class: 'btn btn-info btn-sm'
21
+ %p
22
+ - if cuser.comments_admin?
23
+ = link_to t("the_comments.deleted_comments", num: cuser.deleted_comcoms_count), [:deleted, :comments], class: 'btn btn-default btn-sm'
24
+ = link_to t("the_comments.spam_comments", num: cuser.spam_comcoms_count), [:spam, :comments], class: 'btn btn-default btn-sm'
25
+ - else
26
+ %span.btn.btn-default.btn-sm= t("the_comments.deleted_comments", num: cuser.deleted_comcoms_count)
27
+ %span.btn.btn-default.btn-sm= t("the_comments.spam_comments", num: cuser.spam_comcoms_count)
28
+
29
+
@@ -1,4 +1,16 @@
1
+ - if commentable.try(:comments_on?) || true
2
+ %h4.comments_sum
3
+ - if commentable.comments_sum.zero?
4
+ Вы можете стать первым, кто оставит комментарий!
5
+ - else
6
+ Комментариев: #{ commentable.comments_sum }
7
+
8
+ - unless current_user
9
+ .comments_description
10
+ %p &mdash; Комментарий можно оставить <b>без регистрации</b>, для этого достаточно заполнить одно обязательное поле <b class='nobr'>Текст комментария</b>. Анонимные комментарии проходят модерацию и до момента одобрения видны только в браузере автора
11
+ %p &mdash; Комментарии зарегистрированных пользователей публикуются сразу после создания
12
+
1
13
  .comments#comments
2
14
  %ol.comments_tree{ data: { comments: { tolarance_time: TheComments.config.tolerance_time } } }
3
15
  = render partial: 'the_comments/haml/comment', locals: { tree: comments_tree }
4
- = render partial: 'the_comments/haml/form', locals: { commentable: commentable }
16
+ = render partial: 'the_comments/haml/form', locals: { commentable: commentable }
@@ -12,14 +12,15 @@
12
12
 
13
13
  .comments
14
14
  - @comments.each do |comment|
15
- - klass = { published: :primary, draft: :warning, deleted: :danger }[comment.state.to_sym]
15
+ - klass = { published: :success, draft: :info, deleted: :danger }[comment.state.to_sym]
16
16
  .panel{ class: "panel-#{klass}" }
17
- .panel-heading= comment.title
17
+ .panel-heading= comment.header_title
18
18
  .panel-body
19
- = render partial: 'the_comments/haml/comment_edit', locals: { comment: comment }
20
19
  = render partial: 'the_comments/haml/comment_body', locals: { comment: comment }
21
20
 
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
21
+ - if current_user.comments_admin?
22
+ = render partial: 'the_comments/haml/comment_edit', locals: { comment: comment }
23
+ = render partial: 'the_comments/haml/manage_controls', locals: { comment: comment }
24
+ = render partial: 'the_comments/haml/additional_info', locals: { comment: comment }
25
+
26
+ = paginate @comments
@@ -9,7 +9,11 @@ table.comment_body.table.table-striped.table-hover
9
9
  tr
10
10
  td
11
11
  b= t('the_comments.title')
12
- td= comment.title.blank? ? t('the_comments.guest_name') : comment.title
12
+ td
13
+ - if comment.try(:user)
14
+ = link_to comment.user_name, comment.user
15
+ - else
16
+ = comment.header_title
13
17
  tr
14
18
  td
15
19
  b= t('the_comments.contacts')
@@ -2,26 +2,7 @@ h3
2
2
  = link_to t('the_comments.new'), '#', id: :new_root_comment
3
3
 
4
4
  = form_for 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')
5
+ - if current_user
6
+ = render partial: 'the_comments/slim/logined_form', locals: { f: f, commentable: commentable }
7
+ - else
8
+ = render partial: 'the_comments/slim/guest_form', locals: { f: f, commentable: commentable }