commontator 0.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
- data/README.md +35 -0
- data/Rakefile +40 -0
- data/app/assets/images/commontator/downvote.png +0 -0
- data/app/assets/images/commontator/downvote_hover.png +0 -0
- data/app/assets/images/commontator/upvote.png +0 -0
- data/app/assets/images/commontator/upvote_hover.png +0 -0
- data/app/assets/stylesheets/commontator/application.css +13 -0
- data/app/assets/stylesheets/commontator/application.css~ +88 -0
- data/app/assets/stylesheets/commontator/comments.css +86 -0
- data/app/assets/stylesheets/commontator/comments.css~ +90 -0
- data/app/assets/stylesheets/commontator/threads.css +13 -0
- data/app/assets/stylesheets/commontator/threads.css~ +13 -0
- data/app/controllers/commontator/application_controller.rb +18 -0
- data/app/controllers/commontator/application_controller.rb~ +16 -0
- data/app/controllers/commontator/comments_controller.rb +143 -0
- data/app/controllers/commontator/comments_controller.rb~ +143 -0
- data/app/controllers/commontator/subscriptions_controller.rb +42 -0
- data/app/controllers/commontator/subscriptions_controller.rb~ +40 -0
- data/app/controllers/commontator/threads_controller.rb +42 -0
- data/app/controllers/commontator/threads_controller.rb~ +43 -0
- data/app/helpers/commontator/application_helper.rb +11 -0
- data/app/helpers/commontator/application_helper.rb~ +11 -0
- data/app/helpers/commontator/comments_helper.rb +47 -0
- data/app/helpers/commontator/comments_helper.rb~ +58 -0
- data/app/helpers/commontator/commontable_helper.rb~ +9 -0
- data/app/helpers/commontator/commontator_helper.rb +8 -0
- data/app/helpers/commontator/commontator_helper.rb~ +8 -0
- data/app/helpers/commontator/subscriptions_helper.rb +8 -0
- data/app/helpers/commontator/subscriptions_helper.rb~ +8 -0
- data/app/helpers/commontator/threads_helper.rb +21 -0
- data/app/helpers/commontator/threads_helper.rb~ +32 -0
- data/app/mailers/commontator/subscription_mailer.rb~ +38 -0
- data/app/mailers/commontator/subscriptions_mailer.rb +51 -0
- data/app/mailers/commontator/subscriptions_mailer.rb~ +51 -0
- data/app/models/commontator/comment.rb +84 -0
- data/app/models/commontator/comment.rb~ +84 -0
- data/app/models/commontator/subscription.rb +21 -0
- data/app/models/commontator/subscription.rb~ +21 -0
- data/app/models/commontator/thread.rb +138 -0
- data/app/models/commontator/thread.rb~ +141 -0
- data/app/views/commontator/comments/_actions.html.erb +32 -0
- data/app/views/commontator/comments/_actions.html.erb~ +33 -0
- data/app/views/commontator/comments/_body.html.erb +7 -0
- data/app/views/commontator/comments/_body.html.erb~ +8 -0
- data/app/views/commontator/comments/_form.html.erb +20 -0
- data/app/views/commontator/comments/_form.html.erb~ +21 -0
- data/app/views/commontator/comments/_show.html.erb +41 -0
- data/app/views/commontator/comments/_show.html.erb~ +45 -0
- data/app/views/commontator/comments/_votes.html.erb +60 -0
- data/app/views/commontator/comments/_votes.html.erb~ +62 -0
- data/app/views/commontator/comments/create.js.erb +15 -0
- data/app/views/commontator/comments/create.js.erb~ +15 -0
- data/app/views/commontator/comments/delete.js.erb +15 -0
- data/app/views/commontator/comments/delete.js.erb~ +15 -0
- data/app/views/commontator/comments/destroy.js.erb~ +1 -0
- data/app/views/commontator/comments/edit.html.erb +6 -0
- data/app/views/commontator/comments/edit.html.erb~ +6 -0
- data/app/views/commontator/comments/edit.js.erb +5 -0
- data/app/views/commontator/comments/edit.js.erb~ +5 -0
- data/app/views/commontator/comments/new.html.erb +8 -0
- data/app/views/commontator/comments/new.html.erb~ +8 -0
- data/app/views/commontator/comments/new.js.erb +12 -0
- data/app/views/commontator/comments/new.js.erb~ +12 -0
- data/app/views/commontator/comments/update.js.erb +7 -0
- data/app/views/commontator/comments/update.js.erb~ +7 -0
- data/app/views/commontator/comments/vote.js.erb +5 -0
- data/app/views/commontator/comments/vote.js.erb~ +5 -0
- data/app/views/commontator/commontator/_thread.html.erb +14 -0
- data/app/views/commontator/commontator/_thread.html.erb~ +15 -0
- data/app/views/commontator/subscriptions/_subscription_link.html.erb +12 -0
- data/app/views/commontator/subscriptions/_subscription_link.html.erb~ +12 -0
- data/app/views/commontator/subscriptions/create.js.erb +5 -0
- data/app/views/commontator/subscriptions/create.js.erb~ +3 -0
- data/app/views/commontator/subscriptions/destroy.js.erb +5 -0
- data/app/views/commontator/subscriptions/destroy.js.erb~ +3 -0
- data/app/views/commontator/subscriptions/index.html.erb +16 -0
- data/app/views/commontator/subscriptions/index.html.erb~ +16 -0
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb +14 -0
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb~ +14 -0
- data/app/views/commontator/threads/_show.html.erb +26 -0
- data/app/views/commontator/threads/_show.html.erb~ +26 -0
- data/app/views/commontator/threads/show.html.erb +3 -0
- data/app/views/commontator/threads/show.js.erb +6 -0
- data/app/views/layouts/commontator/application.html.erb +14 -0
- data/config/initializers/commontator.rb +7 -0
- data/config/routes.rb +24 -0
- data/config/routes.rb~ +22 -0
- data/db/migrate/0_install_commontator.rb +40 -0
- data/db/migrate/0_install_commontator.rb~ +40 -0
- data/lib/commontator.rb +66 -0
- data/lib/commontator.rb~ +66 -0
- data/lib/commontator/acts_as_commontable.rb +39 -0
- data/lib/commontator/acts_as_commontable.rb~ +42 -0
- data/lib/commontator/acts_as_commontator.rb +28 -0
- data/lib/commontator/acts_as_commontator.rb~ +37 -0
- data/lib/commontator/commontable_config.rb +13 -0
- data/lib/commontator/commontator_config.rb +13 -0
- data/lib/commontator/engine.rb +5 -0
- data/lib/commontator/routes.rb~ +37 -0
- data/lib/commontator/version.rb +3 -0
- data/lib/commontator/version.rb~ +3 -0
- data/test/commontator_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +16 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +204 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/functional/comment_thread_subscriptions_controller_test.rb~ +125 -0
- data/test/functional/comments_controller_test.rb +181 -0
- data/test/functional/comments_controller_test.rb~ +184 -0
- data/test/functional/subscriptions_controller_test.rb +122 -0
- data/test/functional/subscriptions_controller_test.rb~ +122 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/comment_test.rb +35 -0
- data/test/unit/comment_test.rb~ +38 -0
- data/test/unit/comment_thread_subscription_test.rb~ +18 -0
- data/test/unit/comment_thread_test.rb~ +60 -0
- data/test/unit/helpers/comment_thread_subscriptions_helper_test.rb~ +7 -0
- data/test/unit/helpers/comments_helper_test.rb +4 -0
- data/test/unit/helpers/comments_helper_test.rb~ +7 -0
- data/test/unit/helpers/subscriptions_helper_test.rb +4 -0
- data/test/unit/helpers/subscriptions_helper_test.rb~ +4 -0
- data/test/unit/subscription_test.rb +15 -0
- data/test/unit/subscription_test.rb~ +15 -0
- data/test/unit/thread_test.rb +57 -0
- data/test/unit/thread_test.rb~ +57 -0
- metadata +301 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
module Commontator
|
|
2
|
+
class CommentsController < ApplicationController
|
|
3
|
+
include ThreadsHelper
|
|
4
|
+
|
|
5
|
+
before_filter :get_thread, :only => [:new, :create]
|
|
6
|
+
before_filter :get_comment_and_thread, :except => [:new, :create]
|
|
7
|
+
|
|
8
|
+
# GET /1/comments/new
|
|
9
|
+
def new
|
|
10
|
+
@comment = Comment.new
|
|
11
|
+
@comment.thread = @thread
|
|
12
|
+
@comment.commontator = @commontator
|
|
13
|
+
|
|
14
|
+
raise SecurityTransgression unless @comment.can_be_created_by?(@commontator)
|
|
15
|
+
|
|
16
|
+
respond_to do |format|
|
|
17
|
+
format.html
|
|
18
|
+
format.js
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# POST /1/comments
|
|
24
|
+
def create
|
|
25
|
+
@comment = Comment.new(params[:comment])
|
|
26
|
+
@comment.thread = @thread
|
|
27
|
+
@comment.commontator = @commontator
|
|
28
|
+
|
|
29
|
+
raise SecurityTransgression unless @comment.can_be_created_by?(@commontator)
|
|
30
|
+
|
|
31
|
+
respond_to do |format|
|
|
32
|
+
if @comment.save
|
|
33
|
+
@thread.subscribe(@commontator) if @thread.config.auto_subscribe_on_comment
|
|
34
|
+
@thread.mark_as_unread_except_for(@commontator)
|
|
35
|
+
SubscriptionsMailer.comment_created_email(@comment)
|
|
36
|
+
@thread.comment_created_callback(@commontator, @comment)
|
|
37
|
+
flash[:notice] = @thread.config.comment_name + ' ' + @thread.config.comment_create_verb_past
|
|
38
|
+
format.html { redirect_to @thread }
|
|
39
|
+
format.js
|
|
40
|
+
else
|
|
41
|
+
@errors = @comment.errors
|
|
42
|
+
format.html { render :action => 'new' }
|
|
43
|
+
format.js
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# GET /comments/1/edit
|
|
49
|
+
def edit
|
|
50
|
+
raise SecurityTransgression unless @comment.can_be_edited_by?(@commontator)
|
|
51
|
+
|
|
52
|
+
respond_to do |format|
|
|
53
|
+
format.html
|
|
54
|
+
format.js
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# PUT /comments/1
|
|
59
|
+
def update
|
|
60
|
+
raise SecurityTransgression unless @comment.can_be_edited_by?(@commontator)
|
|
61
|
+
|
|
62
|
+
respond_to do |format|
|
|
63
|
+
if @comment.update_attributes(params[:comment])
|
|
64
|
+
flash[:notice] = @thread.config.comment_name + ' updated'
|
|
65
|
+
@thread.comment_edited_callback(@commontator, @comment)
|
|
66
|
+
format.html { redirect_to @thread }
|
|
67
|
+
format.js
|
|
68
|
+
else
|
|
69
|
+
format.html { render :action => "edit" }
|
|
70
|
+
format.js
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# PUT /comments/1/delete
|
|
76
|
+
def delete
|
|
77
|
+
raise SecurityTransgression unless @comment.can_be_deleted_by?(@commontator)
|
|
78
|
+
|
|
79
|
+
@comment.delete(@commontator)
|
|
80
|
+
@thread.comment_deleted_callback(@commontator, @comment)
|
|
81
|
+
|
|
82
|
+
respond_to do |format|
|
|
83
|
+
format.html { redirect_to @thread }
|
|
84
|
+
format.js { render :delete }
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# PUT /comments/1/undelete
|
|
89
|
+
def undelete
|
|
90
|
+
raise SecurityTransgression unless @comment.can_be_deleted_by?(@commontator)
|
|
91
|
+
|
|
92
|
+
@comment.undelete
|
|
93
|
+
|
|
94
|
+
respond_to do |format|
|
|
95
|
+
format.html { redirect_to @thread }
|
|
96
|
+
format.js { render :delete }
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# PUT /comments/1/upvote
|
|
101
|
+
def upvote
|
|
102
|
+
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@commontator)
|
|
103
|
+
|
|
104
|
+
@comment.upvote_from @commontator
|
|
105
|
+
|
|
106
|
+
respond_to do |format|
|
|
107
|
+
format.html { redirect_to @thread }
|
|
108
|
+
format.js { render :vote }
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# PUT /comments/1/downvote
|
|
113
|
+
def downvote
|
|
114
|
+
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@commontator)
|
|
115
|
+
|
|
116
|
+
@comment.downvote_from @commontator
|
|
117
|
+
|
|
118
|
+
respond_to do |format|
|
|
119
|
+
format.html { redirect_to @thread }
|
|
120
|
+
format.js { render :vote }
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# PUT /comments/1/unvote
|
|
125
|
+
def unvote
|
|
126
|
+
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@commontator)
|
|
127
|
+
|
|
128
|
+
@comment.unvote :voter => @commontator
|
|
129
|
+
|
|
130
|
+
respond_to do |format|
|
|
131
|
+
format.html { redirect_to @thread }
|
|
132
|
+
format.js { render :vote }
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
protected
|
|
137
|
+
|
|
138
|
+
def get_comment_and_thread
|
|
139
|
+
@comment = Comment.find(params[:id])
|
|
140
|
+
@thread = @comment.thread
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
module Commontator
|
|
2
|
+
class CommentsController < ApplicationController
|
|
3
|
+
include ThreadsHelper
|
|
4
|
+
|
|
5
|
+
before_filter :get_thread, :only => [:new, :create]
|
|
6
|
+
before_filter :get_comment_and_thread, :except => [:new, :create]
|
|
7
|
+
|
|
8
|
+
# GET /1/comments/new
|
|
9
|
+
def new
|
|
10
|
+
@comment = Comment.new
|
|
11
|
+
@comment.thread = @thread
|
|
12
|
+
@comment.commontator = @commontator
|
|
13
|
+
|
|
14
|
+
raise SecurityTransgression unless @comment.can_be_created_by?(@commontator)
|
|
15
|
+
|
|
16
|
+
respond_to do |format|
|
|
17
|
+
format.html
|
|
18
|
+
format.js
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# POST /1/comments
|
|
24
|
+
def create
|
|
25
|
+
@comment = Comment.new(params[:comment])
|
|
26
|
+
@comment.thread = @thread
|
|
27
|
+
@comment.commontator = @commontator
|
|
28
|
+
|
|
29
|
+
raise SecurityTransgression unless @comment.can_be_created_by?(@commontator)
|
|
30
|
+
|
|
31
|
+
respond_to do |format|
|
|
32
|
+
if @comment.save
|
|
33
|
+
@thread.subscribe(@commontator) if @thread.config.auto_subscribe_on_comment
|
|
34
|
+
@thread.mark_as_unread_except_for(@commontator)
|
|
35
|
+
SubscriptionsMailer.comment_created_email(@comment)
|
|
36
|
+
@thread.comment_created_callback(@commontator, @comment)
|
|
37
|
+
flash[:notice] = @thread.config.comment_name + ' ' + @thread.config.comment_create_verb_past
|
|
38
|
+
format.html { redirect_to @thread }
|
|
39
|
+
format.js
|
|
40
|
+
else
|
|
41
|
+
@errors = @comment.errors
|
|
42
|
+
format.html { render :action => 'new' }
|
|
43
|
+
format.js
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# GET /comments/1/edit
|
|
49
|
+
def edit
|
|
50
|
+
raise SecurityTransgression unless @comment.can_be_edited_by?(@commontator)
|
|
51
|
+
|
|
52
|
+
respond_to do |format|
|
|
53
|
+
format.html
|
|
54
|
+
format.js
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# PUT /comments/1
|
|
59
|
+
def update
|
|
60
|
+
raise SecurityTransgression unless @comment.can_be_edited_by?(@commontator)
|
|
61
|
+
|
|
62
|
+
respond_to do |format|
|
|
63
|
+
if @comment.update_attributes(params[:comment])
|
|
64
|
+
flash[:notice] = @thread.config.comment_name + ' updated'
|
|
65
|
+
@thread.comment_edited_callback(@commontator, @comment)
|
|
66
|
+
format.html { redirect_to @thread }
|
|
67
|
+
format.js
|
|
68
|
+
else
|
|
69
|
+
format.html { render :action => "edit" }
|
|
70
|
+
format.js
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# PUT /comments/1/delete
|
|
76
|
+
def delete
|
|
77
|
+
raise SecurityTransgression unless @comment.can_be_deleted_by?(@commontator)
|
|
78
|
+
|
|
79
|
+
@comment.delete(@commontator)
|
|
80
|
+
@thread.comment_deleted_callback(@commontator, @comment)
|
|
81
|
+
|
|
82
|
+
respond_to do |format|
|
|
83
|
+
format.html { redirect_to @thread }
|
|
84
|
+
format.js { render :delete }
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# PUT /comments/1/undelete
|
|
89
|
+
def undelete
|
|
90
|
+
raise SecurityTransgression unless @comment.can_be_deleted_by?(@commontator)
|
|
91
|
+
|
|
92
|
+
@comment.undelete
|
|
93
|
+
|
|
94
|
+
respond_to do |format|
|
|
95
|
+
format.html { redirect_to @thread }
|
|
96
|
+
format.js { render :update }
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# PUT /comments/1/upvote
|
|
101
|
+
def upvote
|
|
102
|
+
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@commontator)
|
|
103
|
+
|
|
104
|
+
@comment.upvote_from @commontator
|
|
105
|
+
|
|
106
|
+
respond_to do |format|
|
|
107
|
+
format.html { redirect_to @thread }
|
|
108
|
+
format.js { render :vote }
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# PUT /comments/1/downvote
|
|
113
|
+
def downvote
|
|
114
|
+
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@commontator)
|
|
115
|
+
|
|
116
|
+
@comment.downvote_from @commontator
|
|
117
|
+
|
|
118
|
+
respond_to do |format|
|
|
119
|
+
format.html { redirect_to @thread }
|
|
120
|
+
format.js { render :vote }
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# PUT /comments/1/unvote
|
|
125
|
+
def unvote
|
|
126
|
+
raise SecurityTransgression unless @comment.can_be_voted_on_by?(@commontator)
|
|
127
|
+
|
|
128
|
+
@comment.unvote :voter => @commontator
|
|
129
|
+
|
|
130
|
+
respond_to do |format|
|
|
131
|
+
format.html { redirect_to @thread }
|
|
132
|
+
format.js { render :vote }
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
protected
|
|
137
|
+
|
|
138
|
+
def get_comment_and_thread
|
|
139
|
+
@comment = Comment.find(params[:id])
|
|
140
|
+
@thread = @comment.thread
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Commontator
|
|
2
|
+
class SubscriptionsController < ApplicationController
|
|
3
|
+
include ThreadsHelper
|
|
4
|
+
|
|
5
|
+
before_filter :get_thread, :except => :index
|
|
6
|
+
|
|
7
|
+
# GET /subscriptions
|
|
8
|
+
def index
|
|
9
|
+
@threads = Subscription.find_all_by_subscriber_id(@commontator.id)\
|
|
10
|
+
.collect { |cts| cts.thread }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# POST /1/subscribe
|
|
14
|
+
def create
|
|
15
|
+
raise SecurityTransgression unless @thread.can_subscribe?(@commontator)
|
|
16
|
+
|
|
17
|
+
if !@thread.subscribe(@commontator)
|
|
18
|
+
flash[:alert] = "You are already subscribed to this " + commontable_name(@thread)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
respond_to do |format|
|
|
22
|
+
format.html { redirect_to @thread }
|
|
23
|
+
format.js
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# POST /1/unsubscribe
|
|
29
|
+
def destroy
|
|
30
|
+
raise SecurityTransgression unless @thread.can_subscribe?(@commontator)
|
|
31
|
+
|
|
32
|
+
if !@thread.unsubscribe(@commontator)
|
|
33
|
+
flash[:alert] = "You are not subscribed to this " + commontable_name(@thread)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
respond_to do |format|
|
|
37
|
+
format.html { redirect_to @thread }
|
|
38
|
+
format.js
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Commontator
|
|
2
|
+
class SubscriptionsController < ApplicationController
|
|
3
|
+
before_filter :get_thread, :except => :index
|
|
4
|
+
|
|
5
|
+
# GET /subscriptions
|
|
6
|
+
def index
|
|
7
|
+
@threads = Subscription.find_all_by_subscriber_id(@commontator.id)\
|
|
8
|
+
.collect { |cts| cts.thread }
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# POST /1/subscribe
|
|
12
|
+
def create
|
|
13
|
+
raise SecurityTransgression unless @thread.can_subscribe?(@commontator)
|
|
14
|
+
|
|
15
|
+
if !@thread.subscribe(@commontator)
|
|
16
|
+
flash[:alert] = "You are already subscribed to this " + commontable_name(@thread)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
respond_to do |format|
|
|
20
|
+
format.html { redirect_to @thread }
|
|
21
|
+
format.js
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# POST /1/unsubscribe
|
|
27
|
+
def destroy
|
|
28
|
+
raise SecurityTransgression unless @thread.can_subscribe?(@commontator)
|
|
29
|
+
|
|
30
|
+
if !@thread.unsubscribe(@commontator)
|
|
31
|
+
flash[:alert] = "You are not subscribed to this " + commontable_name(@thread)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
respond_to do |format|
|
|
35
|
+
format.html { redirect_to @thread }
|
|
36
|
+
format.js
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Commontator
|
|
2
|
+
class ThreadsController < ApplicationController
|
|
3
|
+
before_filter :get_thread
|
|
4
|
+
|
|
5
|
+
# GET /threads/1
|
|
6
|
+
def show
|
|
7
|
+
raise SecurityTransgression unless @thread.can_be_read_by?(@commontator)
|
|
8
|
+
|
|
9
|
+
@thread.mark_as_read_for(@commontator)
|
|
10
|
+
|
|
11
|
+
respond_to do |format|
|
|
12
|
+
format.html
|
|
13
|
+
format.js
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# PUT /threads/1/close
|
|
18
|
+
def close
|
|
19
|
+
raise SecurityTransgression unless @thread.can_be_edited_by?(@commontator)
|
|
20
|
+
|
|
21
|
+
@thread.close(@commontator)
|
|
22
|
+
@thread.thread_closed_callback(@commontator)
|
|
23
|
+
|
|
24
|
+
respond_to do |format|
|
|
25
|
+
format.html { redirect_to @thread }
|
|
26
|
+
format.js
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# PUT /threads/1/reopen
|
|
31
|
+
def reopen
|
|
32
|
+
raise SecurityTransgression unless @thread.can_be_edited_by?(@commontator)
|
|
33
|
+
|
|
34
|
+
@thread.reopen
|
|
35
|
+
|
|
36
|
+
respond_to do |format|
|
|
37
|
+
format.html { redirect_to @thread }
|
|
38
|
+
format.js
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Commontator
|
|
2
|
+
class ThreadsController < ApplicationController
|
|
3
|
+
|
|
4
|
+
before_filter :get_thread
|
|
5
|
+
|
|
6
|
+
# GET /threads/1
|
|
7
|
+
def show
|
|
8
|
+
raise SecurityTransgression unless @thread.can_be_read_by?(@commontator)
|
|
9
|
+
|
|
10
|
+
@thread.mark_as_read_for(@commontator)
|
|
11
|
+
|
|
12
|
+
respond_to do |format|
|
|
13
|
+
format.html
|
|
14
|
+
format.js
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# PUT /threads/1/close
|
|
19
|
+
def close
|
|
20
|
+
raise SecurityTransgression unless @thread.can_be_edited_by?(@commontator)
|
|
21
|
+
|
|
22
|
+
@thread.close(@commontator)
|
|
23
|
+
@thread.thread_closed_callback(@commontator)
|
|
24
|
+
|
|
25
|
+
respond_to do |format|
|
|
26
|
+
format.html { redirect_to @thread }
|
|
27
|
+
format.js
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# PUT /threads/1/reopen
|
|
32
|
+
def reopen
|
|
33
|
+
raise SecurityTransgression unless @thread.can_be_edited_by?(@commontator)
|
|
34
|
+
|
|
35
|
+
@thread.reopen
|
|
36
|
+
|
|
37
|
+
respond_to do |format|
|
|
38
|
+
format.html { redirect_to @thread }
|
|
39
|
+
format.js
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|