commontator 0.4.1 → 0.5.12
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +35 -23
- data/app/assets/stylesheets/commontator/comments.css +1 -1
- data/app/assets/stylesheets/commontator/comments.css~ +0 -4
- data/app/controllers/commontator/application_controller.rb +4 -5
- data/app/controllers/commontator/application_controller.rb~ +5 -5
- data/app/controllers/commontator/comments_controller.rb +30 -30
- data/app/controllers/commontator/comments_controller.rb~ +31 -31
- data/app/controllers/commontator/subscriptions_controller.rb +8 -7
- data/app/controllers/commontator/subscriptions_controller.rb~ +6 -7
- data/app/controllers/commontator/threads_controller.rb +8 -9
- data/app/controllers/commontator/threads_controller.rb~ +9 -10
- data/app/helpers/commontator/comments_helper.rb~ +14 -24
- data/app/helpers/commontator/subscriptions_helper.rb~ +3 -3
- data/app/helpers/commontator/threads_helper.rb +0 -8
- data/app/helpers/commontator/threads_helper.rb~ +5 -5
- data/app/mailers/commontator/subscriptions_mailer.rb +8 -8
- data/app/mailers/commontator/subscriptions_mailer.rb~ +9 -10
- data/app/models/commontator/comment.rb +14 -6
- data/app/models/commontator/comment.rb~ +15 -12
- data/app/views/commontator/comments/_actions.html.erb +6 -5
- data/app/views/commontator/comments/_actions.html.erb~ +6 -5
- data/app/views/commontator/comments/_body.html.erb +2 -1
- data/app/views/commontator/comments/_body.html.erb~ +1 -2
- data/app/views/commontator/comments/_form.html.erb +8 -3
- data/app/views/commontator/comments/_form.html.erb~ +7 -4
- data/app/views/commontator/comments/_show.html.erb +11 -8
- data/app/views/commontator/comments/_show.html.erb~ +11 -8
- data/app/views/commontator/comments/_votes.html.erb +7 -6
- data/app/views/commontator/comments/create.js.erb +4 -2
- data/app/views/commontator/comments/delete.js.erb +5 -3
- data/app/views/commontator/comments/delete.js.erb~ +5 -3
- data/app/views/commontator/comments/update.js.erb +1 -1
- data/app/views/commontator/comments/update.js.erb~ +1 -1
- data/app/views/commontator/comments/vote.js.erb +2 -1
- data/app/views/commontator/shared/_thread.html.erb +17 -0
- data/app/views/commontator/shared/_thread.html.erb~ +16 -0
- data/app/views/commontator/shared/_thread_link.html.erb~ +16 -0
- data/app/views/commontator/subscriptions/_link.html.erb +3 -2
- data/app/views/commontator/subscriptions/subscribe.js.erb +2 -1
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb +1 -1
- data/app/views/commontator/threads/_show.html.erb +18 -11
- data/app/views/commontator/threads/_show.html.erb~ +18 -11
- data/app/views/commontator/threads/show.js.erb +2 -1
- data/config/initializers/commontator.rb +14 -14
- data/db/migrate/0_install_commontator.rb +3 -3
- data/lib/commontator.rb +5 -6
- data/lib/commontator.rb~ +5 -6
- data/lib/commontator/acts_as_commontable.rb +2 -0
- data/lib/commontator/acts_as_commontator.rb +2 -0
- data/lib/commontator/controller_includes.rb +23 -0
- data/lib/commontator/controller_includes.rb~ +23 -0
- data/lib/commontator/shared_helper.rb +42 -0
- data/lib/commontator/shared_helper.rb~ +42 -0
- data/lib/commontator/shared_methods.rb~ +24 -0
- data/lib/commontator/version.rb +1 -1
- data/lib/commontator/version.rb~ +1 -1
- data/test/dummy/config/initializers/commontator.rb +15 -15
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/1_install_commontator.commontator.rb +3 -3
- data/test/dummy/db/schema.rb +3 -3
- data/test/dummy/log/development.log +64 -0
- metadata +10 -70
- data/app/assets/stylesheets/commontator/application.css~ +0 -88
- data/app/assets/stylesheets/commontator/threads.css~ +0 -13
- data/app/helpers/commontator/application_helper.rb~ +0 -11
- data/app/helpers/commontator/comments_helper.rb +0 -51
- data/app/helpers/commontator/commontable_helper.rb~ +0 -9
- data/app/helpers/commontator/commontator_helper.rb +0 -8
- data/app/helpers/commontator/commontator_helper.rb~ +0 -8
- data/app/helpers/commontator/subscriptions_helper.rb +0 -8
- data/app/mailers/commontator/subscription_mailer.rb~ +0 -38
- data/app/models/commontator/subscription.rb~ +0 -21
- data/app/models/commontator/thread.rb~ +0 -143
- data/app/views/commontator/comments/_votes.html.erb~ +0 -62
- data/app/views/commontator/comments/create.js.erb~ +0 -15
- data/app/views/commontator/comments/destroy.js.erb~ +0 -1
- data/app/views/commontator/comments/edit.html.erb~ +0 -6
- data/app/views/commontator/comments/edit.js.erb~ +0 -5
- data/app/views/commontator/comments/new.html.erb~ +0 -8
- data/app/views/commontator/comments/new.js.erb~ +0 -12
- data/app/views/commontator/comments/vote.js.erb~ +0 -5
- data/app/views/commontator/shared/_thread_link.html.erb +0 -13
- data/app/views/commontator/subscriptions/_index.html.erb~ +0 -16
- data/app/views/commontator/subscriptions/_link.html.erb~ +0 -15
- data/app/views/commontator/subscriptions/_subscription_link.html.erb~ +0 -13
- data/app/views/commontator/subscriptions/create.js.erb~ +0 -5
- data/app/views/commontator/subscriptions/destroy.js.erb~ +0 -3
- data/app/views/commontator/subscriptions/index.html.erb~ +0 -16
- data/app/views/commontator/subscriptions/subscribe.js.erb~ +0 -5
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb~ +0 -6
- data/app/views/commontator/threads/_actions.html.erb~ +0 -28
- data/app/views/commontator/threads/_link.html.erb~ +0 -14
- data/app/views/commontator/threads/close.js.erb~ +0 -5
- data/app/views/commontator/threads/show.html.erb~ +0 -3
- data/app/views/commontator/threads/show.js.erb~ +0 -6
- data/config/initializers/commontator.rb~ +0 -179
- data/config/routes.rb~ +0 -24
- data/db/migrate/0_install_commontator.rb~ +0 -48
- data/lib/commontator/acts_as_commontable.rb~ +0 -39
- data/lib/commontator/acts_as_commontator.rb~ +0 -28
- data/lib/commontator/commontable_config.rb~ +0 -13
- data/lib/commontator/commontator_config.rb~ +0 -13
- data/lib/commontator/routes.rb~ +0 -37
- data/lib/tasks/commontator_tasks.rake~ +0 -41
- data/test/dummy/config/initializers/commontator.rb~ +0 -179
- data/test/dummy/config/routes.rb~ +0 -3
- data/test/functional/comment_thread_subscriptions_controller_test.rb~ +0 -125
- data/test/functional/comments_controller_test.rb~ +0 -184
- data/test/functional/subscriptions_controller_test.rb~ +0 -122
- data/test/unit/comment_test.rb~ +0 -38
- data/test/unit/comment_thread_subscription_test.rb~ +0 -18
- data/test/unit/comment_thread_test.rb~ +0 -60
- data/test/unit/helpers/comment_thread_subscriptions_helper_test.rb~ +0 -7
- data/test/unit/helpers/comments_helper_test.rb~ +0 -7
- data/test/unit/helpers/subscriptions_helper_test.rb~ +0 -4
- data/test/unit/subscription_test.rb~ +0 -15
- data/test/unit/thread_test.rb~ +0 -57
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# Commontator
|
2
2
|
|
3
|
-
|
3
|
+
Commontator is a Rails engine for comments.
|
4
|
+
That means it is fully functional as soon as you install and configure its gem, providing models, views and controllers of its own.
|
5
|
+
At the same time, it is highly configurable, so you can change anything about it if you would like.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -11,7 +13,7 @@ There are 4 steps you must follow to install commontator:
|
|
11
13
|
Add this line to your application's Gemfile:
|
12
14
|
|
13
15
|
```ruby
|
14
|
-
gem 'commontator', '~> 0.
|
16
|
+
gem 'commontator', '~> 0.5.0'
|
15
17
|
```
|
16
18
|
|
17
19
|
And then execute:
|
@@ -59,7 +61,7 @@ There are 4 steps you must follow to install commontator:
|
|
59
61
|
Add this line to your application's routes file:
|
60
62
|
|
61
63
|
```ruby
|
62
|
-
mount Commontator::Engine =>
|
64
|
+
mount Commontator::Engine => '/commontator'
|
63
65
|
```
|
64
66
|
|
65
67
|
You can change the mount path if you would like a different one.
|
@@ -81,41 +83,51 @@ Follow the steps below to add commontator to your models and views:
|
|
81
83
|
```ruby
|
82
84
|
acts_as_commontable
|
83
85
|
```
|
84
|
-
|
85
|
-
2. Controllers
|
86
|
-
|
87
|
-
Add the following line to the controller(s) that handle the views where you want to display comments:
|
88
|
-
|
89
|
-
```ruby
|
90
|
-
helper Commontator::CommontatorHelper
|
91
|
-
```
|
92
86
|
|
93
|
-
|
87
|
+
2. Views
|
94
88
|
|
95
|
-
Add the following line to any view where you would like to display comments:
|
89
|
+
Add the following line to any erb view where you would like to display comments:
|
96
90
|
|
97
91
|
```erb
|
98
|
-
<%=
|
92
|
+
<%= commontator_thread(commontable) %>
|
99
93
|
```
|
100
|
-
|
94
|
+
|
101
95
|
Where commontable is an instance of some model that acts_as_commontable.
|
102
96
|
|
97
|
+
3. Controllers
|
98
|
+
|
99
|
+
Instead of linking to the thread, you might want to have the thread display right away, when the corresponding view page is loaded.
|
100
|
+
If that's the case, add the following to the controller action that displays the view where the thread is located:
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
commontator_thread_show(commontable)
|
104
|
+
```
|
105
|
+
|
106
|
+
Note that the above method also checks the current user's read permission on the thread.
|
107
|
+
It will raise a SecurityTransgression if the user is not allowed to read the thread.
|
108
|
+
You can specify the name of the method that determines which users are allowed to read which threads in the initializer.
|
109
|
+
|
103
110
|
That's it! Commontator is now ready for use.
|
104
111
|
|
112
|
+
## Browser Support
|
113
|
+
|
114
|
+
No incompatibilities are currently known with any of the major browsers.
|
115
|
+
Currently commontator requires javascript to be enabled to function properly.
|
116
|
+
|
105
117
|
## Customization
|
106
118
|
|
107
119
|
Copy commontator's files to your app using any of the following commands:
|
108
120
|
|
109
121
|
```sh
|
110
|
-
rake commontator:copy:images
|
111
|
-
rake commontator:copy:stylesheets
|
122
|
+
$ rake commontator:copy:images
|
123
|
+
$ rake commontator:copy:stylesheets
|
112
124
|
|
113
|
-
rake commontator:copy:views
|
114
|
-
rake commontator:copy:mailers
|
115
|
-
rake commontator:copy:helpers
|
125
|
+
$ rake commontator:copy:views
|
126
|
+
$ rake commontator:copy:mailers
|
127
|
+
$ rake commontator:copy:helpers
|
116
128
|
|
117
|
-
rake commontator:copy:controllers
|
118
|
-
rake commontator:copy:models
|
129
|
+
$ rake commontator:copy:controllers
|
130
|
+
$ rake commontator:copy:models
|
119
131
|
```
|
120
132
|
|
121
133
|
You are now free to modify them and have any changes made manifest in your application.
|
@@ -1,19 +1,18 @@
|
|
1
1
|
module Commontator
|
2
2
|
class ApplicationController < ActionController::Base
|
3
|
-
before_filter :
|
3
|
+
before_filter :get_user
|
4
4
|
|
5
5
|
protected
|
6
6
|
|
7
|
-
def
|
8
|
-
@
|
9
|
-
raise SecurityTransgression unless (@
|
7
|
+
def get_user
|
8
|
+
@user = send Commontator.current_user_method
|
9
|
+
raise SecurityTransgression unless (@user.nil? || @user.is_commontator)
|
10
10
|
end
|
11
11
|
|
12
12
|
def get_thread
|
13
13
|
@thread = params[:thread_id].blank? ? \
|
14
14
|
Commontator::Thread.find(params[:id]) : \
|
15
15
|
Commontator::Thread.find(params[:thread_id])
|
16
|
-
get_commontable_url
|
17
16
|
end
|
18
17
|
|
19
18
|
def get_commontable_url
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Commontator
|
2
2
|
class ApplicationController < ActionController::Base
|
3
|
-
before_filter :
|
3
|
+
before_filter :get_user
|
4
4
|
|
5
5
|
protected
|
6
6
|
|
7
|
-
def
|
8
|
-
@
|
9
|
-
raise SecurityTransgression unless (@
|
7
|
+
def get_user
|
8
|
+
@user = send Commontator.current_user_method
|
9
|
+
raise SecurityTransgression unless (@user.nil? || @user.is_commontator)
|
10
10
|
end
|
11
11
|
|
12
12
|
def get_thread
|
@@ -17,7 +17,7 @@ module Commontator
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def get_commontable_url
|
20
|
-
@thread.config.commontable_url_proc.call(main_app, @thread.commontable)
|
20
|
+
@commontable_url = @thread.config.commontable_url_proc.call(main_app, @thread.commontable)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -2,17 +2,18 @@ module Commontator
|
|
2
2
|
class CommentsController < ApplicationController
|
3
3
|
before_filter :get_thread, :only => [:new, :create]
|
4
4
|
before_filter :get_comment_and_thread, :except => [:new, :create]
|
5
|
+
before_filter :get_commontable_url, :only => :create
|
5
6
|
|
6
7
|
# GET /1/comments/new
|
7
8
|
def new
|
8
9
|
@comment = Comment.new
|
9
10
|
@comment.thread = @thread
|
10
|
-
@comment.
|
11
|
+
@comment.creator = @user
|
11
12
|
|
12
|
-
raise SecurityTransgression unless @comment.can_be_created_by?(@
|
13
|
+
raise SecurityTransgression unless @comment.can_be_created_by?(@user)
|
13
14
|
|
14
15
|
respond_to do |format|
|
15
|
-
format.html
|
16
|
+
#format.html
|
16
17
|
format.js
|
17
18
|
end
|
18
19
|
|
@@ -22,105 +23,105 @@ module Commontator
|
|
22
23
|
def create
|
23
24
|
@comment = Comment.new(params[:comment])
|
24
25
|
@comment.thread = @thread
|
25
|
-
@comment.
|
26
|
+
@comment.creator = @user
|
26
27
|
|
27
|
-
raise SecurityTransgression unless @comment.can_be_created_by?(@
|
28
|
+
raise SecurityTransgression unless @comment.can_be_created_by?(@user)
|
28
29
|
|
29
30
|
if @comment.save
|
30
|
-
@thread.subscribe(@
|
31
|
-
@thread.mark_as_unread_except_for(@
|
31
|
+
@thread.subscribe(@user) if @thread.config.auto_subscribe_on_comment
|
32
|
+
@thread.mark_as_unread_except_for(@user)
|
32
33
|
SubscriptionsMailer.comment_created_email(@comment, @commontable_url)
|
33
|
-
@thread.comment_created_callback(@
|
34
|
+
@thread.comment_created_callback(@user, @comment)
|
34
35
|
else
|
35
36
|
@errors = @comment.errors
|
36
37
|
end
|
37
38
|
|
38
39
|
respond_to do |format|
|
39
|
-
format.html { redirect_to @
|
40
|
+
format.html { redirect_to @thread }
|
40
41
|
format.js
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
45
|
# GET /comments/1/edit
|
45
46
|
def edit
|
46
|
-
raise SecurityTransgression unless @comment.can_be_edited_by?(@
|
47
|
+
raise SecurityTransgression unless @comment.can_be_edited_by?(@user)
|
47
48
|
|
48
49
|
respond_to do |format|
|
49
|
-
format.html
|
50
|
+
#format.html
|
50
51
|
format.js
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
54
55
|
# PUT /comments/1
|
55
56
|
def update
|
56
|
-
raise SecurityTransgression unless @comment.can_be_edited_by?(@
|
57
|
+
raise SecurityTransgression unless @comment.can_be_edited_by?(@user)
|
57
58
|
|
58
|
-
@thread.comment_edited_callback(@
|
59
|
+
@thread.comment_edited_callback(@user, @comment) \
|
59
60
|
if @comment.update_attributes(params[:comment])
|
60
61
|
|
61
62
|
respond_to do |format|
|
62
|
-
format.html { redirect_to @
|
63
|
+
format.html { redirect_to @thread }
|
63
64
|
format.js
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
67
68
|
# PUT /comments/1/delete
|
68
69
|
def delete
|
69
|
-
raise SecurityTransgression unless @comment.can_be_deleted_by?(@
|
70
|
+
raise SecurityTransgression unless @comment.can_be_deleted_by?(@user)
|
70
71
|
|
71
|
-
@comment.delete(@
|
72
|
-
@thread.comment_deleted_callback(@
|
72
|
+
@comment.delete(@user)
|
73
|
+
@thread.comment_deleted_callback(@user, @comment)
|
73
74
|
|
74
75
|
respond_to do |format|
|
75
|
-
format.html { redirect_to @
|
76
|
+
format.html { redirect_to @thread }
|
76
77
|
format.js { render :delete }
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
80
81
|
# PUT /comments/1/undelete
|
81
82
|
def undelete
|
82
|
-
raise SecurityTransgression unless @comment.can_be_deleted_by?(@
|
83
|
+
raise SecurityTransgression unless @comment.can_be_deleted_by?(@user)
|
83
84
|
|
84
85
|
@comment.undelete
|
85
86
|
|
86
87
|
respond_to do |format|
|
87
|
-
format.html { redirect_to @
|
88
|
+
format.html { redirect_to @thread }
|
88
89
|
format.js { render :delete }
|
89
90
|
end
|
90
91
|
end
|
91
92
|
|
92
93
|
# PUT /comments/1/upvote
|
93
94
|
def upvote
|
94
|
-
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@
|
95
|
+
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
|
95
96
|
|
96
|
-
@comment.upvote_from @
|
97
|
+
@comment.upvote_from @user
|
97
98
|
|
98
99
|
respond_to do |format|
|
99
|
-
format.html { redirect_to @
|
100
|
+
format.html { redirect_to @thread }
|
100
101
|
format.js { render :vote }
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
104
105
|
# PUT /comments/1/downvote
|
105
106
|
def downvote
|
106
|
-
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@
|
107
|
+
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
|
107
108
|
|
108
|
-
@comment.downvote_from @
|
109
|
+
@comment.downvote_from @user
|
109
110
|
|
110
111
|
respond_to do |format|
|
111
|
-
format.html { redirect_to @
|
112
|
+
format.html { redirect_to @thread }
|
112
113
|
format.js { render :vote }
|
113
114
|
end
|
114
115
|
end
|
115
116
|
|
116
117
|
# PUT /comments/1/unvote
|
117
118
|
def unvote
|
118
|
-
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@
|
119
|
+
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
|
119
120
|
|
120
|
-
@comment.unvote :voter => @
|
121
|
+
@comment.unvote :voter => @user
|
121
122
|
|
122
123
|
respond_to do |format|
|
123
|
-
format.html { redirect_to @
|
124
|
+
format.html { redirect_to @thread }
|
124
125
|
format.js { render :vote }
|
125
126
|
end
|
126
127
|
end
|
@@ -130,7 +131,6 @@ module Commontator
|
|
130
131
|
def get_comment_and_thread
|
131
132
|
@comment = Comment.find(params[:id])
|
132
133
|
@thread = @comment.thread
|
133
|
-
get_commontable_url
|
134
134
|
end
|
135
135
|
end
|
136
136
|
end
|
@@ -2,17 +2,18 @@ module Commontator
|
|
2
2
|
class CommentsController < ApplicationController
|
3
3
|
before_filter :get_thread, :only => [:new, :create]
|
4
4
|
before_filter :get_comment_and_thread, :except => [:new, :create]
|
5
|
+
before_filter :get_commontable_url, :only => :create
|
5
6
|
|
6
7
|
# GET /1/comments/new
|
7
8
|
def new
|
8
9
|
@comment = Comment.new
|
9
10
|
@comment.thread = @thread
|
10
|
-
@comment.
|
11
|
+
@comment.creator = @user
|
11
12
|
|
12
|
-
raise SecurityTransgression unless @comment.can_be_created_by?(@
|
13
|
+
raise SecurityTransgression unless @comment.can_be_created_by?(@user)
|
13
14
|
|
14
15
|
respond_to do |format|
|
15
|
-
format.html
|
16
|
+
#format.html
|
16
17
|
format.js
|
17
18
|
end
|
18
19
|
|
@@ -22,105 +23,105 @@ module Commontator
|
|
22
23
|
def create
|
23
24
|
@comment = Comment.new(params[:comment])
|
24
25
|
@comment.thread = @thread
|
25
|
-
@comment.
|
26
|
+
@comment.creator = @user
|
26
27
|
|
27
|
-
raise SecurityTransgression unless @comment.can_be_created_by?(@
|
28
|
+
raise SecurityTransgression unless @comment.can_be_created_by?(@user)
|
28
29
|
|
29
30
|
if @comment.save
|
30
|
-
@thread.subscribe(@
|
31
|
-
@thread.mark_as_unread_except_for(@
|
32
|
-
SubscriptionsMailer.comment_created_email(@comment)
|
33
|
-
@thread.comment_created_callback(@
|
31
|
+
@thread.subscribe(@user) if @thread.config.auto_subscribe_on_comment
|
32
|
+
@thread.mark_as_unread_except_for(@user)
|
33
|
+
SubscriptionsMailer.comment_created_email(@comment, @commontable_url)
|
34
|
+
@thread.comment_created_callback(@user, @comment)
|
34
35
|
else
|
35
36
|
@errors = @comment.errors
|
36
37
|
end
|
37
38
|
|
38
39
|
respond_to do |format|
|
39
|
-
format.html { redirect_to @
|
40
|
+
format.html { redirect_to @thread }
|
40
41
|
format.js
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
44
45
|
# GET /comments/1/edit
|
45
46
|
def edit
|
46
|
-
raise SecurityTransgression unless @comment.can_be_edited_by?(@
|
47
|
+
raise SecurityTransgression unless @comment.can_be_edited_by?(@user)
|
47
48
|
|
48
49
|
respond_to do |format|
|
49
|
-
format.html
|
50
|
+
format.html
|
50
51
|
format.js
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
54
55
|
# PUT /comments/1
|
55
56
|
def update
|
56
|
-
raise SecurityTransgression unless @comment.can_be_edited_by?(@
|
57
|
+
raise SecurityTransgression unless @comment.can_be_edited_by?(@user)
|
57
58
|
|
58
|
-
@thread.comment_edited_callback(@
|
59
|
+
@thread.comment_edited_callback(@user, @comment) \
|
59
60
|
if @comment.update_attributes(params[:comment])
|
60
61
|
|
61
62
|
respond_to do |format|
|
62
|
-
format.html { redirect_to @
|
63
|
+
format.html { redirect_to @thread }
|
63
64
|
format.js
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
67
68
|
# PUT /comments/1/delete
|
68
69
|
def delete
|
69
|
-
raise SecurityTransgression unless @comment.can_be_deleted_by?(@
|
70
|
+
raise SecurityTransgression unless @comment.can_be_deleted_by?(@user)
|
70
71
|
|
71
|
-
@comment.delete(@
|
72
|
-
@thread.comment_deleted_callback(@
|
72
|
+
@comment.delete(@user)
|
73
|
+
@thread.comment_deleted_callback(@user, @comment)
|
73
74
|
|
74
75
|
respond_to do |format|
|
75
|
-
format.html { redirect_to @
|
76
|
+
format.html { redirect_to @thread }
|
76
77
|
format.js { render :delete }
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
80
81
|
# PUT /comments/1/undelete
|
81
82
|
def undelete
|
82
|
-
raise SecurityTransgression unless @comment.can_be_deleted_by?(@
|
83
|
+
raise SecurityTransgression unless @comment.can_be_deleted_by?(@user)
|
83
84
|
|
84
85
|
@comment.undelete
|
85
86
|
|
86
87
|
respond_to do |format|
|
87
|
-
format.html { redirect_to @
|
88
|
+
format.html { redirect_to @thread }
|
88
89
|
format.js { render :delete }
|
89
90
|
end
|
90
91
|
end
|
91
92
|
|
92
93
|
# PUT /comments/1/upvote
|
93
94
|
def upvote
|
94
|
-
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@
|
95
|
+
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
|
95
96
|
|
96
|
-
@comment.upvote_from @
|
97
|
+
@comment.upvote_from @user
|
97
98
|
|
98
99
|
respond_to do |format|
|
99
|
-
format.html { redirect_to @
|
100
|
+
format.html { redirect_to @thread }
|
100
101
|
format.js { render :vote }
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
104
105
|
# PUT /comments/1/downvote
|
105
106
|
def downvote
|
106
|
-
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@
|
107
|
+
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
|
107
108
|
|
108
|
-
@comment.downvote_from @
|
109
|
+
@comment.downvote_from @user
|
109
110
|
|
110
111
|
respond_to do |format|
|
111
|
-
format.html { redirect_to @
|
112
|
+
format.html { redirect_to @thread }
|
112
113
|
format.js { render :vote }
|
113
114
|
end
|
114
115
|
end
|
115
116
|
|
116
117
|
# PUT /comments/1/unvote
|
117
118
|
def unvote
|
118
|
-
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@
|
119
|
+
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
|
119
120
|
|
120
|
-
@comment.unvote :voter => @
|
121
|
+
@comment.unvote :voter => @user
|
121
122
|
|
122
123
|
respond_to do |format|
|
123
|
-
format.html { redirect_to @
|
124
|
+
format.html { redirect_to @thread }
|
124
125
|
format.js { render :vote }
|
125
126
|
end
|
126
127
|
end
|
@@ -130,7 +131,6 @@ module Commontator
|
|
130
131
|
def get_comment_and_thread
|
131
132
|
@comment = Comment.find(params[:id])
|
132
133
|
@thread = @comment.thread
|
133
|
-
get_commontable_url
|
134
134
|
end
|
135
135
|
end
|
136
136
|
end
|