commontator 4.0.2 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -5
- data/app/assets/stylesheets/commontator/comments.css +16 -5
- data/app/assets/stylesheets/commontator/comments.css~ +98 -0
- data/app/controllers/commontator/application_controller.rb +6 -3
- data/app/controllers/commontator/application_controller.rb~ +30 -0
- data/app/controllers/commontator/threads_controller.rb +2 -0
- data/app/controllers/commontator/threads_controller.rb~ +44 -0
- data/app/helpers/commontator/threads_helper.rb +1 -8
- data/app/helpers/commontator/threads_helper.rb~ +11 -0
- data/app/mailers/commontator/subscriptions_mailer.rb +2 -4
- data/app/mailers/commontator/subscriptions_mailer.rb~ +50 -0
- data/app/models/commontator/comment.rb +23 -19
- data/app/models/commontator/comment.rb~ +106 -0
- data/app/models/commontator/thread.rb +10 -10
- data/app/models/commontator/thread.rb~ +124 -0
- data/app/views/commontator/comments/_show.html.erb +36 -34
- data/app/views/commontator/comments/_show.html.erb~ +47 -0
- data/app/views/commontator/comments/_votes.html.erb +6 -2
- data/app/views/commontator/comments/_votes.html.erb~ +61 -0
- data/app/views/commontator/comments/delete.js.erb +2 -2
- data/app/views/commontator/comments/delete.js.erb~ +17 -0
- data/app/views/commontator/comments/update.js.erb +2 -2
- data/app/views/commontator/comments/update.js.erb~ +7 -0
- data/app/views/commontator/subscriptions_mailer/comment_created.html.erb +2 -2
- data/app/views/commontator/subscriptions_mailer/comment_created.html.erb~ +6 -0
- data/app/views/commontator/threads/_show.html.erb +3 -7
- data/app/views/commontator/threads/_show.html.erb~ +58 -0
- data/config/initializers/commontator.rb +52 -47
- data/config/initializers/commontator.rb~ +176 -0
- data/lib/commontator.rb +6 -7
- data/lib/commontator.rb~ +61 -0
- data/lib/commontator/controller_includes.rb +1 -3
- data/lib/commontator/controller_includes.rb~ +22 -0
- data/lib/commontator/shared_helper.rb +3 -8
- data/lib/commontator/shared_helper.rb~ +37 -0
- data/lib/commontator/version.rb +1 -1
- data/lib/commontator/version.rb~ +3 -0
- data/spec/app/controllers/commontator/comments_controller_spec.rb +64 -45
- data/spec/app/controllers/commontator/comments_controller_spec.rb~ +580 -0
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +3 -3
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb~ +99 -0
- data/spec/app/controllers/commontator/threads_controller_spec.rb +15 -9
- data/spec/app/controllers/commontator/threads_controller_spec.rb~ +126 -0
- data/spec/app/helpers/commontator/application_helper_spec.rb +1 -1
- data/spec/app/helpers/commontator/application_helper_spec.rb~ +9 -0
- data/spec/app/helpers/commontator/threads_helper_spec.rb +1 -5
- data/spec/app/helpers/commontator/threads_helper_spec.rb~ +13 -0
- data/spec/app/models/commontator/comment_spec.rb +4 -3
- data/spec/app/models/commontator/comment_spec.rb~ +62 -0
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/application.rb~ +27 -0
- data/spec/dummy/config/initializers/commontator.rb +67 -55
- data/spec/dummy/config/initializers/commontator.rb~ +176 -0
- data/spec/dummy/config/initializers/commontator2.rb~ +169 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +84489 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/02d4b791eb831cf2057bf4703a1218d1 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/0f196a1a50363b0a076ec6e1ee5417f6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a41c8be5379abec3c0d0d98e2f0d5609 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e1f674c11941d62aac1764ef3a7134e4 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/e85565206c3e5fdf9dfeb367c85557b1 +0 -0
- data/spec/lib/commontator/commontable_config_spec.rb +1 -1
- data/spec/lib/commontator/commontable_config_spec.rb~ +26 -0
- data/spec/lib/commontator/commontator_config_spec.rb +5 -5
- data/spec/lib/commontator/commontator_config_spec.rb~ +26 -0
- data/spec/lib/commontator_spec.rb +6 -4
- data/spec/lib/commontator_spec.rb~ +28 -0
- data/spec/test_helper.rb +4 -4
- data/spec/test_helper.rb~ +37 -0
- metadata +46 -2
@@ -1,8 +1,8 @@
|
|
1
1
|
$("#comment_<%= @comment.id.to_s %>_body_div").html("<%= escape_javascript(
|
2
2
|
render :partial => 'body', :locals => {:comment => @comment}) %>");
|
3
3
|
|
4
|
-
$("#comment_<%= @comment.id.to_s %>
|
5
|
-
@comment.
|
4
|
+
$("#comment_<%= @comment.id.to_s %>_updated_timestamp_span").html("<%= escape_javascript(
|
5
|
+
"#{@comment.updated_timestamp} by #{commontator_name(@comment.editor)}") %>");
|
6
6
|
|
7
7
|
$("#comment_<%= @comment.id.to_s %>_actions_span").html("<%= escape_javascript(
|
8
8
|
render :partial => 'actions',
|
@@ -0,0 +1,17 @@
|
|
1
|
+
$("#comment_<%= @comment.id.to_s %>_body_div").html("<%= escape_javascript(
|
2
|
+
render :partial => 'body', :locals => {:comment => @comment}) %>");
|
3
|
+
|
4
|
+
$("#comment_<%= @comment.id.to_s %>_updated_timestamp_span").html("<%= escape_javascript(
|
5
|
+
"#{@comment.updated_timestamp} by #{commontator_name(comment.editor)}") %>");
|
6
|
+
|
7
|
+
$("#comment_<%= @comment.id.to_s %>_actions_span").html("<%= escape_javascript(
|
8
|
+
render :partial => 'actions',
|
9
|
+
:locals => {:comment => @comment,
|
10
|
+
:user => @user}) %>");
|
11
|
+
|
12
|
+
$("#comment_<%= @comment.id %>_votes_span").html("<%= escape_javascript(
|
13
|
+
render :partial => 'votes',
|
14
|
+
:locals => {:comment => @comment,
|
15
|
+
:user => @user}) %>");
|
16
|
+
|
17
|
+
<%= javascript_proc %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
$("#comment_<%= @comment.id.to_s %>_body_div").html("<%= escape_javascript(
|
2
2
|
render :partial => 'body', :locals => {:comment => @comment}) %>");
|
3
3
|
|
4
|
-
$("#comment_<%= @comment.id.to_s %>
|
5
|
-
|
4
|
+
$("#comment_<%= @comment.id.to_s %>_updated_timestamp_span").html("<%= escape_javascript(
|
5
|
+
"#{@comment.updated_timestamp} by #{commontator_name(@comment.editor)}") %>");
|
6
6
|
|
7
7
|
<%= javascript_proc %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
$("#comment_<%= @comment.id.to_s %>_body_div").html("<%= escape_javascript(
|
2
|
+
render :partial => 'body', :locals => {:comment => @comment}) %>");
|
3
|
+
|
4
|
+
$("#comment_<%= @comment.id.to_s %>_updated_timestamp_span").html("<%= escape_javascript(
|
5
|
+
@comment.updated_timestamp) %>");
|
6
|
+
|
7
|
+
<%= javascript_proc %>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<h4><%= @creator_name %>'s <%= @thread.config.comment_name %> on <%= @commontable_name
|
1
|
+
<h4><%= @creator_name %>'s <%= @thread.config.comment_name %> on <%= @commontable_name %>:</h4>
|
2
2
|
|
3
3
|
<%= render :partial => 'commontator/comments/body',
|
4
4
|
:locals => { :comment => @comment } %>
|
5
5
|
|
6
|
-
<p><a href="<%= @commontable_url %>">Click here</a> to
|
6
|
+
<p><a href="<%= @commontable_url %>">Click here</a> to view all comments on <%= @commontable_name %>.</p>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<h4><%= @creator_name %>'s <%= @thread.config.comment_name %> on <%= @commontable_name %>:</h4>
|
2
|
+
|
3
|
+
<%= render :partial => 'commontator/comments/body',
|
4
|
+
:locals => { :comment => @comment } %>
|
5
|
+
|
6
|
+
<p><a href="<%= @commontable_url %>">Click here</a> to view all comments on <%= @commontable_name %> <%= @commontable_id %>.</p>
|
@@ -44,19 +44,15 @@
|
|
44
44
|
<% end %>
|
45
45
|
</div>
|
46
46
|
|
47
|
-
<br/>
|
48
|
-
|
49
47
|
<% if thread.is_closed? %>
|
50
|
-
|
51
48
|
<p><%= thread.config.comment_name.capitalize.pluralize %> cannot be <%= thread.config.comment_create_verb_past %> at this time.</p>
|
52
|
-
|
49
|
+
<% elsif !user %>
|
50
|
+
<p>You must log in before you can <%= thread.config.comment_create_verb_present %> a <%= thread.config.comment_name %>.</p>
|
53
51
|
<% else %>
|
54
|
-
|
55
52
|
<div id="thread_<%= thread.id %>_new_comment_div" class="thread_new_comment"></div>
|
56
53
|
|
57
54
|
<span id="thread_<%= thread.id %>_new_comment_link_span" class="thread_new_comment_link">
|
58
|
-
<%= link_to thread.config.comment_create_verb_present.capitalize + ' ' + thread.config.comment_name,
|
55
|
+
<%= link_to thread.config.comment_create_verb_present.capitalize + ' new ' + thread.config.comment_name,
|
59
56
|
commontator.new_thread_comment_path(thread), :remote => true %>
|
60
57
|
</span>
|
61
|
-
|
62
58
|
<% end %>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<% # Clients of this partial must supply the following variables:
|
2
|
+
# thread
|
3
|
+
# user
|
4
|
+
%>
|
5
|
+
|
6
|
+
<% can_subscribe = thread.can_subscribe?(user) %>
|
7
|
+
<% can_edit = thread.can_be_edited_by?(user) %>
|
8
|
+
|
9
|
+
<span id="thread_<%= thread.id.to_s %>_header_span" class="thread_header">
|
10
|
+
<%= thread.config.comment_name.capitalize.pluralize + (thread.is_closed? ? ' (closed)' : '') %>
|
11
|
+
</span>
|
12
|
+
|
13
|
+
<span id="thread_<%= thread.id.to_s %>_actions_span" class="thread_actions">
|
14
|
+
<% if can_subscribe %>
|
15
|
+
<span id="thread_<%= thread.id.to_s %>_subscription_span" class="thread_subscription">
|
16
|
+
<%= render :partial => 'commontator/subscriptions/link',
|
17
|
+
:locals => {:thread => thread,
|
18
|
+
:user => user} %>
|
19
|
+
</span>
|
20
|
+
<% end %>
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
<% if can_edit %>
|
25
|
+
<% is_closed = thread.is_closed? %>
|
26
|
+
<% close_string = is_closed ? "reopen" : "close" %>
|
27
|
+
<%= link_to close_string.capitalize,
|
28
|
+
commontator.polymorphic_path([close_string, thread]),
|
29
|
+
:confirm => (!is_closed ? \
|
30
|
+
'Are you sure you want to close this thread?' : nil),
|
31
|
+
:method => :put,
|
32
|
+
:id => "thread_#{thread.id.to_s}_#{close_string}_link",
|
33
|
+
:class => "thread_#{close_string}_link",
|
34
|
+
:remote => true %>
|
35
|
+
<% end %>
|
36
|
+
</span>
|
37
|
+
|
38
|
+
<div id="thread_<%= thread.id.to_s %>_comment_list_div" class="thread_comment_list">
|
39
|
+
<% thread.ordered_comments.each do |comment| %>
|
40
|
+
<% next unless comment.can_be_read_by?(user) %>
|
41
|
+
<%= render :partial => 'commontator/comments/show',
|
42
|
+
:locals => {:comment => comment,
|
43
|
+
:user => user} %>
|
44
|
+
<% end %>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<% if thread.is_closed? %>
|
48
|
+
<p><%= thread.config.comment_name.capitalize.pluralize %> cannot be <%= thread.config.comment_create_verb_past %> at this time.</p>
|
49
|
+
<% elsif !user %>
|
50
|
+
<p>You must log in before you can <%= thread.config.comment_create_verb_present %> a <%= thread.config.comment_name %> to this thread.</p>
|
51
|
+
<% else %>
|
52
|
+
<div id="thread_<%= thread.id %>_new_comment_div" class="thread_new_comment"></div>
|
53
|
+
|
54
|
+
<span id="thread_<%= thread.id %>_new_comment_link_span" class="thread_new_comment_link">
|
55
|
+
<%= link_to thread.config.comment_create_verb_present.capitalize + ' new ' + thread.config.comment_name,
|
56
|
+
commontator.new_thread_comment_path(thread), :remote => true %>
|
57
|
+
</span>
|
58
|
+
<% end %>
|
@@ -3,9 +3,10 @@
|
|
3
3
|
Commontator.configure do |config|
|
4
4
|
# Engine Configuration
|
5
5
|
|
6
|
-
#
|
7
|
-
#
|
8
|
-
|
6
|
+
# Proc that is passed the current controller as argument
|
7
|
+
# Returns the current user
|
8
|
+
# Default: lambda { |controller| controller.current_user }
|
9
|
+
config.current_user_proc = lambda { |controller| controller.current_user }
|
9
10
|
|
10
11
|
# Proc that is called after any javascript runs (e.g. to display/clear flash messages)
|
11
12
|
# It is passed the view_context object (self from the view template), so you should be able to
|
@@ -17,32 +18,31 @@ Commontator.configure do |config|
|
|
17
18
|
|
18
19
|
|
19
20
|
# User (acts_as_commontator) Configuration
|
20
|
-
|
21
|
-
# The name used if the user's name cannot be retrieved
|
22
|
-
# Default: 'Anonymous'
|
23
|
-
config.user_missing_name = 'Anonymous'
|
24
21
|
|
25
22
|
# Whether the comment creator's name is clickable in the comment view
|
26
23
|
# If enabled, the link will point to the comment creator's 'show' page
|
27
24
|
# Default: false
|
28
25
|
config.user_name_clickable = false
|
29
26
|
|
30
|
-
#
|
31
|
-
#
|
32
|
-
|
27
|
+
# Proc called with user as argument
|
28
|
+
# Returns the user's name
|
29
|
+
# Default: lambda { |user| 'Anonymous' } (all users are Anonymous)
|
30
|
+
config.user_name_proc = lambda { |user| 'Anonymous' }
|
33
31
|
|
34
|
-
#
|
35
|
-
#
|
36
|
-
|
32
|
+
# Proc called with user as argument
|
33
|
+
# Returns the user's email address
|
34
|
+
# Used in the subscription mailer
|
35
|
+
# Default: lambda { |user| user.email }
|
36
|
+
config.user_email_proc = lambda { |user| user.email }
|
37
37
|
|
38
|
-
# Proc called with user as argument
|
39
|
-
#
|
40
|
-
#
|
38
|
+
# Proc called with user as argument
|
39
|
+
# Returns true iif the user is an admin
|
40
|
+
# Admins can delete other users' comments and close threads
|
41
41
|
# Default: lambda { |user| false } (no admins)
|
42
42
|
config.user_admin_proc = lambda { |user| false }
|
43
43
|
|
44
|
-
# Proc called with user as argument
|
45
|
-
#
|
44
|
+
# Proc called with user as argument
|
45
|
+
# Returns true iif the user should receive subscription emails
|
46
46
|
# Default: lambda { |user| true } (always receive subscription emails)
|
47
47
|
config.subscription_email_enable_proc = lambda { |user| true }
|
48
48
|
|
@@ -69,16 +69,9 @@ Commontator.configure do |config|
|
|
69
69
|
# Default: 'modified'
|
70
70
|
config.comment_edit_verb_past = 'modified'
|
71
71
|
|
72
|
-
# What a commontable is called in your application
|
73
|
-
# If you have multiple commontable models,
|
74
|
-
# you will want to pass this configuration value
|
75
|
-
# as an argument to acts_as_commontable in each one
|
76
|
-
# Default: 'commontable'
|
77
|
-
config.commontable_name = 'commontable'
|
78
|
-
|
79
72
|
# The format of the timestamps used by Commontator
|
80
|
-
# Default: '%b %d %Y
|
81
|
-
config.timestamp_format = '%b %d %Y
|
73
|
+
# Default: '%b %d %Y at %I:%M %p'
|
74
|
+
config.timestamp_format = '%b %d %Y at %I:%M %p'
|
82
75
|
|
83
76
|
# Whether admins can edit other users' comments
|
84
77
|
# Default: false
|
@@ -116,6 +109,11 @@ Commontator.configure do |config|
|
|
116
109
|
# Default: false
|
117
110
|
config.can_vote_on_comments = false
|
118
111
|
|
112
|
+
# Whether to display upvotes and downvotes
|
113
|
+
# combined or separately
|
114
|
+
# Default: true
|
115
|
+
config.combine_upvotes_and_downvotes = true
|
116
|
+
|
119
117
|
# Whether comments should be ordered by vote score
|
120
118
|
# instead of by order posted
|
121
119
|
# Default: false
|
@@ -125,47 +123,54 @@ Commontator.configure do |config|
|
|
125
123
|
# Default: true
|
126
124
|
config.closed_threads_are_readable = true
|
127
125
|
|
128
|
-
# Whether comments deleted by
|
129
|
-
# (the content will
|
126
|
+
# Whether to show that comments deleted by a moderator actually existed
|
127
|
+
# (the content will be hidden either way)
|
130
128
|
# Default: true
|
131
129
|
config.deleted_comments_are_visible = true
|
132
130
|
|
133
|
-
#
|
134
|
-
#
|
135
|
-
|
131
|
+
# Proc called with thread and user as arguments
|
132
|
+
# Returns true iif the user should be allowed to read that thread
|
133
|
+
# Note: can be called with a user object that is false or nil if not logged in
|
134
|
+
# Default: lambda { |thread, user| true } (anyone can read threads even if not logged in)
|
135
|
+
config.can_read_thread_proc = lambda { |thread, user| true }
|
136
136
|
|
137
137
|
# Proc called with thread and user as arguments
|
138
|
-
#
|
139
|
-
# and
|
140
|
-
# Note: user can be nil
|
138
|
+
# Returns true iif the user is a moderator for that particular thread
|
139
|
+
# and can delete users' comments in the thread or close it
|
141
140
|
# Default: lambda { |thread, user| false } (no thread-specific moderators)
|
142
141
|
config.can_edit_thread_proc = lambda { |thread, user| false }
|
143
142
|
|
144
|
-
# Proc called with
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
|
143
|
+
# Proc called with the commontable object as argument
|
144
|
+
# Returns the name by which the commontable object will be called in email messages
|
145
|
+
# If you have multiple commontable models, you may want to pass this
|
146
|
+
# configuration value as an argument to acts_as_commontable in each one
|
147
|
+
# Default: lambda { |commontable| "#{commontable.class.name} ##{commontable.id}" }
|
148
|
+
config.commontable_name_proc = lambda { |commontable| "#{commontable.class.name} ##{commontable.id}" }
|
149
149
|
|
150
|
-
# Proc
|
151
|
-
#
|
152
|
-
#
|
150
|
+
# Proc called with main_app and commontable objects as arguments
|
151
|
+
# Return the url that contains the commontable's thread to be used in the subscription email
|
152
|
+
# The application's routes can be accessed using the main_app object
|
153
153
|
# Default: lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
|
154
|
+
# (defaults to the commontable's show url)
|
154
155
|
config.commontable_url_proc = lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
|
155
156
|
|
156
|
-
# Proc
|
157
|
+
# Proc called with params from the subscription mailer as arguments
|
158
|
+
# Returns the subscription email 'from' address
|
159
|
+
# Available params can be seen in the subscription mailer
|
157
160
|
# Default:
|
158
161
|
# lambda { |params| 'no-reply@example.com' }
|
159
162
|
config.subscription_email_from_proc = lambda { |params| 'no-reply@example.com' }
|
160
163
|
|
161
|
-
# Proc
|
164
|
+
# Proc called with params from the subscription mailer as arguments
|
165
|
+
# Returns the subscription email 'subject' string
|
166
|
+
# Available params can be seen in the subscription mailer
|
162
167
|
# Default:
|
163
168
|
# lambda do |params|
|
164
169
|
# "#{params[:creator_name]} #{params[:config].comment_create_verb_past} a " + \
|
165
|
-
# "#{params[:config].comment_name} on #{params[:commontable_name]}
|
170
|
+
# "#{params[:config].comment_name} on #{params[:commontable_name]}"
|
166
171
|
# end
|
167
172
|
config.subscription_email_subject_proc = lambda do |params|
|
168
173
|
"#{params[:creator_name]} #{params[:config].comment_create_verb_past} a " + \
|
169
|
-
"#{params[:config].comment_name} on #{params[:commontable_name]}
|
174
|
+
"#{params[:config].comment_name} on #{params[:commontable_name]}"
|
170
175
|
end
|
171
176
|
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
# Change the settings below to suit your needs
|
2
|
+
# All settings are initially set to their default values
|
3
|
+
Commontator.configure do |config|
|
4
|
+
# Engine Configuration
|
5
|
+
|
6
|
+
# Proc that is passed the current controller as argument
|
7
|
+
# Returns the current user
|
8
|
+
# Default: 'current_user'
|
9
|
+
config.current_user_proc = lambda { |controller| controller.current_user }
|
10
|
+
|
11
|
+
# Proc that is called after any javascript runs (e.g. to display/clear flash messages)
|
12
|
+
# It is passed the view_context object (self from the view template), so you should be able to
|
13
|
+
# access anything you normally could in a view template (by using, e.g. view.flash)
|
14
|
+
# However, be aware that it does not have access to the main application's helpers
|
15
|
+
# Should return a string containing JS to be appended to all Commontator JS responses
|
16
|
+
# Default: lambda { |view| '$("#error_explanation").remove();' }
|
17
|
+
config.javascript_proc = lambda { |view| '$("#error_explanation").remove();' }
|
18
|
+
|
19
|
+
|
20
|
+
# User (acts_as_commontator) Configuration
|
21
|
+
|
22
|
+
# Whether the comment creator's name is clickable in the comment view
|
23
|
+
# If enabled, the link will point to the comment creator's 'show' page
|
24
|
+
# Default: false
|
25
|
+
config.user_name_clickable = false
|
26
|
+
|
27
|
+
# Proc called with user as argument
|
28
|
+
# Returns the user's name
|
29
|
+
# Default: lambda { |user| 'Anonymous' } (all users are Anonymous)
|
30
|
+
config.user_name_proc = lambda { |user| 'Anonymous' }
|
31
|
+
|
32
|
+
# Proc called with user as argument
|
33
|
+
# Returns the user's email address
|
34
|
+
# Used in the subscription mailer
|
35
|
+
# Default: lambda { |user| user.email }
|
36
|
+
config.user_email_proc = lambda { |user| user.email }
|
37
|
+
|
38
|
+
# Proc called with user as argument
|
39
|
+
# Returns true iif the user is an admin
|
40
|
+
# Admins can delete other users' comments and close threads
|
41
|
+
# Default: lambda { |user| false } (no admins)
|
42
|
+
config.user_admin_proc = lambda { |user| false }
|
43
|
+
|
44
|
+
# Proc called with user as argument
|
45
|
+
# Returns true iif the user should receive subscription emails
|
46
|
+
# Default: lambda { |user| true } (always receive subscription emails)
|
47
|
+
config.subscription_email_enable_proc = lambda { |user| true }
|
48
|
+
|
49
|
+
|
50
|
+
# Commontable (acts_as_commontable) Configuration
|
51
|
+
|
52
|
+
# What a comment is called in your application
|
53
|
+
# Default: 'comment'
|
54
|
+
config.comment_name = 'comment'
|
55
|
+
|
56
|
+
# Verb used when creating comments (present)
|
57
|
+
# Default: 'post'
|
58
|
+
config.comment_create_verb_present = 'post'
|
59
|
+
|
60
|
+
# Verb used when creating comments (past)
|
61
|
+
# Default: 'posted'
|
62
|
+
config.comment_create_verb_past = 'posted'
|
63
|
+
|
64
|
+
# Verb used when editing comments (present)
|
65
|
+
# Default: 'modify'
|
66
|
+
config.comment_edit_verb_present = 'modify'
|
67
|
+
|
68
|
+
# Verb used when editing comments (past)
|
69
|
+
# Default: 'modified'
|
70
|
+
config.comment_edit_verb_past = 'modified'
|
71
|
+
|
72
|
+
# The format of the timestamps used by Commontator
|
73
|
+
# Default: '%b %d %Y at %I:%M %p'
|
74
|
+
config.timestamp_format = '%b %d %Y at %I:%M %p'
|
75
|
+
|
76
|
+
# Whether admins can edit other users' comments
|
77
|
+
# Default: false
|
78
|
+
config.admin_can_edit_comments = false
|
79
|
+
|
80
|
+
# Whether users automatically subscribe to a thread when commenting
|
81
|
+
# Default: false
|
82
|
+
config.auto_subscribe_on_comment = false
|
83
|
+
|
84
|
+
# Whether users can edit their own comments
|
85
|
+
# Default: true
|
86
|
+
config.can_edit_own_comments = true
|
87
|
+
|
88
|
+
# Whether users can edit their own comments
|
89
|
+
# after someone posted a newer comment
|
90
|
+
# Default: false
|
91
|
+
config.can_edit_old_comments = false
|
92
|
+
|
93
|
+
# Whether users can delete their own comments
|
94
|
+
# Default: true
|
95
|
+
config.can_delete_own_comments = true
|
96
|
+
|
97
|
+
# Whether users can delete their own comments
|
98
|
+
# after someone posted a newer comment
|
99
|
+
# Default: false
|
100
|
+
config.can_delete_old_comments = false
|
101
|
+
|
102
|
+
# Whether users can manually subscribe or unsubscribe to threads
|
103
|
+
# Default: true
|
104
|
+
config.can_subscribe_to_thread = true
|
105
|
+
|
106
|
+
# Whether users can vote on other users' comments
|
107
|
+
# Note: requires acts_as_votable gem installed
|
108
|
+
# and configured for your application
|
109
|
+
# Default: false
|
110
|
+
config.can_vote_on_comments = false
|
111
|
+
|
112
|
+
# Whether to display upvotes and downvotes
|
113
|
+
# combined or separately
|
114
|
+
# Default: true
|
115
|
+
config.combine_upvotes_and_downvotes = true
|
116
|
+
|
117
|
+
# Whether comments should be ordered by vote score
|
118
|
+
# instead of by order posted
|
119
|
+
# Default: false
|
120
|
+
config.comments_ordered_by_votes = false
|
121
|
+
|
122
|
+
# Whether users can read threads closed by moderators
|
123
|
+
# Default: true
|
124
|
+
config.closed_threads_are_readable = true
|
125
|
+
|
126
|
+
# Whether to show that comments deleted by a moderator actually existed
|
127
|
+
# (the content will be hidden either way)
|
128
|
+
# Default: true
|
129
|
+
config.deleted_comments_are_visible = true
|
130
|
+
|
131
|
+
# Proc called with thread and user as arguments
|
132
|
+
# Returns true iif the user should be allowed to read that thread
|
133
|
+
# Note: can be called with a user object that is false or nil if not logged in
|
134
|
+
# Default: lambda { |thread, user| true } (anyone can read threads even if not logged in)
|
135
|
+
config.can_read_thread_proc = lambda { |thread, user| true }
|
136
|
+
|
137
|
+
# Proc called with thread and user as arguments
|
138
|
+
# Returns true iif the user is a moderator for that particular thread
|
139
|
+
# and can delete users' comments in the thread or close it
|
140
|
+
# Default: lambda { |thread, user| false } (no thread-specific moderators)
|
141
|
+
config.can_edit_thread_proc = lambda { |thread, user| false }
|
142
|
+
|
143
|
+
# Proc called with the commontable object as argument
|
144
|
+
# Returns the name by which the commontable object will be called in email messages
|
145
|
+
# If you have multiple commontable models, you may want to pass this
|
146
|
+
# configuration value as an argument to acts_as_commontable in each one
|
147
|
+
# Default: lambda { |commontable| "#{commontable.class.name} ##{commontable.id}" }
|
148
|
+
config.commontable_name_proc = lambda { |commontable| "#{commontable.class.name} ##{commontable.id}" }
|
149
|
+
|
150
|
+
# Proc called with main_app and commontable objects as arguments
|
151
|
+
# Return the url that contains the commontable's thread to be used in the subscription email
|
152
|
+
# The application's routes can be accessed using the main_app object
|
153
|
+
# Default: lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
|
154
|
+
# (defaults to the commontable's show url)
|
155
|
+
config.commontable_url_proc = lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
|
156
|
+
|
157
|
+
# Proc called with params from the subscription mailer as arguments
|
158
|
+
# Returns the subscription email 'from' address
|
159
|
+
# Available params can be seen in the subscription mailer
|
160
|
+
# Default:
|
161
|
+
# lambda { |params| 'no-reply@example.com' }
|
162
|
+
config.subscription_email_from_proc = lambda { |params| 'no-reply@example.com' }
|
163
|
+
|
164
|
+
# Proc called with params from the subscription mailer as arguments
|
165
|
+
# Returns the subscription email 'subject' string
|
166
|
+
# Available params can be seen in the subscription mailer
|
167
|
+
# Default:
|
168
|
+
# lambda do |params|
|
169
|
+
# "#{params[:creator_name]} #{params[:config].comment_create_verb_past} a " + \
|
170
|
+
# "#{params[:config].comment_name} on #{params[:commontable_name]}"
|
171
|
+
# end
|
172
|
+
config.subscription_email_subject_proc = lambda do |params|
|
173
|
+
"#{params[:creator_name]} #{params[:config].comment_create_verb_past} a " + \
|
174
|
+
"#{params[:config].comment_name} on #{params[:commontable_name]}"
|
175
|
+
end
|
176
|
+
end
|