biovision-comment 0.1.170914 → 0.7.190905.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +68 -14
- data/app/assets/javascripts/biovision/comment/biovision-comments.js +118 -0
- data/app/assets/stylesheets/biovision/comment/comments.scss +111 -38
- data/app/controllers/admin/comments_controller.rb +18 -5
- data/app/controllers/comments_controller.rb +45 -32
- data/app/helpers/comments_helper.rb +20 -0
- data/app/models/comment.rb +88 -19
- data/app/models/concerns/commentable_item.rb +15 -0
- data/app/services/biovision/components/comments_component.rb +39 -0
- data/app/services/comment_handler.rb +49 -0
- data/app/services/comments_manager.rb +24 -0
- data/app/views/admin/comments/entity/_in_list.html.erb +8 -5
- data/app/views/admin/comments/index.html.erb +2 -1
- data/app/views/admin/comments/show.html.erb +25 -10
- data/app/views/admin/components/links/_comments.html.erb +3 -0
- data/app/views/comment_mailer/entry_reply.text.erb +2 -6
- data/app/views/comments/_comment.html.erb +66 -16
- data/app/views/comments/_form.html.erb +92 -19
- data/app/views/comments/_list.html.erb +17 -19
- data/app/views/comments/_reply_container.html.erb +15 -0
- data/app/views/comments/_section.html.erb +34 -0
- data/app/views/comments/edit.html.erb +6 -5
- data/app/views/comments/new.html.erb +2 -2
- data/config/locales/comments-ru.yml +32 -2
- data/config/routes.rb +18 -10
- data/db/migrate/20170914000001_create_comments.rb +48 -23
- data/db/migrate/20190203090909_add_fields_to_comments.rb +14 -0
- data/db/migrate/20190428212121_add_approved_to_comments.rb +14 -0
- data/db/migrate/20190428212122_create_comments_component.rb +21 -0
- data/db/migrate/20190628101010_add_data_to_comments.rb +15 -0
- data/lib/biovision/comment/engine.rb +7 -2
- data/lib/biovision/comment/version.rb +3 -1
- metadata +19 -8
- data/app/views/comments/show.html.erb +0 -27
data/config/routes.rb
CHANGED
@@ -1,17 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Rails.application.routes.draw do
|
2
|
-
resources :comments,
|
4
|
+
resources :comments, only: %i[update destroy]
|
5
|
+
|
6
|
+
scope '/(:locale)', constraints: { locale: /ru|en|sv|cn/ } do
|
7
|
+
resources :comments, only: %i[create edit show] do
|
8
|
+
post 'check', on: :collection
|
9
|
+
end
|
3
10
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
11
|
+
namespace :admin do
|
12
|
+
resources :comments, only: %i[index show] do
|
13
|
+
member do
|
14
|
+
post 'toggle', defaults: { format: :json }
|
15
|
+
put 'lock', defaults: { format: :json }
|
16
|
+
delete 'lock', action: :unlock, defaults: { format: :json }
|
17
|
+
end
|
10
18
|
end
|
11
19
|
end
|
12
|
-
end
|
13
20
|
|
14
|
-
|
15
|
-
|
21
|
+
namespace :my do
|
22
|
+
resources :comments, only: :index
|
23
|
+
end
|
16
24
|
end
|
17
25
|
end
|
@@ -1,31 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Migration for comments table
|
1
4
|
class CreateComments < ActiveRecord::Migration[5.0]
|
2
5
|
def up
|
3
|
-
|
4
|
-
|
5
|
-
t.timestamps
|
6
|
-
t.integer :parent_id
|
7
|
-
t.references :user, foreign_key: true, on_update: :cascade, on_delete: :cascade
|
8
|
-
t.references :agent, foreign_key: true, on_update: :cascade, on_delete: :nullify
|
9
|
-
t.inet :ip
|
10
|
-
t.boolean :visible, default: true, null: false
|
11
|
-
t.boolean :locked, default: false, null: false
|
12
|
-
t.boolean :deleted, default: false, null: false
|
13
|
-
t.integer :upvote_count, default: 0, null: false
|
14
|
-
t.integer :downvote_count, default: 0, null: false
|
15
|
-
t.integer :vote_result, default: 0, null: false
|
16
|
-
t.integer :commentable_id, null: false
|
17
|
-
t.string :commentable_type, null: false
|
18
|
-
t.text :body, null: false
|
19
|
-
end
|
20
|
-
|
21
|
-
add_index :comments, [:commentable_id, :commentable_type]
|
22
|
-
add_foreign_key :comments, :comments, column: :parent_id, on_update: :cascade, on_delete: :cascade
|
23
|
-
end
|
6
|
+
create_component_record
|
7
|
+
create_comments_table unless Comment.table_exists?
|
24
8
|
end
|
25
9
|
|
26
10
|
def down
|
27
|
-
if Comment.table_exists?
|
28
|
-
|
11
|
+
drop_table :comments if Comment.table_exists?
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def create_comments_table
|
17
|
+
create_table :comments, comment: 'Comment for commentable item' do |t|
|
18
|
+
t.timestamps
|
19
|
+
t.integer :parent_id
|
20
|
+
t.references :user, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
21
|
+
t.references :agent, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
22
|
+
t.inet :ip
|
23
|
+
t.boolean :visible, default: true, null: false
|
24
|
+
t.boolean :locked, default: false, null: false
|
25
|
+
t.boolean :deleted, default: false, null: false
|
26
|
+
t.boolean :spam, default: false, null: false
|
27
|
+
t.boolean :approved, default: true, null: false
|
28
|
+
t.integer :upvote_count, default: 0, null: false
|
29
|
+
t.integer :downvote_count, default: 0, null: false
|
30
|
+
t.integer :vote_result, default: 0, null: false
|
31
|
+
t.integer :commentable_id, null: false
|
32
|
+
t.string :commentable_type, null: false
|
33
|
+
t.string :author_name
|
34
|
+
t.string :author_email
|
35
|
+
t.text :body, null: false
|
36
|
+
t.jsonb :data, default: {}, null: false
|
29
37
|
end
|
38
|
+
|
39
|
+
add_index :comments, :data, using: :gin
|
40
|
+
add_index :comments, %i[commentable_id commentable_type]
|
41
|
+
add_foreign_key :comments, :comments, column: :parent_id, on_update: :cascade, on_delete: :cascade
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_component_record
|
45
|
+
slug = Biovision::Components::CommentsComponent::SLUG
|
46
|
+
return if BiovisionComponent.exists?(slug: slug)
|
47
|
+
|
48
|
+
BiovisionComponent.create!(
|
49
|
+
slug: slug,
|
50
|
+
settings: {
|
51
|
+
premoderation: false,
|
52
|
+
auto_approve_threshold: 3
|
53
|
+
}
|
54
|
+
)
|
30
55
|
end
|
31
56
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Adding "spam" flag and anonymous contact fields to comment
|
4
|
+
class AddFieldsToComments < ActiveRecord::Migration[5.2]
|
5
|
+
def up
|
6
|
+
add_column(:comments, :spam, :boolean, default: false, null: false) unless column_exists?(:comments, :spam)
|
7
|
+
add_column(:comments, :author_name, :string) unless column_exists?(:comments, :author_name)
|
8
|
+
add_column(:comments, :author_email, :string) unless column_exists?(:comments, :author_email)
|
9
|
+
end
|
10
|
+
|
11
|
+
def down
|
12
|
+
# No rollback needed
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Add column with approval flag to comments
|
4
|
+
class AddApprovedToComments < ActiveRecord::Migration[5.2]
|
5
|
+
def up
|
6
|
+
return if column_exists?(:comments, :approved)
|
7
|
+
|
8
|
+
add_column :comments, :approved, :boolean, default: true, null: false
|
9
|
+
end
|
10
|
+
|
11
|
+
def down
|
12
|
+
# No rollback needed
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Create row for comments component in components table
|
4
|
+
class CreateCommentsComponent < ActiveRecord::Migration[5.2]
|
5
|
+
def up
|
6
|
+
slug = Biovision::Components::CommentsComponent::SLUG
|
7
|
+
return if BiovisionComponent.exists?(slug: slug)
|
8
|
+
|
9
|
+
BiovisionComponent.create!(
|
10
|
+
slug: slug,
|
11
|
+
settings: {
|
12
|
+
premoderation: false,
|
13
|
+
auto_approve_threshold: 3
|
14
|
+
}
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def down
|
19
|
+
# No rollback needed
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Add data column to comments
|
4
|
+
class AddDataToComments < ActiveRecord::Migration[5.2]
|
5
|
+
def up
|
6
|
+
return if column_exists? :comments, :data
|
7
|
+
|
8
|
+
add_column :comments, :data, :jsonb, default: {}, null: false
|
9
|
+
add_index :comments, :data, using: :gin
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
# No rollback needed
|
14
|
+
end
|
15
|
+
end
|
@@ -1,10 +1,15 @@
|
|
1
|
+
require 'biovision/base'
|
2
|
+
|
1
3
|
module Biovision
|
2
4
|
module Comment
|
3
5
|
class Engine < ::Rails::Engine
|
6
|
+
config.generators do |g|
|
7
|
+
g.test_framework :rspec
|
8
|
+
g.fixture_replacement :factory_bot, :dir => 'spec/factories'
|
9
|
+
end
|
10
|
+
|
4
11
|
config.assets.precompile << %w(biovision/base/icons/*)
|
5
12
|
config.assets.precompile << %w(biovision/base/placeholders/*)
|
6
13
|
end
|
7
|
-
|
8
|
-
require 'biovision/base'
|
9
14
|
end
|
10
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: biovision-comment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.190905.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxim Khan-Magomedov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-09-04 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: rails-i18n
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: factory_bot_rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -134,33 +134,45 @@ files:
|
|
134
134
|
- Rakefile
|
135
135
|
- app/assets/config/biovision_comment_manifest.js
|
136
136
|
- app/assets/javascripts/biovision/comment/application.js
|
137
|
+
- app/assets/javascripts/biovision/comment/biovision-comments.js
|
137
138
|
- app/assets/stylesheets/biovision/comment/comments.scss
|
138
139
|
- app/controllers/admin/comments_controller.rb
|
139
140
|
- app/controllers/biovision/comment/application_controller.rb
|
140
141
|
- app/controllers/comments_controller.rb
|
141
142
|
- app/controllers/my/comments_controller.rb
|
142
143
|
- app/helpers/biovision/comment/application_helper.rb
|
144
|
+
- app/helpers/comments_helper.rb
|
143
145
|
- app/jobs/biovision/comment/application_job.rb
|
144
146
|
- app/mailers/biovision/comment/application_mailer.rb
|
145
147
|
- app/mailers/comment_mailer.rb
|
146
148
|
- app/models/biovision/comment/application_record.rb
|
147
149
|
- app/models/comment.rb
|
150
|
+
- app/models/concerns/commentable_item.rb
|
151
|
+
- app/services/biovision/components/comments_component.rb
|
152
|
+
- app/services/comment_handler.rb
|
153
|
+
- app/services/comments_manager.rb
|
148
154
|
- app/views/admin/comments/_comment.html.erb
|
149
155
|
- app/views/admin/comments/_nav_item.html.erb
|
150
156
|
- app/views/admin/comments/entity/_in_list.html.erb
|
151
157
|
- app/views/admin/comments/index.html.erb
|
152
158
|
- app/views/admin/comments/show.html.erb
|
159
|
+
- app/views/admin/components/links/_comments.html.erb
|
153
160
|
- app/views/comment_mailer/entry_reply.text.erb
|
154
161
|
- app/views/comments/_comment.html.erb
|
155
162
|
- app/views/comments/_form.html.erb
|
156
163
|
- app/views/comments/_list.html.erb
|
164
|
+
- app/views/comments/_reply_container.html.erb
|
165
|
+
- app/views/comments/_section.html.erb
|
157
166
|
- app/views/comments/edit.html.erb
|
158
167
|
- app/views/comments/new.html.erb
|
159
|
-
- app/views/comments/show.html.erb
|
160
168
|
- app/views/layouts/biovision/comment/application.html.erb
|
161
169
|
- config/locales/comments-ru.yml
|
162
170
|
- config/routes.rb
|
163
171
|
- db/migrate/20170914000001_create_comments.rb
|
172
|
+
- db/migrate/20190203090909_add_fields_to_comments.rb
|
173
|
+
- db/migrate/20190428212121_add_approved_to_comments.rb
|
174
|
+
- db/migrate/20190428212122_create_comments_component.rb
|
175
|
+
- db/migrate/20190628101010_add_data_to_comments.rb
|
164
176
|
- lib/biovision/comment.rb
|
165
177
|
- lib/biovision/comment/engine.rb
|
166
178
|
- lib/biovision/comment/version.rb
|
@@ -184,8 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
196
|
- !ruby/object:Gem::Version
|
185
197
|
version: '0'
|
186
198
|
requirements: []
|
187
|
-
|
188
|
-
rubygems_version: 2.6.11
|
199
|
+
rubygems_version: 3.0.4
|
189
200
|
signing_key:
|
190
201
|
specification_version: 4
|
191
202
|
summary: Commenting for biovision-based applications
|
@@ -1,27 +0,0 @@
|
|
1
|
-
<% content_for :meta_title, t('.title', id: @entity.id) %>
|
2
|
-
<% content_for :options do %>
|
3
|
-
<ul>
|
4
|
-
<li><%= link_to t(:list), admin_comments_path %></li>
|
5
|
-
<li><%= link_to t(:edit), edit_comment_path(@entity) %></li>
|
6
|
-
</ul>
|
7
|
-
<% end %>
|
8
|
-
|
9
|
-
<article class="comment">
|
10
|
-
<h1><%= t('.title', id: @entity.id) %></h1>
|
11
|
-
|
12
|
-
<div class="comment">
|
13
|
-
<div class="title">
|
14
|
-
<%= @entity.commentable.model_name.human %>
|
15
|
-
<cite><%= link_to @entity.commentable.title, @entity.commentable %></cite>
|
16
|
-
</div>
|
17
|
-
|
18
|
-
<div class="author">
|
19
|
-
<%= user_link @entity.user %>
|
20
|
-
<%= time_tag @entity.created_at %>
|
21
|
-
</div>
|
22
|
-
|
23
|
-
<div class="body">
|
24
|
-
<%= prepare_comment_text(@entity) %>
|
25
|
-
</div>
|
26
|
-
</div>
|
27
|
-
</article>
|