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.
- checksums.yaml +4 -4
- data/README.md +104 -20
- data/app/assets/javascripts/the_comments.js.coffee +7 -6
- data/app/assets/stylesheets/the_comments.css.scss +11 -8
- data/app/controllers/concerns/{controller.rb → the_comments/controller.rb} +29 -48
- data/app/controllers/concerns/the_comments/view_token.rb +20 -0
- data/app/models/concerns/{comment.rb → the_comments/comment.rb} +22 -9
- data/app/models/concerns/{comment_states.rb → the_comments/comment_states.rb} +2 -8
- data/app/models/concerns/{commentable.rb → the_comments/commentable.rb} +0 -0
- data/app/models/concerns/{user.rb → the_comments/user.rb} +6 -2
- data/app/views/the_comments/haml/_additional_info.html.haml +1 -1
- data/app/views/the_comments/haml/_comment_body.html.haml +7 -2
- data/app/views/the_comments/haml/_comment_edit.html.haml +1 -1
- data/app/views/the_comments/haml/_form.html.haml +4 -23
- data/app/views/the_comments/haml/_guest_form.html.haml +22 -0
- data/app/views/the_comments/haml/_logined_form.html.haml +18 -0
- data/app/views/the_comments/haml/_manage_controls.html.haml +20 -17
- data/app/views/the_comments/haml/_sidebar.html.haml +6 -25
- data/app/views/the_comments/haml/_sidebar_admin.html.haml +12 -0
- data/app/views/the_comments/haml/_sidebar_backlink.html.haml +3 -0
- data/app/views/the_comments/haml/_sidebar_user.html.haml +29 -0
- data/app/views/the_comments/haml/_tree.html.haml +13 -1
- data/app/views/the_comments/haml/manage.html.haml +8 -7
- data/app/views/the_comments/slim/_comment_body.html.slim +5 -1
- data/app/views/the_comments/slim/_form.html.slim +4 -23
- data/app/views/the_comments/slim/_guest_form.html.slim +22 -0
- data/app/views/the_comments/slim/_logined_form.html.slim +18 -0
- data/app/views/the_comments/slim/_manage_controls.html.slim +19 -16
- data/app/views/the_comments/slim/_sidebar.html.slim +6 -25
- data/app/views/the_comments/slim/_sidebar_admin.html.slim +12 -0
- data/app/views/the_comments/slim/_sidebar_backlink.html.slim +3 -0
- data/app/views/the_comments/slim/_sidebar_user.html.slim +29 -0
- data/app/views/the_comments/slim/_tree.html.slim +13 -1
- data/app/views/the_comments/slim/index.html.slim +2 -2
- data/app/views/the_comments/slim/manage.html.slim +7 -6
- data/config/initializers/the_comments.rb +0 -1
- data/config/locales/ru.yml +14 -10
- data/config/routes.rb +4 -2
- data/docs/whats_wrong_with_other_gems.md +13 -13
- data/docs/where_is_example_application.md +3 -3
- data/gem_version.rb +2 -2
- data/lib/the_comments.rb +26 -7
- data/lib/the_comments/config.rb +1 -4
- data/spec/dummy_app/Gemfile +2 -2
- data/spec/dummy_app/config/routes.rb +1 -0
- data/spec/dummy_app/spec/models/user_counters_spec.rb +5 -5
- data/the_comments.gemspec +3 -2
- data/views_converter.rb +2 -2
- metadata +49 -26
- data/app/views/the_comments/haml/index.html.haml +0 -18
- data/app/views/the_comments/haml/my_comments.html.haml +0 -28
@@ -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.avatar.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,24 +1,27 @@
|
|
1
1
|
- hidden = "display:none"
|
2
2
|
|
3
3
|
.row.controls
|
4
|
-
.col-md-9
|
5
|
-
= link_to
|
6
|
-
|
4
|
+
.col-md-9.action_btns
|
5
|
+
= link_to '#', class: "edit btn btn-success" do
|
6
|
+
= t('the_comments.edit')
|
7
7
|
|
8
|
-
|
9
|
-
|
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.
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
@@ -1,28 +1,9 @@
|
|
1
|
-
-
|
2
|
-
|
3
|
-
.panel.panel-primary
|
1
|
+
.panel.panel-default
|
4
2
|
.panel-heading= t "the_comments.nav.header"
|
5
3
|
.panel-body
|
6
|
-
|
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/slim/sidebar_backlink'
|
21
5
|
|
22
|
-
- if
|
23
|
-
|
24
|
-
|
25
|
-
|
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/slim/sidebar_admin'
|
8
|
+
- else
|
9
|
+
= render partial: 'the_comments/slim/sidebar_user'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
- cuser = current_user
|
2
|
+
|
3
|
+
= render partial: 'the_comments/slim/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,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.comments_on?
|
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 — Комментарий можно оставить <b>без регистрации</b>, для этого достаточно заполнить одно обязательное поле <b class='nobr'>Текст комментария</b>. Анонимные комментарии проходят модерацию и до момента одобрения видны только в браузере автора
|
11
|
+
p — Комментарии зарегистрированных пользователей публикуются сразу после создания
|
12
|
+
|
1
13
|
.comments#comments
|
2
|
-
ol.comments_tree
|
14
|
+
ol.comments_tree data: { comments: { tolarance_time: TheComments.config.tolerance_time } }
|
3
15
|
= render partial: 'the_comments/slim/comment', locals: { tree: comments_tree }
|
4
16
|
= render partial: 'the_comments/slim/form', locals: { commentable: commentable }
|
@@ -9,9 +9,9 @@
|
|
9
9
|
|
10
10
|
.comments
|
11
11
|
- @comments.each do |comment|
|
12
|
-
- klass = { published: :
|
12
|
+
- klass = { published: :success, draft: :info, deleted: :danger }[comment.state.to_sym]
|
13
13
|
.panel class: "panel-#{klass}"
|
14
|
-
.panel-heading= comment.
|
14
|
+
.panel-heading= comment.header_title
|
15
15
|
.panel-body
|
16
16
|
= render partial: 'the_comments/slim/comment_body', locals: { comment: comment }
|
17
17
|
|
@@ -12,14 +12,15 @@
|
|
12
12
|
|
13
13
|
.comments
|
14
14
|
- @comments.each do |comment|
|
15
|
-
- klass = { published: :
|
15
|
+
- klass = { published: :success, draft: :info, deleted: :danger }[comment.state.to_sym]
|
16
16
|
.panel class: "panel-#{klass}"
|
17
|
-
.panel-heading= comment.
|
17
|
+
.panel-heading= comment.header_title
|
18
18
|
.panel-body
|
19
|
-
= render partial: 'the_comments/slim/comment_edit', locals: { comment: comment }
|
20
19
|
= render partial: 'the_comments/slim/comment_body', locals: { comment: comment }
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
- if current_user.comments_admin?
|
22
|
+
= render partial: 'the_comments/slim/comment_edit', locals: { comment: comment }
|
23
|
+
= render partial: 'the_comments/slim/manage_controls', locals: { comment: comment }
|
24
|
+
= render partial: 'the_comments/slim/additional_info', locals: { comment: comment }
|
25
|
+
|
25
26
|
= paginate @comments
|
data/config/locales/ru.yml
CHANGED
@@ -12,16 +12,18 @@ ru:
|
|
12
12
|
|
13
13
|
the_comments:
|
14
14
|
incoming: "Входящие:"
|
15
|
-
in_system: "Все в системе:"
|
16
|
-
written_by_me: "
|
15
|
+
in_system: "Все в системе: %{num}"
|
16
|
+
written_by_me: "Написаны мной: %{num}"
|
17
|
+
for_my_posts: "К моим постам: %{num}"
|
17
18
|
back_to_root: "← На главную"
|
18
|
-
|
19
|
-
my_comments: "Мои комментарии (%{num})"
|
20
|
-
draft_comments: "Новые (%{num})"
|
21
|
-
published_comments: "Опубликованные (%{num})"
|
22
|
-
deleted_comments: "Удаленные (%{num})"
|
23
|
-
spam_comments: "Спам (%{num})"
|
24
19
|
|
20
|
+
my_comments: "Мои комментарии %{num}"
|
21
|
+
draft_comments: "На модерации: %{num}"
|
22
|
+
published_comments: "Опубликованы: %{num}"
|
23
|
+
deleted_comments: "Удалены: %{num}"
|
24
|
+
spam_comments: "Спам: %{num}"
|
25
|
+
|
26
|
+
waiting_for_moderation: Комментарий ожидает проверки
|
25
27
|
management: Управление комментариями
|
26
28
|
new: "Написать новый комментарий"
|
27
29
|
update: "Обновить"
|
@@ -43,7 +45,9 @@ ru:
|
|
43
45
|
no_comments_here: Здесь нет комментариев
|
44
46
|
|
45
47
|
nav:
|
46
|
-
header:
|
48
|
+
header: Комментарии
|
49
|
+
to_root: На главную
|
50
|
+
all_incoming: Все входящие
|
47
51
|
|
48
52
|
form:
|
49
53
|
title: "Ваше имя:"
|
@@ -64,4 +68,4 @@ ru:
|
|
64
68
|
delete_confirm: Вы уверены?
|
65
69
|
waiting_for_moderation: Ожидает модерации
|
66
70
|
ajax_requests_required: 'Извините, ожидается JavaScript/Ajax запрос'
|
67
|
-
undefined_commentable: Комментируемый объект не определен
|
71
|
+
undefined_commentable: Комментируемый объект не определен
|
data/config/routes.rb
CHANGED
@@ -3,10 +3,12 @@ module TheComments
|
|
3
3
|
def call mapper, options = {}
|
4
4
|
mapper.collection do
|
5
5
|
mapper.get :manage
|
6
|
+
mapper.get :my_comments
|
6
7
|
|
7
8
|
mapper.get :my_draft
|
8
9
|
mapper.get :my_published
|
9
|
-
mapper.get :
|
10
|
+
mapper.get :my_deleted
|
11
|
+
mapper.get :my_spam
|
10
12
|
|
11
13
|
mapper.get :draft
|
12
14
|
mapper.get :published
|
@@ -33,4 +35,4 @@ module TheComments
|
|
33
35
|
end
|
34
36
|
end
|
35
37
|
end
|
36
|
-
end
|
38
|
+
end
|
@@ -2,27 +2,27 @@
|
|
2
2
|
|
3
3
|
### What's wrong with other gems?
|
4
4
|
|
5
|
-
|
5
|
+
Take a look at [Ruby-Toolbox](https://www.ruby-toolbox.com/categories/rails_comments). What can we see?
|
6
6
|
|
7
|
-
* [Acts as commentable with threading](https://github.com/elight/acts_as_commentable_with_threading) -
|
8
|
-
* [acts_as_commentable](https://github.com/jackdempsey/acts_as_commentable) -
|
9
|
-
* [opinio](https://github.com/Draiken/opinio) -
|
10
|
-
* [has_threaded_comments](https://github.com/aarongough/has_threaded_comments) -
|
7
|
+
* [Acts as commentable with threading](https://github.com/elight/acts_as_commentable_with_threading) - Where is the render helper for the tree? There is no helper! Am I supposed to write a render helper for the tree myself? Nooooo!!! I'm sorry, I can't use this gem.
|
8
|
+
* [acts_as_commentable](https://github.com/jackdempsey/acts_as_commentable) - I can see the code for models. But I can't see the code for controllers and views. Unfortunately, there is no threading. This isn't enough for me.
|
9
|
+
* [opinio](https://github.com/Draiken/opinio) - Better, but still no threading. I can do better!
|
10
|
+
* [has_threaded_comments](https://github.com/aarongough/has_threaded_comments) - A solid gem. Has model, controller and view helpers for tree rendering! **But** last activity was 2 years ago, it still needs a few features - I can do better.
|
11
11
|
|
12
|
-
### Why TheComments
|
12
|
+
### Why is TheComments better than other gems?
|
13
13
|
|
14
14
|
1. TheComments allows for threaded comments
|
15
15
|
2. **Only TheComments has special helper for tree rendering** (based on [TheSortableTree](https://github.com/the-teacher/the_sortable_tree)).
|
16
|
-
3. TheComments designed to reduce requests
|
17
|
-
4. TheComments has solution for [building
|
18
|
-
5. TheComments designed for text preprocessors (Textile, Markdown, Sanitize, Coderay etc.)
|
19
|
-
6. TheComments has admin UI based on bootstrap 3
|
20
|
-
7. TheComments is "all-in-one"
|
16
|
+
3. TheComments is designed to reduce database requests. Helpful for cache counters.
|
17
|
+
4. TheComments has a solution for [building Recent Comments](https://github.com/the-teacher/the_comments/blob/master/docs/denormalization_and_recent_comments.md) (for polymorphic relations)
|
18
|
+
5. TheComments is designed for text preprocessors (Textile, Markdown, Sanitize, Coderay etc.)
|
19
|
+
6. TheComments has an admin UI based on bootstrap 3
|
20
|
+
7. TheComments is an "all-in-one" solution.<br>
|
21
21
|
It has: Models and Controllers logic (via concerns), Generators, Views, Helper for fast Tree rendering and Admin UI.
|
22
|
-
8. I'll try to help you via skype: **ilya.killich
|
22
|
+
8. If you have problems with TheComments, I'll try to help you via skype: **ilya.killich**
|
23
23
|
|
24
24
|
### TheComments based on:
|
25
25
|
|
26
26
|
1. [AwesomeNestedSet](https://github.com/collectiveidea/awesome_nested_set) - for comments threading
|
27
27
|
2. [TheSortableTree](https://github.com/the-teacher/the_sortable_tree) - for fast rendering of comments tree
|
28
|
-
3. [State Machine](https://github.com/pluginaweek/state_machine) - to provide easy and correct recalculation cache counters on states transitions
|
28
|
+
3. [State Machine](https://github.com/pluginaweek/state_machine) - to provide easy and correct recalculation cache counters on states transitions
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
### Dummy Application
|
4
4
|
|
5
|
-
|
5
|
+
TheComments repository contains a dummy application for development and testing.
|
6
6
|
|
7
7
|
It's here: [Dummy App](https://github.com/the-teacher/the_comments/tree/master/spec/dummy_app)
|
8
8
|
|
9
|
-
|
9
|
+
To run the dummy app:
|
10
10
|
|
11
11
|
```ruby
|
12
12
|
git clone https://github.com/the-teacher/the_comments.git
|
@@ -22,7 +22,7 @@ rails s -p 3000 -b localhost
|
|
22
22
|
|
23
23
|
### Run tests
|
24
24
|
|
25
|
-
|
25
|
+
To run the RSPEC tests:
|
26
26
|
|
27
27
|
```ruby
|
28
28
|
git clone https://github.com/the-teacher/the_comments.git
|
data/gem_version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module TheComments
|
2
|
-
VERSION = "2.
|
3
|
-
end
|
2
|
+
VERSION = "2.3.1"
|
3
|
+
end
|
data/lib/the_comments.rb
CHANGED
@@ -1,19 +1,38 @@
|
|
1
1
|
require 'state_machine'
|
2
|
+
require 'state_machine/version'
|
3
|
+
|
4
|
+
require 'the_simple_sort'
|
2
5
|
require 'the_sortable_tree'
|
3
6
|
|
4
7
|
require 'the_comments/config'
|
5
8
|
require 'the_comments/version'
|
6
9
|
|
7
|
-
_root_ = File.expand_path('../../', __FILE__)
|
8
|
-
|
9
10
|
module TheComments
|
10
|
-
|
11
|
+
COMMENTS_COOKIES_TOKEN = 'JustTheCommentsCookies'
|
12
|
+
|
13
|
+
class Engine < Rails::Engine
|
14
|
+
config.autoload_paths += Dir["#{config.root}/app/controllers/concerns/**/"]
|
15
|
+
config.autoload_paths += Dir["#{config.root}/app/models/concerns/**/"]
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
19
|
# Loading of concerns
|
20
|
+
_root_ = File.expand_path('../../', __FILE__)
|
14
21
|
require "#{_root_}/config/routes.rb"
|
15
|
-
require "#{_root_}/app/controllers/concerns/controller.rb"
|
16
22
|
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
if StateMachine::VERSION.to_f <= 1.2
|
24
|
+
puts '~' * 50
|
25
|
+
puts 'TheComments'
|
26
|
+
puts '~' * 50
|
27
|
+
puts 'WARNING!'
|
28
|
+
puts 'StateMachine patch for Rails4 will be applied'
|
29
|
+
puts
|
30
|
+
puts '> private method *around_validation* from StateMachine::Integrations::ActiveModel will be public'
|
31
|
+
puts
|
32
|
+
puts 'https://github.com/pluginaweek/state_machine/issues/295'
|
33
|
+
puts 'https://github.com/pluginaweek/state_machine/issues/251'
|
34
|
+
puts '~' * 50
|
35
|
+
module StateMachine::Integrations::ActiveModel
|
36
|
+
public :around_validation
|
37
|
+
end
|
38
|
+
end
|
data/lib/the_comments/config.rb
CHANGED
@@ -19,8 +19,7 @@ module TheComments
|
|
19
19
|
:default_title,
|
20
20
|
:template_engine,
|
21
21
|
:empty_trap_protection,
|
22
|
-
:tolerance_time_protection
|
23
|
-
:delete_descendants_on_node_delete
|
22
|
+
:tolerance_time_protection
|
24
23
|
end
|
25
24
|
|
26
25
|
configure do |config|
|
@@ -34,7 +33,5 @@ module TheComments
|
|
34
33
|
|
35
34
|
config.empty_trap_protection = true
|
36
35
|
config.tolerance_time_protection = true
|
37
|
-
|
38
|
-
config.delete_descendants_on_node_delete = true
|
39
36
|
end
|
40
37
|
end
|
data/spec/dummy_app/Gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
# Base gems
|
4
|
-
gem 'rails', '4.
|
4
|
+
gem 'rails', '4.1.4 ' #github: 'rails/rails', branch: 'master'
|
5
5
|
gem 'sqlite3'
|
6
6
|
|
7
7
|
gem 'jquery-rails'
|
@@ -40,4 +40,4 @@ group :development, :test do
|
|
40
40
|
gem 'rspec-rails', '~> 2.0'
|
41
41
|
|
42
42
|
# gem 'database_cleaner'
|
43
|
-
end
|
43
|
+
end
|