commentui 0.1.01 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -9
- data/app/controllers/commentui/comments_controller.rb +4 -4
- data/app/models/commentui/comment.rb +1 -1
- data/app/models/commentui/{thread.rb → topic.rb} +1 -1
- data/config/routes.rb +1 -1
- data/db/migrate/20191109044444_rename_commentui_threads_to_commentui_topics.rb +6 -0
- data/lib/commentui/acts_as_commentuiable.rb +4 -4
- data/lib/commentui/acts_as_commentuier.rb +2 -2
- data/lib/commentui/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad0908a8083abe7a1d1259737e6b29b018dac8fcb20018fc07942a7dc6a9bf41
|
4
|
+
data.tar.gz: 4d14f9228b136fba56899558a551037c452164d9675ac3d8a6df588b433337d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '058506a2f751d862840c6b4fd3596c55ee12b53740c495f56ec24f73587d788ba93e5bb5b857a34c89e08f68cc152b96f242df359c4cee40d6bad7f4bef937b1'
|
7
|
+
data.tar.gz: 7f6f84809b084fb8b0c5888a4d7e715acf14f99983eebbd783763c47d6d63b0bfe157e6de942fd9cd806d4d2aa9bafd14e087962f0e56059c2a3934146de5b4e
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ A simple comment API gem
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
```ruby
|
9
|
-
gem 'commentui', "~> 0.
|
9
|
+
gem 'commentui', "~> 0.2.0"
|
10
10
|
```
|
11
11
|
|
12
12
|
And then execute:
|
@@ -18,7 +18,7 @@ Or install it yourself as:
|
|
18
18
|
$ gem install commentui
|
19
19
|
```
|
20
20
|
### 2. Migrations
|
21
|
-
Run the following [command](https://edgeguides.rubyonrails.org/engines.html#engine-setup) to copy Commentui's migrations to your application:
|
21
|
+
Run the following [command](https://edgeguides.rubyonrails.org/engines.html#engine-setup) to copy Commentui's migrations to your application (run when update gem also):
|
22
22
|
```bash
|
23
23
|
$ bundle exec rake commentui:install:migrations
|
24
24
|
```
|
@@ -75,13 +75,13 @@ Supported actions
|
|
75
75
|
|
76
76
|
|Helper|HTTP Verb|Path|Controller#Action|
|
77
77
|
|--- |--- |--- |--- |
|
78
|
-
|
|
79
|
-
||POST|/
|
80
|
-
|
|
81
|
-
||PATCH|/
|
82
|
-
||PUT|/
|
83
|
-
||DELETE|/
|
84
|
-
|
|
78
|
+
|topic_comments_path|GET|/topics/:topic_id/comments(.:format)|commentui/comments#index|
|
79
|
+
||POST|/topics/:topic_id/comments(.:format)|commentui/comments#create|
|
80
|
+
|topic_comment_path|GET|/topics/:topic_id/comments/:id(.:format)|commentui/comments#show|
|
81
|
+
||PATCH|/topics/:topic_id/comments/:id(.:format)|commentui/comments#update|
|
82
|
+
||PUT|/topics/:topic_id/comments/:id(.:format)|commentui/comments#update|
|
83
|
+
||DELETE|/topics/:topic_id/comments/:id(.:format)|commentui/comments#destroy|
|
84
|
+
|topic_path|GET|/topics/:id(.:format)|commentui/topics#show|
|
85
85
|
|
86
86
|
|
87
87
|
## Contributing
|
@@ -4,7 +4,7 @@ module Commentui
|
|
4
4
|
class CommentsController < ApplicationController
|
5
5
|
include Pagy::Backend
|
6
6
|
|
7
|
-
before_action :
|
7
|
+
before_action :set_topic
|
8
8
|
before_action :set_comment, only: [:update, :destroy]
|
9
9
|
before_action :check_user, only: [:update, :destroy]
|
10
10
|
after_action { pagy_headers_merge(@pagy) if @pagy }
|
@@ -37,12 +37,12 @@ module Commentui
|
|
37
37
|
|
38
38
|
private
|
39
39
|
|
40
|
-
def
|
41
|
-
@
|
40
|
+
def set_topic
|
41
|
+
@topic ||= Commentui::Topic.find(params[:topic_id])
|
42
42
|
end
|
43
43
|
|
44
44
|
def comments_scope
|
45
|
-
@
|
45
|
+
@topic.comments.order(created_at: :asc)
|
46
46
|
end
|
47
47
|
|
48
48
|
def set_comment
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Commentui::Engine.routes.draw do
|
2
|
-
resources :
|
2
|
+
resources :topics, only: [:show] do
|
3
3
|
comment_resources = [:index, :show, :create]
|
4
4
|
comment_resources << :update if Commentui.allow_modify_comment
|
5
5
|
comment_resources << :destroy if Commentui.allow_modify_destroy
|
@@ -7,13 +7,13 @@ module Commentui
|
|
7
7
|
class_methods do
|
8
8
|
def acts_as_commentuiable
|
9
9
|
class_exec do
|
10
|
-
has_one :
|
10
|
+
has_one :commentui_topic,
|
11
11
|
dependent: :nullify,
|
12
12
|
as: :commentable,
|
13
|
-
class_name: "Commentui::
|
13
|
+
class_name: "Commentui::Topic"
|
14
14
|
|
15
|
-
def
|
16
|
-
@
|
15
|
+
def commentui_topic
|
16
|
+
@commentui_topic ||= (super || create_commentui_topic)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -15,10 +15,10 @@ module Commentui
|
|
15
15
|
dependent: :nullify,
|
16
16
|
as: :editor,
|
17
17
|
class_name: "Commentui::Comment"
|
18
|
-
has_many :
|
18
|
+
has_many :commentui_closed_topics,
|
19
19
|
dependent: :nullify,
|
20
20
|
as: :closer,
|
21
|
-
class_name: "Commentui::
|
21
|
+
class_name: "Commentui::Topic"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end ###
|
data/lib/commentui/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commentui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phuoc Phan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -181,11 +181,12 @@ files:
|
|
181
181
|
- app/controllers/commentui/comments_controller.rb
|
182
182
|
- app/models/commentui/application_record.rb
|
183
183
|
- app/models/commentui/comment.rb
|
184
|
-
- app/models/commentui/
|
184
|
+
- app/models/commentui/topic.rb
|
185
185
|
- config/initializers/commentui.rb
|
186
186
|
- config/routes.rb
|
187
187
|
- db/migrate/20191012044238_create_commentui_threads.rb
|
188
188
|
- db/migrate/20191012050923_create_commentui_comments.rb
|
189
|
+
- db/migrate/20191109044444_rename_commentui_threads_to_commentui_topics.rb
|
189
190
|
- lib/commentui.rb
|
190
191
|
- lib/commentui/acts_as_commentuiable.rb
|
191
192
|
- lib/commentui/acts_as_commentuier.rb
|