commontator 6.1.0 → 6.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -5
- data/app/assets/config/commontator/manifest.js +3 -0
- data/app/assets/stylesheets/commontator/application.scss +1 -1
- data/app/models/commontator/thread.rb +11 -1
- data/app/views/commontator/threads/_reply.html.erb +2 -2
- data/app/views/commontator/threads/_show.html.erb +2 -2
- data/config/initializers/commontator.rb +2 -2
- data/db/migrate/{0_install_commontator.rb → 10_install_commontator.rb} +4 -4
- data/db/migrate/{1_add_replying_to_comments.rb → 11_add_replying_to_comments.rb} +1 -1
- data/lib/commontator/acts_as_commontable.rb +7 -4
- data/lib/commontator/acts_as_commontator.rb +5 -3
- data/lib/commontator/controllers.rb +3 -5
- data/lib/commontator/shared_helper.rb +7 -2
- data/lib/commontator/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bee013bb63d8967e048c353d6f71de9fe0ac5cfd4b40530e065d9cb11f8a14e
|
4
|
+
data.tar.gz: 9fb7f5b8d45b8264235cb77ced85d07dbda0667a2f3aaf03053f67abe0aa75fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ad713e82c9db2b3b64f53ef3baa0b1143ff9fc45f79a8b5964ecfd7c7ce3c4e0f19308e3b234e9dbfcae439d520bb056472d9415bf149831c313d231d4f447f
|
7
|
+
data.tar.gz: b3e80f26aeccdf66161cd509e48f4f78f5c74f2cf9f78dddb387b7c9e37270d124a4e5183ce883912472ab452efc6907a795f80a02e59481da94494b01746c40
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
[![Code Climate](https://codeclimate.com/github/lml/commontator/badges/gpa.svg)](https://codeclimate.com/github/lml/commontator)
|
6
6
|
[![Code Coverage](https://codeclimate.com/github/lml/commontator/badges/coverage.svg)](https://codeclimate.com/github/lml/commontator)
|
7
7
|
|
8
|
-
Commontator is a Rails engine for comments. It is compatible with Rails 5.
|
8
|
+
Commontator is a Rails engine for comments. It is compatible with Rails 5.2+.
|
9
9
|
Being an engine means it is fully functional as soon as you install and
|
10
10
|
configure the gem, providing models, views and controllers of its own.
|
11
11
|
At the same time, almost anything about it can be configured or customized to suit your needs.
|
@@ -22,7 +22,7 @@ Follow the steps below to install Commontator:
|
|
22
22
|
gem 'commontator'
|
23
23
|
```
|
24
24
|
|
25
|
-
You will also need jquery
|
25
|
+
You will also need jquery and a sass compiler, which can be either be installed through
|
26
26
|
the webpacker gem and yarn/npm/bower or through the jquery-rails and sass[c]-rails gems:
|
27
27
|
|
28
28
|
```rb
|
@@ -79,10 +79,19 @@ Follow the steps below to install Commontator:
|
|
79
79
|
|
80
80
|
You can change the mount path if you would like a different one.
|
81
81
|
|
82
|
-
|
82
|
+
### Assets
|
83
83
|
|
84
|
-
|
84
|
+
1. Javascripts
|
85
85
|
|
86
|
+
Make sure your application.js requires jquery and rails-ujs or jquery-ujs:
|
87
|
+
|
88
|
+
Rails 5.1+:
|
89
|
+
```js
|
90
|
+
//= require jquery
|
91
|
+
//= require rails-ujs
|
92
|
+
```
|
93
|
+
|
94
|
+
Rails 5.0:
|
86
95
|
```js
|
87
96
|
//= require jquery
|
88
97
|
// If jquery-ujs was installed through jquery-rails
|
@@ -97,7 +106,7 @@ Follow the steps below to install Commontator:
|
|
97
106
|
//= require commontator/application
|
98
107
|
```
|
99
108
|
|
100
|
-
|
109
|
+
2. Stylesheets
|
101
110
|
|
102
111
|
In order to display comment threads properly, you must
|
103
112
|
require Commontator's application.scss in your `application.[s]css`:
|
@@ -106,6 +115,18 @@ Follow the steps below to install Commontator:
|
|
106
115
|
*= require commontator/application
|
107
116
|
```
|
108
117
|
|
118
|
+
#### Sprockets 4+
|
119
|
+
|
120
|
+
You must require Commontator's manifest.js in your app's manifest.js for images to work properly:
|
121
|
+
|
122
|
+
```js
|
123
|
+
//= link commontator/manifest.js
|
124
|
+
```
|
125
|
+
|
126
|
+
You also need to either add the necessary link tag commands to your layout to load
|
127
|
+
commontator/application.js and commontator/application.css or require them in your app's
|
128
|
+
application.js and application.css like in Sprockets 3.
|
129
|
+
|
109
130
|
## Usage
|
110
131
|
|
111
132
|
Follow the steps below to add Commontator to your models and views:
|
@@ -60,7 +60,17 @@ class Commontator::Thread < ActiveRecord::Base
|
|
60
60
|
|
61
61
|
def comments_with_parent_id(parent_id, show_all)
|
62
62
|
oc = ordered_comments(show_all)
|
63
|
-
|
63
|
+
|
64
|
+
if [ :i, :b ].include?(config.comment_reply_style)
|
65
|
+
# Filter comments by parent_id so we display nested comments
|
66
|
+
oc.where(parent_id: parent_id)
|
67
|
+
elsif parent_id.nil?
|
68
|
+
# Parent is the thread itself and nesting is disabled, so include all comments
|
69
|
+
oc
|
70
|
+
else
|
71
|
+
# Parent is some comment and nesting is disabled, so return nothing
|
72
|
+
oc.none
|
73
|
+
end
|
64
74
|
end
|
65
75
|
|
66
76
|
def paginated_comments(page, parent_id, show_all)
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<% if thread.is_closed? %>
|
9
9
|
<p><%= t 'commontator.thread.status.cannot_post' %></p>
|
10
10
|
<% elsif !user %>
|
11
|
-
<p><%= t 'commontator.require_login'
|
11
|
+
<p><%= t 'commontator.require_login' %></p>
|
12
12
|
<% else %>
|
13
13
|
<% if @commontator_new_comment.nil? %>
|
14
14
|
<div id="commontator-thread-<%= thread.id %>-new-comment-link" class="new-comment">
|
@@ -19,7 +19,7 @@
|
|
19
19
|
<% end %>
|
20
20
|
|
21
21
|
<div id="commontator-thread-<%= thread.id %>-new-comment" class="new-comment<%=
|
22
|
-
@commontator_new_comment.nil? ? ' hidden' : '' %>">
|
22
|
+
@commontator_new_comment.nil? ? ' commontator-hidden' : '' %>">
|
23
23
|
<% unless @commontator_new_comment.nil? %>
|
24
24
|
<%=
|
25
25
|
render partial: 'commontator/comments/form', locals: {
|
@@ -11,7 +11,7 @@
|
|
11
11
|
nested_comments = thread.nested_comments_for(user, comments, show_all)
|
12
12
|
%>
|
13
13
|
|
14
|
-
<div id="commontator-thread-<%= thread.id %>-show" class="show hidden">
|
14
|
+
<div id="commontator-thread-<%= thread.id %>-show" class="show commontator-hidden">
|
15
15
|
<%= link_to t('commontator.thread.actions.show'),
|
16
16
|
'#',
|
17
17
|
id: "commontator-thread-#{thread.id}-show-link" %>
|
@@ -20,7 +20,7 @@
|
|
20
20
|
<div id="commontator-thread-<%= thread.id %>-content" class="content">
|
21
21
|
<div id="commontator-thread-<%= thread.id %>-header" class="header">
|
22
22
|
<span id="commontator-thread-<%= thread.id %>-actions" class="actions">
|
23
|
-
<span id="commontator-thread-<%= thread.id %>-hide" class="hide hidden">
|
23
|
+
<span id="commontator-thread-<%= thread.id %>-hide" class="hide commontator-hidden">
|
24
24
|
<%= link_to t('commontator.thread.actions.hide'),
|
25
25
|
'#',
|
26
26
|
id: "commontator-thread-#{thread.id}-hide-link" %>
|
@@ -254,10 +254,10 @@ Commontator.configure do |config|
|
|
254
254
|
# Returns: the address emails are sent "from" (String)
|
255
255
|
# Important: If using subscriptions, change this to at least match your domain name
|
256
256
|
# Default: ->(thread) do
|
257
|
-
# "no-reply@#{Rails.application.class.
|
257
|
+
# "no-reply@#{Rails.application.class.module_parent.to_s.downcase}.com"
|
258
258
|
# end
|
259
259
|
config.email_from_proc = ->(thread) do
|
260
|
-
"no-reply@#{Rails.application.class.
|
260
|
+
"no-reply@#{Rails.application.class.module_parent.to_s.downcase}.com"
|
261
261
|
end
|
262
262
|
|
263
263
|
# commontable_name_proc
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class InstallCommontator < ActiveRecord::Migration[
|
1
|
+
class InstallCommontator < ActiveRecord::Migration[6.0]
|
2
2
|
def change
|
3
3
|
create_table :commontator_threads do |t|
|
4
4
|
t.references :commontable,
|
@@ -8,7 +8,7 @@ class InstallCommontator < ActiveRecord::Migration[5.2]
|
|
8
8
|
|
9
9
|
t.datetime :closed_at
|
10
10
|
|
11
|
-
t.timestamps
|
11
|
+
t.timestamps
|
12
12
|
end
|
13
13
|
|
14
14
|
create_table :commontator_comments do |t|
|
@@ -24,7 +24,7 @@ class InstallCommontator < ActiveRecord::Migration[5.2]
|
|
24
24
|
t.integer :cached_votes_up, default: 0, index: true
|
25
25
|
t.integer :cached_votes_down, default: 0, index: true
|
26
26
|
|
27
|
-
t.timestamps
|
27
|
+
t.timestamps
|
28
28
|
end
|
29
29
|
|
30
30
|
add_index :commontator_comments, [ :creator_id, :creator_type, :thread_id ],
|
@@ -37,7 +37,7 @@ class InstallCommontator < ActiveRecord::Migration[5.2]
|
|
37
37
|
}
|
38
38
|
t.references :subscriber, polymorphic: true, null: false, index: false
|
39
39
|
|
40
|
-
t.timestamps
|
40
|
+
t.timestamps
|
41
41
|
end
|
42
42
|
|
43
43
|
add_index :commontator_subscriptions, [ :subscriber_id, :subscriber_type, :thread_id ],
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddReplyingToComments < ActiveRecord::Migration[
|
1
|
+
class AddReplyingToComments < ActiveRecord::Migration[6.0]
|
2
2
|
def change
|
3
3
|
add_reference :commontator_comments, :parent, foreign_key: {
|
4
4
|
to_table: :commontator_comments, on_update: :restrict, on_delete: :cascade
|
@@ -17,14 +17,15 @@ module Commontator::ActsAsCommontable
|
|
17
17
|
cattr_accessor :commontable_config
|
18
18
|
self.commontable_config = Commontator::CommontableConfig.new(options)
|
19
19
|
|
20
|
-
has_one :commontator_thread, association_options.merge(
|
20
|
+
has_one :commontator_thread, **association_options.merge(
|
21
21
|
as: :commontable, class_name: 'Commontator::Thread'
|
22
22
|
)
|
23
23
|
|
24
|
-
validates :commontator_thread, presence: true
|
25
|
-
|
26
24
|
prepend Commontator::BuildThread
|
27
25
|
|
26
|
+
# Support creating acts_as_commontable records without a commontator_thread when migrating
|
27
|
+
validates :commontator_thread, presence: true, if: -> { Commontator::Thread.table_exists? }
|
28
|
+
|
28
29
|
self.is_commontable = true
|
29
30
|
end
|
30
31
|
end
|
@@ -33,4 +34,6 @@ module Commontator::ActsAsCommontable
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
|
-
|
37
|
+
ActiveSupport.on_load :active_record do
|
38
|
+
include Commontator::ActsAsCommontable
|
39
|
+
end
|
@@ -16,10 +16,10 @@ module Commontator::ActsAsCommontator
|
|
16
16
|
cattr_accessor :commontator_config
|
17
17
|
self.commontator_config = Commontator::CommontatorConfig.new(options)
|
18
18
|
|
19
|
-
has_many :commontator_comments, association_options.merge(
|
19
|
+
has_many :commontator_comments, **association_options.merge(
|
20
20
|
as: :creator, class_name: 'Commontator::Comment'
|
21
21
|
)
|
22
|
-
has_many :commontator_subscriptions, association_options.merge(
|
22
|
+
has_many :commontator_subscriptions, **association_options.merge(
|
23
23
|
as: :subscriber, class_name: 'Commontator::Subscription'
|
24
24
|
)
|
25
25
|
|
@@ -33,4 +33,6 @@ module Commontator::ActsAsCommontator
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
ActiveSupport.on_load :active_record do
|
37
|
+
include Commontator::ActsAsCommontator
|
38
|
+
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
require_relative 'shared_helper'
|
2
2
|
|
3
3
|
module Commontator::Controllers
|
4
|
-
def self.included(base)
|
5
|
-
base.helper Commontator::SharedHelper
|
6
|
-
end
|
7
|
-
|
8
4
|
def commontator_set_thread_variables
|
9
5
|
return if @commontator_thread.nil? || !@commontator_thread.can_be_read_by?(@commontator_user)
|
10
6
|
|
@@ -31,4 +27,6 @@ module Commontator::Controllers
|
|
31
27
|
end
|
32
28
|
end
|
33
29
|
|
34
|
-
|
30
|
+
ActiveSupport.on_load :action_controller do
|
31
|
+
include Commontator::Controllers
|
32
|
+
end
|
@@ -57,5 +57,10 @@ module Commontator::SharedHelper
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
ActiveSupport.on_load :action_controller do
|
61
|
+
include Commontator::SharedHelper
|
62
|
+
end
|
63
|
+
|
64
|
+
ActiveSupport.on_load :action_controller_base do
|
65
|
+
helper Commontator::SharedHelper
|
66
|
+
end
|
data/lib/commontator/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
COMMONTATOR_VERSION = '6.1
|
1
|
+
COMMONTATOR_VERSION = '6.3.1'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commontator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.1
|
4
|
+
version: 6.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dante Soares
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: will_paginate
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,6 +159,7 @@ extra_rdoc_files: []
|
|
159
159
|
files:
|
160
160
|
- MIT-LICENSE
|
161
161
|
- README.md
|
162
|
+
- app/assets/config/commontator/manifest.js
|
162
163
|
- app/assets/images/commontator/downvote.png
|
163
164
|
- app/assets/images/commontator/downvote_active.png
|
164
165
|
- app/assets/images/commontator/downvote_disabled.png
|
@@ -214,8 +215,8 @@ files:
|
|
214
215
|
- config/locales/ru.yml
|
215
216
|
- config/locales/zh.yml
|
216
217
|
- config/routes.rb
|
217
|
-
- db/migrate/
|
218
|
-
- db/migrate/
|
218
|
+
- db/migrate/10_install_commontator.rb
|
219
|
+
- db/migrate/11_add_replying_to_comments.rb
|
219
220
|
- lib/commontator.rb
|
220
221
|
- lib/commontator/acts_as_commontable.rb
|
221
222
|
- lib/commontator/acts_as_commontator.rb
|
@@ -250,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
251
|
- !ruby/object:Gem::Version
|
251
252
|
version: '0'
|
252
253
|
requirements: []
|
253
|
-
rubygems_version: 3.
|
254
|
+
rubygems_version: 3.2.7
|
254
255
|
signing_key:
|
255
256
|
specification_version: 4
|
256
257
|
summary: Allows users to comment on any model in your application.
|