commontator 4.0.2 → 4.1.1
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.
- 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
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require "commontator"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
+
|
18
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
+
# config.i18n.default_locale = :de
|
21
|
+
|
22
|
+
config.generators do |g|
|
23
|
+
g.test_framework :mini_test, :spec => true, :fixture => false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# Change the settings below to suit your needs
|
2
2
|
# All settings are initially set to their default values
|
3
3
|
Commontator.configure do |config|
|
4
|
-
|
5
4
|
# Engine Configuration
|
6
5
|
|
7
|
-
#
|
8
|
-
#
|
9
|
-
|
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 }
|
10
10
|
|
11
11
|
# Proc that is called after any javascript runs (e.g. to display/clear flash messages)
|
12
12
|
# It is passed the view_context object (self from the view template), so you should be able to
|
@@ -14,36 +14,35 @@ Commontator.configure do |config|
|
|
14
14
|
# However, be aware that it does not have access to the main application's helpers
|
15
15
|
# Should return a string containing JS to be appended to all Commontator JS responses
|
16
16
|
# Default: lambda { |view| '$("#error_explanation").remove();' }
|
17
|
-
config.javascript_proc = lambda { |view| '
|
17
|
+
config.javascript_proc = lambda { |view| '' }
|
18
18
|
|
19
19
|
|
20
20
|
# User (acts_as_commontator) Configuration
|
21
|
-
|
22
|
-
# The name used if the user's name cannot be retrieved
|
23
|
-
# Default: 'Anonymous'
|
24
|
-
config.user_missing_name = 'Anonymous'
|
25
21
|
|
26
22
|
# Whether the comment creator's name is clickable in the comment view
|
27
|
-
# If enabled, the link will point to the comment creator's show page
|
23
|
+
# If enabled, the link will point to the comment creator's 'show' page
|
28
24
|
# Default: false
|
29
25
|
config.user_name_clickable = false
|
30
26
|
|
31
|
-
#
|
32
|
-
#
|
33
|
-
|
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' }
|
34
31
|
|
35
|
-
#
|
36
|
-
#
|
37
|
-
|
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 }
|
38
37
|
|
39
|
-
# Proc called with user as argument
|
40
|
-
#
|
41
|
-
#
|
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
|
42
41
|
# Default: lambda { |user| false } (no admins)
|
43
|
-
config.user_admin_proc = lambda { |user| user.
|
42
|
+
config.user_admin_proc = lambda { |user| user.is_admin }
|
44
43
|
|
45
|
-
# Proc called with user as argument
|
46
|
-
#
|
44
|
+
# Proc called with user as argument
|
45
|
+
# Returns true iif the user should receive subscription emails
|
47
46
|
# Default: lambda { |user| true } (always receive subscription emails)
|
48
47
|
config.subscription_email_enable_proc = lambda { |user| true }
|
49
48
|
|
@@ -62,16 +61,17 @@ Commontator.configure do |config|
|
|
62
61
|
# Default: 'posted'
|
63
62
|
config.comment_create_verb_past = 'posted'
|
64
63
|
|
65
|
-
#
|
66
|
-
#
|
67
|
-
|
68
|
-
|
69
|
-
#
|
70
|
-
|
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
71
|
|
72
72
|
# The format of the timestamps used by Commontator
|
73
|
-
# Default: '%b %d %Y
|
74
|
-
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'
|
75
75
|
|
76
76
|
# Whether admins can edit other users' comments
|
77
77
|
# Default: false
|
@@ -109,56 +109,68 @@ Commontator.configure do |config|
|
|
109
109
|
# Default: false
|
110
110
|
config.can_vote_on_comments = true
|
111
111
|
|
112
|
+
# Whether to display upvotes and downvotes
|
113
|
+
# combined or separately
|
114
|
+
# Default: true
|
115
|
+
config.combine_upvotes_and_downvotes = true
|
116
|
+
|
112
117
|
# Whether comments should be ordered by vote score
|
113
118
|
# instead of by order posted
|
114
119
|
# Default: false
|
115
120
|
config.comments_ordered_by_votes = false
|
116
121
|
|
117
|
-
# Whether users can read threads closed by
|
122
|
+
# Whether users can read threads closed by moderators
|
118
123
|
# Default: true
|
119
124
|
config.closed_threads_are_readable = true
|
120
125
|
|
121
|
-
# Whether comments deleted by
|
122
|
-
# (the content will
|
126
|
+
# Whether to show that comments deleted by a moderator actually existed
|
127
|
+
# (the content will be hidden either way)
|
123
128
|
# Default: true
|
124
129
|
config.deleted_comments_are_visible = true
|
125
130
|
|
126
|
-
# The method which returns the commontable's id, sent to users in email messages
|
127
|
-
# Default: 'id'
|
128
|
-
config.commontable_id_method = 'id'
|
129
|
-
|
130
131
|
# Proc called with thread and user as arguments
|
131
|
-
#
|
132
|
-
#
|
133
|
-
#
|
134
|
-
|
135
|
-
config.can_edit_thread_proc = lambda { |thread, user| user.try(:can_edit) }
|
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| user && user.can_read }
|
136
136
|
|
137
137
|
# Proc called with thread and user as arguments
|
138
|
-
#
|
139
|
-
#
|
140
|
-
# Default: lambda { |thread, user|
|
141
|
-
config.
|
142
|
-
|
143
|
-
# Proc
|
144
|
-
#
|
145
|
-
#
|
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| user.can_edit }
|
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
|
146
153
|
# Default: lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
|
154
|
+
# (defaults to the commontable's show url)
|
147
155
|
config.commontable_url_proc = lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
|
148
|
-
|
149
|
-
# Proc
|
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
|
150
160
|
# Default:
|
151
161
|
# lambda { |params| 'no-reply@example.com' }
|
152
162
|
config.subscription_email_from_proc = lambda { |params| 'no-reply@example.com' }
|
153
163
|
|
154
|
-
# 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
|
155
167
|
# Default:
|
156
168
|
# lambda do |params|
|
157
169
|
# "#{params[:creator_name]} #{params[:config].comment_create_verb_past} a " + \
|
158
|
-
# "#{params[:config].comment_name} on #{params[:commontable_name]}
|
170
|
+
# "#{params[:config].comment_name} on #{params[:commontable_name]}"
|
159
171
|
# end
|
160
172
|
config.subscription_email_subject_proc = lambda do |params|
|
161
173
|
"#{params[:creator_name]} #{params[:config].comment_create_verb_past} a " + \
|
162
|
-
"#{params[:config].comment_name} on #{params[:commontable_name]}
|
174
|
+
"#{params[:config].comment_name} on #{params[:commontable_name]}"
|
163
175
|
end
|
164
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: lambda { |controller| controller.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| 'DummyJS' }
|
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| user.is_admin }
|
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 = 'dummy 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 = true
|
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| user && user.can_read }
|
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| user.can_edit }
|
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
|
@@ -0,0 +1,169 @@
|
|
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
|
+
# Name of the ApplicationController helper method that returns the current user
|
7
|
+
# Default: 'current_user'
|
8
|
+
config.current_user_method = 'current_user'
|
9
|
+
|
10
|
+
# Proc that is called after any javascript runs (e.g. to display/clear flash messages)
|
11
|
+
# It is passed the view_context object (self from the view template), so you should be able to
|
12
|
+
# access anything you normally could in a view template (by using, e.g. view.flash)
|
13
|
+
# However, be aware that it does not have access to the main application's helpers
|
14
|
+
# Should return a string containing JS to be appended to all Commontator JS responses
|
15
|
+
# Default: lambda { |view| '$("#error_explanation").remove();' }
|
16
|
+
config.javascript_proc = lambda { |view| 'Dummy Javascript' }
|
17
|
+
|
18
|
+
|
19
|
+
# 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
|
+
|
25
|
+
# Whether the comment creator's name is clickable in the comment view
|
26
|
+
# If enabled, the link will point to the comment creator's 'show' page
|
27
|
+
# Default: false
|
28
|
+
config.user_name_clickable = false
|
29
|
+
|
30
|
+
# The method that returns the user's email address
|
31
|
+
# Default: 'email'
|
32
|
+
config.user_email_method = 'email'
|
33
|
+
|
34
|
+
# The method that returns the user's name
|
35
|
+
# Default: '' (use user_missing_name)
|
36
|
+
config.user_name_method = ''
|
37
|
+
|
38
|
+
# Proc called with user as argument that returns true if the user is an admin
|
39
|
+
# Admins can delete other users' comments and close threads
|
40
|
+
# Default: lambda { |user| false } (no admins)
|
41
|
+
config.user_admin_proc = lambda { |user| user.try(:is_admin) }
|
42
|
+
|
43
|
+
# Proc called with user as argument that returns true
|
44
|
+
# if the user should receive subscription emails
|
45
|
+
# Default: lambda { |user| true } (always receive subscription emails)
|
46
|
+
config.subscription_email_enable_proc = lambda { |user| true }
|
47
|
+
|
48
|
+
|
49
|
+
# Commontable (acts_as_commontable) Configuration
|
50
|
+
|
51
|
+
# What a comment is called in your application
|
52
|
+
# Default: 'comment'
|
53
|
+
config.comment_name = 'dummy comment'
|
54
|
+
|
55
|
+
# Verb used when creating comments (present)
|
56
|
+
# Default: 'post'
|
57
|
+
config.comment_create_verb_present = 'post'
|
58
|
+
|
59
|
+
# Verb used when creating comments (past)
|
60
|
+
# Default: 'posted'
|
61
|
+
config.comment_create_verb_past = 'posted'
|
62
|
+
|
63
|
+
# Verb used when editing comments (present)
|
64
|
+
# Default: 'modify'
|
65
|
+
config.comment_edit_verb_present = 'modify'
|
66
|
+
|
67
|
+
# Verb used when editing comments (past)
|
68
|
+
# Default: 'modified'
|
69
|
+
config.comment_edit_verb_past = 'modified'
|
70
|
+
|
71
|
+
# What a commontable is called in your application
|
72
|
+
# If you have multiple commontable models,
|
73
|
+
# you will want to pass this configuration value
|
74
|
+
# as an argument to acts_as_commontable in each one
|
75
|
+
# Default: 'commontable'
|
76
|
+
config.commontable_name = 'dummy model'
|
77
|
+
|
78
|
+
# The format of the timestamps used by Commontator
|
79
|
+
# Default: '%b %d %Y, %I:%M %p'
|
80
|
+
config.timestamp_format = '%b %d %Y, %I:%M %p'
|
81
|
+
|
82
|
+
# Whether admins can edit other users' comments
|
83
|
+
# Default: false
|
84
|
+
config.admin_can_edit_comments = false
|
85
|
+
|
86
|
+
# Whether users automatically subscribe to a thread when commenting
|
87
|
+
# Default: false
|
88
|
+
config.auto_subscribe_on_comment = false
|
89
|
+
|
90
|
+
# Whether users can edit their own comments
|
91
|
+
# Default: true
|
92
|
+
config.can_edit_own_comments = true
|
93
|
+
|
94
|
+
# Whether users can edit their own comments
|
95
|
+
# after someone posted a newer comment
|
96
|
+
# Default: false
|
97
|
+
config.can_edit_old_comments = false
|
98
|
+
|
99
|
+
# Whether users can delete their own comments
|
100
|
+
# Default: true
|
101
|
+
config.can_delete_own_comments = true
|
102
|
+
|
103
|
+
# Whether users can delete their own comments
|
104
|
+
# after someone posted a newer comment
|
105
|
+
# Default: false
|
106
|
+
config.can_delete_old_comments = false
|
107
|
+
|
108
|
+
# Whether users can manually subscribe or unsubscribe to threads
|
109
|
+
# Default: true
|
110
|
+
config.can_subscribe_to_thread = true
|
111
|
+
|
112
|
+
# Whether users can vote on other users' comments
|
113
|
+
# Note: requires acts_as_votable gem installed
|
114
|
+
# and configured for your application
|
115
|
+
# Default: false
|
116
|
+
config.can_vote_on_comments = true
|
117
|
+
|
118
|
+
# Whether comments should be ordered by vote score
|
119
|
+
# instead of by order posted
|
120
|
+
# Default: false
|
121
|
+
config.comments_ordered_by_votes = false
|
122
|
+
|
123
|
+
# Whether users can read threads closed by moderators
|
124
|
+
# Default: true
|
125
|
+
config.closed_threads_are_readable = true
|
126
|
+
|
127
|
+
# Whether to show that comments deleted by a moderator actually existed
|
128
|
+
# (the content will be hidden either way)
|
129
|
+
# Default: true
|
130
|
+
config.deleted_comments_are_visible = true
|
131
|
+
|
132
|
+
# The method which returns the commontable's id, sent to users in email messages
|
133
|
+
# Default: 'id'
|
134
|
+
config.commontable_id_method = 'id'
|
135
|
+
|
136
|
+
# Proc called with thread and user as arguments
|
137
|
+
# If it returns true, that user is a moderator for that particular thread
|
138
|
+
# and can delete users' comments in the thread or close it
|
139
|
+
# Default: lambda { |thread, user| false } (no thread-specific moderators)
|
140
|
+
config.can_edit_thread_proc = lambda { |thread, user| false }
|
141
|
+
|
142
|
+
# Proc called with thread and user as arguments
|
143
|
+
# If it returns true, that user is allowed to read that thread
|
144
|
+
# Note: user can be false or nil
|
145
|
+
# Default: lambda { |thread, user| true } (anyone can read threads even if not logged in)
|
146
|
+
config.can_read_thread_proc = lambda { |thread, user| true }
|
147
|
+
|
148
|
+
# Proc that returns the commontable url that contains the thread
|
149
|
+
# (defaults to the commontable show url)
|
150
|
+
# Main application's routes can be accessed using main_app object
|
151
|
+
# Default: lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
|
152
|
+
config.commontable_url_proc = lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
|
153
|
+
|
154
|
+
# Proc that returns the subscription email 'from' address
|
155
|
+
# Default:
|
156
|
+
# lambda { |params| 'no-reply@example.com' }
|
157
|
+
config.subscription_email_from_proc = lambda { |params| 'no-reply@example.com' }
|
158
|
+
|
159
|
+
# Proc that returns the subscription email 'subject' string
|
160
|
+
# Default:
|
161
|
+
# lambda do |params|
|
162
|
+
# "#{params[:creator_name]} #{params[:config].comment_create_verb_past} a " + \
|
163
|
+
# "#{params[:config].comment_name} on #{params[:commontable_name]} #{params[:commontable_id]}"
|
164
|
+
# end
|
165
|
+
config.subscription_email_subject_proc = lambda do |params|
|
166
|
+
"#{params[:creator_name]} #{params[:config].comment_create_verb_past} a " + \
|
167
|
+
"#{params[:config].comment_name} on #{params[:commontable_name]} #{params[:commontable_id]}"
|
168
|
+
end
|
169
|
+
end
|