commontator 0.4.1 → 0.5.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. data/README.md +35 -23
  2. data/app/assets/stylesheets/commontator/comments.css +1 -1
  3. data/app/assets/stylesheets/commontator/comments.css~ +0 -4
  4. data/app/controllers/commontator/application_controller.rb +4 -5
  5. data/app/controllers/commontator/application_controller.rb~ +5 -5
  6. data/app/controllers/commontator/comments_controller.rb +30 -30
  7. data/app/controllers/commontator/comments_controller.rb~ +31 -31
  8. data/app/controllers/commontator/subscriptions_controller.rb +8 -7
  9. data/app/controllers/commontator/subscriptions_controller.rb~ +6 -7
  10. data/app/controllers/commontator/threads_controller.rb +8 -9
  11. data/app/controllers/commontator/threads_controller.rb~ +9 -10
  12. data/app/helpers/commontator/comments_helper.rb~ +14 -24
  13. data/app/helpers/commontator/subscriptions_helper.rb~ +3 -3
  14. data/app/helpers/commontator/threads_helper.rb +0 -8
  15. data/app/helpers/commontator/threads_helper.rb~ +5 -5
  16. data/app/mailers/commontator/subscriptions_mailer.rb +8 -8
  17. data/app/mailers/commontator/subscriptions_mailer.rb~ +9 -10
  18. data/app/models/commontator/comment.rb +14 -6
  19. data/app/models/commontator/comment.rb~ +15 -12
  20. data/app/views/commontator/comments/_actions.html.erb +6 -5
  21. data/app/views/commontator/comments/_actions.html.erb~ +6 -5
  22. data/app/views/commontator/comments/_body.html.erb +2 -1
  23. data/app/views/commontator/comments/_body.html.erb~ +1 -2
  24. data/app/views/commontator/comments/_form.html.erb +8 -3
  25. data/app/views/commontator/comments/_form.html.erb~ +7 -4
  26. data/app/views/commontator/comments/_show.html.erb +11 -8
  27. data/app/views/commontator/comments/_show.html.erb~ +11 -8
  28. data/app/views/commontator/comments/_votes.html.erb +7 -6
  29. data/app/views/commontator/comments/create.js.erb +4 -2
  30. data/app/views/commontator/comments/delete.js.erb +5 -3
  31. data/app/views/commontator/comments/delete.js.erb~ +5 -3
  32. data/app/views/commontator/comments/update.js.erb +1 -1
  33. data/app/views/commontator/comments/update.js.erb~ +1 -1
  34. data/app/views/commontator/comments/vote.js.erb +2 -1
  35. data/app/views/commontator/shared/_thread.html.erb +17 -0
  36. data/app/views/commontator/shared/_thread.html.erb~ +16 -0
  37. data/app/views/commontator/shared/_thread_link.html.erb~ +16 -0
  38. data/app/views/commontator/subscriptions/_link.html.erb +3 -2
  39. data/app/views/commontator/subscriptions/subscribe.js.erb +2 -1
  40. data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb +1 -1
  41. data/app/views/commontator/threads/_show.html.erb +18 -11
  42. data/app/views/commontator/threads/_show.html.erb~ +18 -11
  43. data/app/views/commontator/threads/show.js.erb +2 -1
  44. data/config/initializers/commontator.rb +14 -14
  45. data/db/migrate/0_install_commontator.rb +3 -3
  46. data/lib/commontator.rb +5 -6
  47. data/lib/commontator.rb~ +5 -6
  48. data/lib/commontator/acts_as_commontable.rb +2 -0
  49. data/lib/commontator/acts_as_commontator.rb +2 -0
  50. data/lib/commontator/controller_includes.rb +23 -0
  51. data/lib/commontator/controller_includes.rb~ +23 -0
  52. data/lib/commontator/shared_helper.rb +42 -0
  53. data/lib/commontator/shared_helper.rb~ +42 -0
  54. data/lib/commontator/shared_methods.rb~ +24 -0
  55. data/lib/commontator/version.rb +1 -1
  56. data/lib/commontator/version.rb~ +1 -1
  57. data/test/dummy/config/initializers/commontator.rb +15 -15
  58. data/test/dummy/db/development.sqlite3 +0 -0
  59. data/test/dummy/db/migrate/1_install_commontator.commontator.rb +3 -3
  60. data/test/dummy/db/schema.rb +3 -3
  61. data/test/dummy/log/development.log +64 -0
  62. metadata +10 -70
  63. data/app/assets/stylesheets/commontator/application.css~ +0 -88
  64. data/app/assets/stylesheets/commontator/threads.css~ +0 -13
  65. data/app/helpers/commontator/application_helper.rb~ +0 -11
  66. data/app/helpers/commontator/comments_helper.rb +0 -51
  67. data/app/helpers/commontator/commontable_helper.rb~ +0 -9
  68. data/app/helpers/commontator/commontator_helper.rb +0 -8
  69. data/app/helpers/commontator/commontator_helper.rb~ +0 -8
  70. data/app/helpers/commontator/subscriptions_helper.rb +0 -8
  71. data/app/mailers/commontator/subscription_mailer.rb~ +0 -38
  72. data/app/models/commontator/subscription.rb~ +0 -21
  73. data/app/models/commontator/thread.rb~ +0 -143
  74. data/app/views/commontator/comments/_votes.html.erb~ +0 -62
  75. data/app/views/commontator/comments/create.js.erb~ +0 -15
  76. data/app/views/commontator/comments/destroy.js.erb~ +0 -1
  77. data/app/views/commontator/comments/edit.html.erb~ +0 -6
  78. data/app/views/commontator/comments/edit.js.erb~ +0 -5
  79. data/app/views/commontator/comments/new.html.erb~ +0 -8
  80. data/app/views/commontator/comments/new.js.erb~ +0 -12
  81. data/app/views/commontator/comments/vote.js.erb~ +0 -5
  82. data/app/views/commontator/shared/_thread_link.html.erb +0 -13
  83. data/app/views/commontator/subscriptions/_index.html.erb~ +0 -16
  84. data/app/views/commontator/subscriptions/_link.html.erb~ +0 -15
  85. data/app/views/commontator/subscriptions/_subscription_link.html.erb~ +0 -13
  86. data/app/views/commontator/subscriptions/create.js.erb~ +0 -5
  87. data/app/views/commontator/subscriptions/destroy.js.erb~ +0 -3
  88. data/app/views/commontator/subscriptions/index.html.erb~ +0 -16
  89. data/app/views/commontator/subscriptions/subscribe.js.erb~ +0 -5
  90. data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb~ +0 -6
  91. data/app/views/commontator/threads/_actions.html.erb~ +0 -28
  92. data/app/views/commontator/threads/_link.html.erb~ +0 -14
  93. data/app/views/commontator/threads/close.js.erb~ +0 -5
  94. data/app/views/commontator/threads/show.html.erb~ +0 -3
  95. data/app/views/commontator/threads/show.js.erb~ +0 -6
  96. data/config/initializers/commontator.rb~ +0 -179
  97. data/config/routes.rb~ +0 -24
  98. data/db/migrate/0_install_commontator.rb~ +0 -48
  99. data/lib/commontator/acts_as_commontable.rb~ +0 -39
  100. data/lib/commontator/acts_as_commontator.rb~ +0 -28
  101. data/lib/commontator/commontable_config.rb~ +0 -13
  102. data/lib/commontator/commontator_config.rb~ +0 -13
  103. data/lib/commontator/routes.rb~ +0 -37
  104. data/lib/tasks/commontator_tasks.rake~ +0 -41
  105. data/test/dummy/config/initializers/commontator.rb~ +0 -179
  106. data/test/dummy/config/routes.rb~ +0 -3
  107. data/test/functional/comment_thread_subscriptions_controller_test.rb~ +0 -125
  108. data/test/functional/comments_controller_test.rb~ +0 -184
  109. data/test/functional/subscriptions_controller_test.rb~ +0 -122
  110. data/test/unit/comment_test.rb~ +0 -38
  111. data/test/unit/comment_thread_subscription_test.rb~ +0 -18
  112. data/test/unit/comment_thread_test.rb~ +0 -60
  113. data/test/unit/helpers/comment_thread_subscriptions_helper_test.rb~ +0 -7
  114. data/test/unit/helpers/comments_helper_test.rb~ +0 -7
  115. data/test/unit/helpers/subscriptions_helper_test.rb~ +0 -4
  116. data/test/unit/subscription_test.rb~ +0 -15
  117. data/test/unit/thread_test.rb~ +0 -57
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # Common Tator
1
+ # Commontator
2
2
 
3
- A Rails engine for comments
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.4.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 => "/commontator"
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
- 3. Views
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
- <%= commontator_thread_link(commontable) %>
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.
@@ -35,7 +35,7 @@
35
35
  padding: 8px;
36
36
  }
37
37
 
38
- .comment_profile_picture img {
38
+ .comment_gravatar_image img {
39
39
  margin-top: 5px;
40
40
  }
41
41
 
@@ -84,7 +84,3 @@
84
84
 
85
85
  padding-bottom: 7px;
86
86
  }
87
-
88
- .thread_new_comment textarea {
89
- width: 100%;
90
- }
@@ -1,19 +1,18 @@
1
1
  module Commontator
2
2
  class ApplicationController < ActionController::Base
3
- before_filter :get_commontator
3
+ before_filter :get_user
4
4
 
5
5
  protected
6
6
 
7
- def get_commontator
8
- @commontator = send Commontator.current_user_method
9
- raise SecurityTransgression unless (@commontator.nil? || @commontator.is_commontator)
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 :get_commontator
3
+ before_filter :get_user
4
4
 
5
5
  protected
6
6
 
7
- def get_commontator
8
- @commontator = send Commontator.current_user_method
9
- raise SecurityTransgression unless (@commontator.nil? || @commontator.is_commontator)
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.commontator = @commontator
11
+ @comment.creator = @user
11
12
 
12
- raise SecurityTransgression unless @comment.can_be_created_by?(@commontator)
13
+ raise SecurityTransgression unless @comment.can_be_created_by?(@user)
13
14
 
14
15
  respond_to do |format|
15
- format.html { redirect_to @commontable_url }
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.commontator = @commontator
26
+ @comment.creator = @user
26
27
 
27
- raise SecurityTransgression unless @comment.can_be_created_by?(@commontator)
28
+ raise SecurityTransgression unless @comment.can_be_created_by?(@user)
28
29
 
29
30
  if @comment.save
30
- @thread.subscribe(@commontator) if @thread.config.auto_subscribe_on_comment
31
- @thread.mark_as_unread_except_for(@commontator)
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(@commontator, @comment)
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 @commontable_url }
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?(@commontator)
47
+ raise SecurityTransgression unless @comment.can_be_edited_by?(@user)
47
48
 
48
49
  respond_to do |format|
49
- format.html { redirect_to @commontable_url }
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?(@commontator)
57
+ raise SecurityTransgression unless @comment.can_be_edited_by?(@user)
57
58
 
58
- @thread.comment_edited_callback(@commontator, @comment) \
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 @commontable_url }
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?(@commontator)
70
+ raise SecurityTransgression unless @comment.can_be_deleted_by?(@user)
70
71
 
71
- @comment.delete(@commontator)
72
- @thread.comment_deleted_callback(@commontator, @comment)
72
+ @comment.delete(@user)
73
+ @thread.comment_deleted_callback(@user, @comment)
73
74
 
74
75
  respond_to do |format|
75
- format.html { redirect_to @commontable_url }
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?(@commontator)
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 @commontable_url }
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?(@commontator)
95
+ raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
95
96
 
96
- @comment.upvote_from @commontator
97
+ @comment.upvote_from @user
97
98
 
98
99
  respond_to do |format|
99
- format.html { redirect_to @commontable_url }
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?(@commontator)
107
+ raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
107
108
 
108
- @comment.downvote_from @commontator
109
+ @comment.downvote_from @user
109
110
 
110
111
  respond_to do |format|
111
- format.html { redirect_to @commontable_url }
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?(@commontator)
119
+ raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
119
120
 
120
- @comment.unvote :voter => @commontator
121
+ @comment.unvote :voter => @user
121
122
 
122
123
  respond_to do |format|
123
- format.html { redirect_to @commontable_url }
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.commontator = @commontator
11
+ @comment.creator = @user
11
12
 
12
- raise SecurityTransgression unless @comment.can_be_created_by?(@commontator)
13
+ raise SecurityTransgression unless @comment.can_be_created_by?(@user)
13
14
 
14
15
  respond_to do |format|
15
- format.html { redirect_to @commontable_url }
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.commontator = @commontator
26
+ @comment.creator = @user
26
27
 
27
- raise SecurityTransgression unless @comment.can_be_created_by?(@commontator)
28
+ raise SecurityTransgression unless @comment.can_be_created_by?(@user)
28
29
 
29
30
  if @comment.save
30
- @thread.subscribe(@commontator) if @thread.config.auto_subscribe_on_comment
31
- @thread.mark_as_unread_except_for(@commontator)
32
- SubscriptionsMailer.comment_created_email(@comment)
33
- @thread.comment_created_callback(@commontator, @comment)
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 @commontable_url }
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?(@commontator)
47
+ raise SecurityTransgression unless @comment.can_be_edited_by?(@user)
47
48
 
48
49
  respond_to do |format|
49
- format.html { redirect_to @commontable_url }
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?(@commontator)
57
+ raise SecurityTransgression unless @comment.can_be_edited_by?(@user)
57
58
 
58
- @thread.comment_edited_callback(@commontator, @comment) \
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 @commontable_url }
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?(@commontator)
70
+ raise SecurityTransgression unless @comment.can_be_deleted_by?(@user)
70
71
 
71
- @comment.delete(@commontator)
72
- @thread.comment_deleted_callback(@commontator, @comment)
72
+ @comment.delete(@user)
73
+ @thread.comment_deleted_callback(@user, @comment)
73
74
 
74
75
  respond_to do |format|
75
- format.html { redirect_to @commontable_url }
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?(@commontator)
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 @commontable_url }
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?(@commontator)
95
+ raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
95
96
 
96
- @comment.upvote_from @commontator
97
+ @comment.upvote_from @user
97
98
 
98
99
  respond_to do |format|
99
- format.html { redirect_to @commontable_url }
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?(@commontator)
107
+ raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
107
108
 
108
- @comment.downvote_from @commontator
109
+ @comment.downvote_from @user
109
110
 
110
111
  respond_to do |format|
111
- format.html { redirect_to @commontable_url }
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?(@commontator)
119
+ raise SecurityTransgression unless @comment.can_be_voted_on_by?(@user)
119
120
 
120
- @comment.unvote :voter => @commontator
121
+ @comment.unvote :voter => @user
121
122
 
122
123
  respond_to do |format|
123
- format.html { redirect_to @commontable_url }
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