commontator 4.5.4 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/MIT-LICENSE +2 -1
- data/README.md +31 -34
- data/Rakefile +3 -2
- data/app/assets/stylesheets/commontator/application.css +1 -0
- data/app/assets/stylesheets/commontator/comments.css +1 -0
- data/app/assets/stylesheets/commontator/threads.css +13 -7
- data/{spec/dummy/tmp/cache/assets/test/sprockets/a473b3873e554893372a53d71f5e9879 → app/assets/stylesheets/commontator/threads.css~} +0 -0
- data/app/controllers/commontator/application_controller.rb +14 -14
- data/app/controllers/commontator/application_controller.rb~ +35 -0
- data/app/controllers/commontator/comments_controller.rb +8 -7
- data/app/controllers/commontator/comments_controller.rb~ +153 -0
- data/app/controllers/commontator/subscriptions_controller.rb +1 -0
- data/app/controllers/commontator/threads_controller.rb +7 -2
- data/app/helpers/commontator/application_helper.rb +1 -0
- data/app/mailers/commontator/subscriptions_mailer.rb +8 -10
- data/app/mailers/commontator/subscriptions_mailer.rb~ +44 -0
- data/app/models/commontator/comment.rb +14 -13
- data/app/models/commontator/comment.rb~ +119 -0
- data/app/models/commontator/subscription.rb +8 -4
- data/app/models/commontator/thread.rb +64 -43
- data/app/models/commontator/thread.rb~ +159 -0
- data/app/views/commontator/comments/_actions.html.erb +1 -0
- data/app/views/commontator/comments/_body.html.erb +2 -1
- data/app/views/commontator/comments/_form.html.erb +5 -1
- data/app/views/commontator/comments/_form.html.erb~ +39 -0
- data/app/views/commontator/comments/_list.html.erb +1 -1
- data/app/views/commontator/comments/_show.html.erb +5 -3
- data/app/views/commontator/comments/_show.html.erb~ +49 -0
- data/app/views/commontator/comments/_votes.html.erb +2 -1
- data/app/views/commontator/comments/_votes.html.erb~ +69 -0
- data/app/views/commontator/comments/cancel.js.erb +1 -0
- data/app/views/commontator/comments/create.js.erb +6 -4
- data/app/views/commontator/comments/create.js.erb~ +14 -0
- data/app/views/commontator/comments/delete.js.erb +1 -0
- data/app/views/commontator/comments/edit.js.erb +1 -0
- data/app/views/commontator/comments/new.js.erb +3 -1
- data/app/views/commontator/comments/new.js.erb~ +13 -0
- data/app/views/commontator/comments/update.js.erb +1 -0
- data/app/views/commontator/comments/vote.js.erb +1 -0
- data/app/views/commontator/shared/_thread.html.erb +4 -5
- data/app/views/commontator/subscriptions/_link.html.erb +2 -1
- data/app/views/commontator/subscriptions/_link.html.erb~ +16 -0
- data/app/views/commontator/subscriptions/subscribe.js.erb +1 -0
- data/app/views/commontator/subscriptions_mailer/comment_created.html.erb +1 -0
- data/app/views/commontator/threads/_reply.html.erb +4 -2
- data/app/views/commontator/threads/_reply.html.erb~ +19 -0
- data/app/views/commontator/threads/_show.html.erb +44 -9
- data/app/views/commontator/threads/_show.html.erb~ +95 -0
- data/app/views/commontator/threads/_show.js.erb +19 -0
- data/app/views/commontator/threads/show.js.erb +4 -4
- data/config/initializers/commontator.rb +169 -132
- data/config/initializers/commontator.rb~ +238 -0
- data/config/locales/commontator/en.yml +12 -3
- data/config/locales/commontator/en.yml~ +104 -0
- data/config/routes.rb +1 -0
- data/db/migrate/0_install_commontator.rb +9 -11
- data/db/migrate/0_install_commontator.rb~ +54 -0
- data/lib/commontator.rb +57 -16
- data/lib/commontator.rb~ +142 -0
- data/lib/commontator/acts_as_commontable.rb +12 -14
- data/lib/commontator/acts_as_commontator.rb +1 -16
- data/lib/commontator/commontable_config.rb +1 -0
- data/lib/commontator/commontator_config.rb +1 -0
- data/lib/commontator/controller_includes.rb +3 -3
- data/lib/commontator/engine.rb +1 -0
- data/lib/commontator/link_renderer.rb +29 -0
- data/lib/commontator/security_transgression.rb +1 -0
- data/lib/commontator/shared_helper.rb +7 -5
- data/lib/commontator/version.rb +2 -1
- data/lib/tasks/commontator_tasks.rake +1 -0
- data/spec/app/controllers/commontator/comments_controller_spec.rb +12 -11
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +2 -1
- data/spec/app/controllers/commontator/threads_controller_spec.rb +2 -1
- data/spec/app/helpers/commontator/application_helper_spec.rb +2 -1
- data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb +2 -1
- data/spec/app/models/commontator/comment_spec.rb +18 -11
- data/spec/app/models/commontator/comment_spec.rb~ +74 -0
- data/spec/app/models/commontator/subscription_spec.rb +18 -8
- data/spec/app/models/commontator/thread_spec.rb +28 -42
- data/spec/dummy/README.md +1 -0
- data/spec/dummy/Rakefile +1 -0
- data/spec/dummy/app/assets/javascripts/application.js +1 -0
- data/spec/dummy/app/assets/stylesheets/application.css +1 -0
- data/spec/dummy/app/controllers/application_controller.rb +1 -0
- data/spec/dummy/app/controllers/dummy_models_controller.rb +1 -0
- data/spec/dummy/app/helpers/application_helper.rb +1 -0
- data/spec/dummy/app/models/dummy_model.rb +1 -0
- data/spec/dummy/app/models/dummy_user.rb +7 -2
- data/spec/dummy/app/models/dummy_user.rb~ +16 -0
- data/spec/dummy/app/views/dummy_model/show.html.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +1 -0
- data/spec/dummy/config.ru +1 -0
- data/spec/dummy/config/boot.rb +1 -0
- data/spec/dummy/config/database.yml +1 -0
- data/spec/dummy/config/environment.rb +1 -0
- data/spec/dummy/config/environments/development.rb +1 -0
- data/spec/dummy/config/environments/production.rb +1 -0
- data/spec/dummy/config/environments/test.rb +1 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +1 -0
- data/spec/dummy/config/initializers/commontator.rb +6 -1
- data/spec/dummy/config/initializers/commontator.rb~ +15 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +1 -0
- data/spec/dummy/config/initializers/inflections.rb +1 -0
- data/spec/dummy/config/initializers/mime_types.rb +1 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -0
- data/spec/dummy/config/initializers/session_store.rb +1 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -0
- data/spec/dummy/config/routes.rb +1 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/1_create_dummy_models.rb +1 -0
- data/spec/dummy/db/migrate/2_create_dummy_users.rb +1 -0
- data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb +1 -0
- data/spec/dummy/db/schema.rb +10 -13
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/404.html +1 -0
- data/spec/dummy/public/422.html +1 -0
- data/spec/dummy/public/500.html +1 -0
- data/spec/dummy/script/rails +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{72b63dddbc5c995f79af8e3c94904fd9 → 02d4b791eb831cf2057bf4703a1218d1} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{a77b1a9223d168112e1705c29220116f → 0f196a1a50363b0a076ec6e1ee5417f6} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a3fb9025f90ff05a6fd4afc7ded2692c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a41c8be5379abec3c0d0d98e2f0d5609 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c69ee3cc5796188d873574179290a6ef +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{f721383d531f067d82b071e14aed7a92 → e1f674c11941d62aac1764ef3a7134e4} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{d2244ccef8e05bb993f75715af0344cc → e85565206c3e5fdf9dfeb367c85557b1} +0 -0
- data/spec/lib/commontator/acts_as_commontable_spec.rb +3 -2
- data/spec/lib/commontator/acts_as_commontator_spec.rb +2 -5
- data/spec/lib/commontator/commontable_config_spec.rb +8 -5
- data/spec/lib/commontator/commontator_config_spec.rb +2 -1
- data/spec/lib/commontator/controller_includes_spec.rb +2 -1
- data/spec/lib/commontator/shared_helper_spec.rb +2 -1
- data/spec/lib/commontator_spec.rb +2 -1
- data/spec/{test_helper.rb → spec_helper.rb} +0 -0
- metadata +154 -135
- data/lib/commontator/remote_link_renderer.rb +0 -10
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/log/development.log +0 -36
- data/spec/dummy/log/test.log +0 -22683
- data/spec/dummy/tmp/cache/assets/test/sprockets/afa63eb365bdf4f42584b17ac9176b9d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/decb63cac838a5314aa0c22a979f5ac9 +0 -0
@@ -2,7 +2,8 @@ $("#thread_<%= @thread.id %>_new_comment_div").html("<%= escape_javascript(
|
|
2
2
|
render :partial => 'form',
|
3
3
|
:locals => {
|
4
4
|
:comment => @comment,
|
5
|
-
:thread => @thread
|
5
|
+
:thread => @thread,
|
6
|
+
:per_page => @per_page
|
6
7
|
}) %>");
|
7
8
|
|
8
9
|
$("#thread_<%= @thread.id %>_new_comment_div").fadeIn()[0].scrollIntoView();
|
@@ -10,3 +11,4 @@ $("#thread_<%= @thread.id %>_new_comment_div").fadeIn()[0].scrollIntoView();
|
|
10
11
|
$("#thread_<%= @thread.id %>_new_comment_link_span").hide();
|
11
12
|
|
12
13
|
<%= javascript_proc %>
|
14
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
$("#thread_<%= @thread.id %>_new_comment_div").html("<%= escape_javascript(
|
2
|
+
render :partial => 'form',
|
3
|
+
:locals => {
|
4
|
+
:comment => @comment,
|
5
|
+
:thread => @thread
|
6
|
+
}) %>");
|
7
|
+
|
8
|
+
$("#thread_<%= @thread.id %>_new_comment_div").fadeIn()[0].scrollIntoView();
|
9
|
+
|
10
|
+
$("#thread_<%= @thread.id %>_new_comment_link_span").hide();
|
11
|
+
|
12
|
+
<%= javascript_proc %>
|
13
|
+
|
@@ -3,8 +3,6 @@
|
|
3
3
|
# user
|
4
4
|
%>
|
5
5
|
|
6
|
-
<% subscription = thread.subscription_for(user) %>
|
7
|
-
|
8
6
|
<% if thread.can_be_read_by?(user) %>
|
9
7
|
<%= stylesheet_link_tag "commontator/application.css", :media => "all" %>
|
10
8
|
|
@@ -16,10 +14,11 @@
|
|
16
14
|
:page => @commontator_page,
|
17
15
|
:per_page => @commontator_per_page} %>
|
18
16
|
<% else %>
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
<% subscription = thread.subscription_for(user) %>
|
18
|
+
<%= link_to "#{t 'commontator.thread.actions.show'} (#{(subscription.unread_comments.count.to_s + '/') \
|
19
|
+
if subscription}#{thread.filtered_comments.count.to_s})", commontator.thread_path(thread),
|
22
20
|
:remote => true %>
|
23
21
|
<% end %>
|
24
22
|
</div>
|
25
23
|
<% end %>
|
24
|
+
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# user
|
4
4
|
%>
|
5
5
|
|
6
|
-
<% is_subscribed = thread.
|
6
|
+
<% is_subscribed = !!thread.subscription_for(user) %>
|
7
7
|
<% sub_string = is_subscribed ? "unsubscribe" : "subscribe" %>
|
8
8
|
<%= link_to t("commontator.subscription.actions.#{sub_string}"),
|
9
9
|
commontator.polymorphic_path([sub_string, thread]),
|
@@ -13,3 +13,4 @@
|
|
13
13
|
:id => "thread_#{thread.id.to_s}_#{sub_string}_link",
|
14
14
|
:class => "thread_#{sub_string}_link",
|
15
15
|
:remote => true %>
|
16
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% # Clients of this partial must supply the following variables:
|
2
|
+
# thread
|
3
|
+
# user
|
4
|
+
%>
|
5
|
+
|
6
|
+
<% is_subscribed = thread.subscription_for(user) %>
|
7
|
+
<% sub_string = is_subscribed ? "unsubscribe" : "subscribe" %>
|
8
|
+
<%= link_to t("commontator.subscription.actions.#{sub_string}"),
|
9
|
+
commontator.polymorphic_path([sub_string, thread]),
|
10
|
+
:confirm => (is_subscribed ? t('commontator.subscription.actions.confirm_unsubscribe') : \
|
11
|
+
nil),
|
12
|
+
:method => :put,
|
13
|
+
:id => "thread_#{thread.id.to_s}_#{sub_string}_link",
|
14
|
+
:class => "thread_#{sub_string}_link",
|
15
|
+
:remote => true %>
|
16
|
+
|
@@ -1,10 +1,11 @@
|
|
1
1
|
<% # Clients of this partial must supply the following variables:
|
2
2
|
# thread
|
3
3
|
# user
|
4
|
+
# per_page
|
4
5
|
%>
|
5
6
|
|
6
7
|
<% if thread.is_closed? %>
|
7
|
-
<p><%= t 'commontator.thread.status.
|
8
|
+
<p><%= t 'commontator.thread.status.cannot_post' %></p>
|
8
9
|
<% elsif !user %>
|
9
10
|
<p><%= t 'commontator.require_login' %>.</p>
|
10
11
|
<% else %>
|
@@ -12,6 +13,7 @@
|
|
12
13
|
|
13
14
|
<span id="thread_<%= thread.id %>_new_comment_link_span" class="thread_new_comment_link">
|
14
15
|
<%= link_to t('commontator.comment.actions.new'),
|
15
|
-
commontator.new_thread_comment_path(thread), :remote => true %>
|
16
|
+
commontator.new_thread_comment_path(thread, :per_page => per_page), :remote => true %>
|
16
17
|
</span>
|
17
18
|
<% end %>
|
19
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% # Clients of this partial must supply the following variables:
|
2
|
+
# thread
|
3
|
+
# user
|
4
|
+
# per_page
|
5
|
+
%>
|
6
|
+
|
7
|
+
<% if thread.is_closed? %>
|
8
|
+
<p><%= t 'commontator.thread.status.cannot_post' %></p>
|
9
|
+
<% elsif !user %>
|
10
|
+
<p><%= t 'commontator.require_login' %>.</p>
|
11
|
+
<% else %>
|
12
|
+
<div id="thread_<%= thread.id %>_new_comment_div" class="thread_new_comment"></div>
|
13
|
+
|
14
|
+
<span id="thread_<%= thread.id %>_new_comment_link_span" class="thread_new_comment_link">
|
15
|
+
<%= link_to t('commontator.comment.actions.new'),
|
16
|
+
commontator.new_thread_comment_path(thread, :per_page => @commontator_per_page), :remote => true %>
|
17
|
+
</span>
|
18
|
+
<% end %>
|
19
|
+
|
@@ -3,6 +3,8 @@
|
|
3
3
|
# user
|
4
4
|
# page
|
5
5
|
# per_page
|
6
|
+
# Optionally, they can also supply the following variable:
|
7
|
+
show_all ||= false
|
6
8
|
%>
|
7
9
|
|
8
10
|
<% can_subscribe = thread.can_subscribe?(user) %>
|
@@ -20,8 +22,20 @@
|
|
20
22
|
|
21
23
|
|
22
24
|
<% if can_edit %>
|
23
|
-
<%
|
24
|
-
|
25
|
+
<% filter_string = show_all ? 'filter' : 'show_all'
|
26
|
+
is_closed = thread.is_closed?
|
27
|
+
close_string = is_closed ? 'reopen' : 'close' %>
|
28
|
+
|
29
|
+
<% if thread.is_filtered? %>
|
30
|
+
<%= link_to t("commontator.thread.actions.#{filter_string}"),
|
31
|
+
commontator.thread_path(thread, :show_all => (show_all ? nil : true)),
|
32
|
+
:id => "thread_#{thread.id.to_s}_#{filter_string}_link",
|
33
|
+
:class => "thread_#{filter_string}_link",
|
34
|
+
:remote => true %>
|
35
|
+
|
36
|
+
|
37
|
+
<% end %>
|
38
|
+
|
25
39
|
<%= link_to t("commontator.thread.actions.#{close_string}"),
|
26
40
|
commontator.polymorphic_path([close_string, thread]),
|
27
41
|
:confirm => (!is_closed ? t('commontator.thread.actions.confirm_close') : nil),
|
@@ -34,27 +48,48 @@
|
|
34
48
|
|
35
49
|
<span id="thread_<%= thread.id.to_s %>_header_span" class="thread_header">
|
36
50
|
<%= t "commontator.thread.status.#{thread.is_closed? ? 'closed' : 'open'}",
|
37
|
-
:closer_name => thread.closer
|
51
|
+
:closer_name => Commontator.commontator_name(thread.closer) %>
|
38
52
|
</span>
|
39
53
|
|
40
54
|
<% if thread.config.comment_order == :l %>
|
41
|
-
<%= render :partial => 'commontator/threads/reply',
|
55
|
+
<%= render :partial => 'commontator/threads/reply',
|
56
|
+
:locals => {:thread => thread, :user => user, :per_page => per_page} %>
|
42
57
|
<% end %>
|
43
58
|
|
44
59
|
<div id="thread_<%= thread.id.to_s %>_comment_list_div" class="thread_comment_list">
|
45
|
-
<% comments = thread.paginated_comments(page, per_page) %>
|
60
|
+
<% comments = show_all ? thread.ordered_comments(true) : thread.paginated_comments(page, per_page) %>
|
46
61
|
<%= render :partial => 'commontator/comments/list',
|
47
62
|
:locals => {:comments => comments,
|
48
63
|
:user => user} %>
|
49
64
|
</div>
|
50
65
|
|
51
|
-
<% if thread.will_paginate? %>
|
66
|
+
<% if thread.will_paginate? && !show_all %>
|
52
67
|
<div id="thread_<%= thread.id.to_s %>_pagination_div" class="thread_pagination">
|
53
|
-
<%=
|
54
|
-
|
68
|
+
<div id="thread_<%= thread.id.to_s %>_page_entries_info_div" class="thread_page_entries_info">
|
69
|
+
<%= page_entries_info comments,
|
70
|
+
:params => {:controller => 'commontator/threads',
|
71
|
+
:action => 'show',
|
72
|
+
:id => thread.id,
|
73
|
+
:page => page,
|
74
|
+
:per_page => per_page} %>.
|
75
|
+
</div>
|
76
|
+
|
77
|
+
<div id="thread_<%= thread.id.to_s %>_will_paginate_div" class="thread_will_paginate">
|
78
|
+
<%= will_paginate comments,
|
79
|
+
:renderer => Commontator::LinkRenderer,
|
80
|
+
:routes_proxy => commontator,
|
81
|
+
:remote => true,
|
82
|
+
:params => {:controller => 'commontator/threads',
|
83
|
+
:action => 'show',
|
84
|
+
:id => thread.id,
|
85
|
+
:page => page,
|
86
|
+
:per_page => per_page} %>
|
87
|
+
</div>
|
55
88
|
</div>
|
56
89
|
<% end %>
|
57
90
|
|
58
91
|
<% if thread.config.comment_order != :l %>
|
59
|
-
<%= render :partial => 'commontator/threads/reply',
|
92
|
+
<%= render :partial => 'commontator/threads/reply',
|
93
|
+
:locals => {:thread => thread, :user => user, :per_page => per_page} %>
|
60
94
|
<% end %>
|
95
|
+
|
@@ -0,0 +1,95 @@
|
|
1
|
+
<% # Clients of this partial must supply the following variables:
|
2
|
+
# thread
|
3
|
+
# user
|
4
|
+
# page
|
5
|
+
# per_page
|
6
|
+
# Optionally, they can also supply the following variable:
|
7
|
+
show_all ||= false
|
8
|
+
%>
|
9
|
+
|
10
|
+
<% can_subscribe = thread.can_subscribe?(user) %>
|
11
|
+
<% can_edit = thread.can_be_edited_by?(user) %>
|
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
|
+
<% filter_string = show_all ? 'filter' : 'show_all'
|
26
|
+
is_closed = thread.is_closed?
|
27
|
+
close_string = is_closed ? 'reopen' : 'close' %>
|
28
|
+
|
29
|
+
<% if thread.is_filtered? %>
|
30
|
+
<%= link_to t("commontator.thread.actions.#{filter_string}"),
|
31
|
+
commontator.thread_path(thread, :show_all => (show_all ? nil : true)),
|
32
|
+
:id => "thread_#{thread.id.to_s}_#{filter_string}_link",
|
33
|
+
:class => "thread_#{filter_string}_link",
|
34
|
+
:remote => true %>
|
35
|
+
|
36
|
+
|
37
|
+
<% end %>
|
38
|
+
|
39
|
+
<%= link_to t("commontator.thread.actions.#{close_string}"),
|
40
|
+
commontator.polymorphic_path([close_string, thread]),
|
41
|
+
:confirm => (!is_closed ? t('commontator.thread.actions.confirm_close') : nil),
|
42
|
+
:method => :put,
|
43
|
+
:id => "thread_#{thread.id.to_s}_#{close_string}_link",
|
44
|
+
:class => "thread_#{close_string}_link",
|
45
|
+
:remote => true %>
|
46
|
+
<% end %>
|
47
|
+
</span>
|
48
|
+
|
49
|
+
<span id="thread_<%= thread.id.to_s %>_header_span" class="thread_header">
|
50
|
+
<%= t "commontator.thread.status.#{thread.is_closed? ? 'closed' : 'open'}",
|
51
|
+
:closer_name => Commontator.commontator_name(thread.closer) %>
|
52
|
+
</span>
|
53
|
+
|
54
|
+
<% if thread.config.comment_order == :l %>
|
55
|
+
<%= render :partial => 'commontator/threads/reply',
|
56
|
+
:locals => {:thread => thread, :user => user, :per_page => per_page} %>
|
57
|
+
<% end %>
|
58
|
+
|
59
|
+
<div id="thread_<%= thread.id.to_s %>_comment_list_div" class="thread_comment_list">
|
60
|
+
<% comments = show_all ? thread.ordered_comments(true) : thread.paginated_comments(page, per_page) %>
|
61
|
+
<%= render :partial => 'commontator/comments/list',
|
62
|
+
:locals => {:comments => comments,
|
63
|
+
:user => user} %>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<% if thread.will_paginate? && !show_all %>
|
67
|
+
<div id="thread_<%= thread.id.to_s %>_pagination_div" class="thread_pagination">
|
68
|
+
<div id="thread_<%= thread.id.to_s %>_page_entries_info_div" class="thread_page_entries_info">
|
69
|
+
<%= page_entries_info comments,
|
70
|
+
:params => {:controller => 'commontator/threads',
|
71
|
+
:action => 'show',
|
72
|
+
:id => thread.id,
|
73
|
+
:page => page,
|
74
|
+
:per_page => per_page} %>
|
75
|
+
</div>
|
76
|
+
|
77
|
+
<div id="thread_<%= thread.id.to_s %>_will_paginate_div" class="thread_will_paginate">
|
78
|
+
<%= will_paginate comments,
|
79
|
+
:renderer => Commontator::LinkRenderer,
|
80
|
+
:routes_proxy => commontator,
|
81
|
+
:remote => true,
|
82
|
+
:params => {:controller => 'commontator/threads',
|
83
|
+
:action => 'show',
|
84
|
+
:id => thread.id,
|
85
|
+
:page => page,
|
86
|
+
:per_page => per_page} %>
|
87
|
+
</div>
|
88
|
+
</div>
|
89
|
+
<% end %>
|
90
|
+
|
91
|
+
<% if thread.config.comment_order != :l %>
|
92
|
+
<%= render :partial => 'commontator/threads/reply',
|
93
|
+
:locals => {:thread => thread, :user => user, :per_page => per_page} %>
|
94
|
+
<% end %>
|
95
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% # Clients of this partial must supply the following variables:
|
2
|
+
# thread
|
3
|
+
# user
|
4
|
+
# page
|
5
|
+
# per_page
|
6
|
+
# Optionally, they can also supply the following variable:
|
7
|
+
show_all ||= false
|
8
|
+
%>
|
9
|
+
|
10
|
+
$("#thread_<%= thread.id %>_div").html(
|
11
|
+
"<%= escape_javascript(
|
12
|
+
render :partial => 'commontator/threads/show',
|
13
|
+
:formats => [:html],
|
14
|
+
:locals => {:thread => thread,
|
15
|
+
:user => user,
|
16
|
+
:page => page,
|
17
|
+
:per_page => per_page,
|
18
|
+
:show_all => show_all}) %>");
|
19
|
+
|
@@ -1,9 +1,9 @@
|
|
1
|
-
|
2
|
-
"<%= escape_javascript(
|
3
|
-
render :partial => 'show',
|
1
|
+
<%= render :partial => 'show',
|
4
2
|
:locals => {:thread => @thread,
|
5
3
|
:user => @user,
|
6
4
|
:page => @commontator_page,
|
7
|
-
:per_page => @commontator_per_page
|
5
|
+
:per_page => @commontator_per_page,
|
6
|
+
:show_all => @show_all} %>
|
8
7
|
|
9
8
|
<%= javascript_proc %>
|
9
|
+
|
@@ -1,123 +1,175 @@
|
|
1
1
|
# Change the settings below to suit your needs
|
2
2
|
# All settings are initially set to their default values
|
3
3
|
|
4
|
-
# Note: Do not "return" from
|
5
|
-
#
|
4
|
+
# Note: Do not "return" from a Proc, use "next" instead if necessary
|
5
|
+
# "return" in a lambda is OK
|
6
6
|
Commontator.configure do |config|
|
7
7
|
# Engine Configuration
|
8
8
|
|
9
|
-
#
|
10
|
-
#
|
9
|
+
# current_user_proc
|
10
|
+
# Type: Proc
|
11
|
+
# Arguments: the current controller (ActionController::Base)
|
12
|
+
# Returns: the current user (acts_as_commontator)
|
13
|
+
# The default works for Devise and similar authentication plugins
|
11
14
|
# Default: lambda { |controller| controller.current_user }
|
12
15
|
config.current_user_proc = lambda { |controller| controller.current_user }
|
13
16
|
|
14
|
-
#
|
15
|
-
#
|
17
|
+
# javascript_proc
|
18
|
+
# Type: Proc
|
19
|
+
# Arguments: a view (ActionView::Base)
|
20
|
+
# Returns: a String that is appended to Commontator JS views
|
16
21
|
# Can be used, for example, to display/clear Rails error messages
|
17
|
-
# Objects visible in view templates can be accessed
|
18
|
-
# the
|
19
|
-
# However, the
|
20
|
-
# Default: lambda { |
|
21
|
-
config.javascript_proc = lambda { |
|
22
|
+
# Objects visible in view templates can be accessed
|
23
|
+
# through the view object (for example, view.flash)
|
24
|
+
# However, the view does not include the main application's helpers
|
25
|
+
# Default: lambda { |view| '$("#error_explanation").remove();' }
|
26
|
+
config.javascript_proc = lambda { |view|
|
22
27
|
'$("#error_explanation").remove();' }
|
23
28
|
|
24
29
|
|
25
30
|
|
26
31
|
# User (acts_as_commontator) Configuration
|
27
32
|
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
33
|
+
# user_name_proc
|
34
|
+
# Type: Proc
|
35
|
+
# Arguments: a user (acts_as_commontator)
|
36
|
+
# Returns: the user's name (String)
|
37
|
+
# Default: lambda { |user| I18n.t('commontator.anonymous') } (all users are anonymous)
|
32
38
|
config.user_name_proc = lambda { |user| I18n.t('commontator.anonymous') }
|
33
39
|
|
34
|
-
#
|
35
|
-
#
|
40
|
+
# user_link_proc
|
41
|
+
# Type: Proc
|
42
|
+
# Arguments: a user (acts_as_commontator),
|
43
|
+
# the app_routes (ActionDispatch::Routing::RoutesProxy)
|
44
|
+
# Returns: a path to the user's `show` page (String)
|
45
|
+
# If anything non-blank is returned, the user's name in comments
|
46
|
+
# comments will become a hyperlink pointing to this path
|
47
|
+
# The main application's routes can be accessed through the app_routes object
|
48
|
+
# Default: lambda { |user, app_routes| '' } (no link)
|
49
|
+
config.user_link_proc = lambda { |user, app_routes| '' }
|
50
|
+
|
51
|
+
# user_avatar_proc
|
52
|
+
# Type: Proc
|
53
|
+
# Arguments: a user (acts_as_commontator), a view (ActionView::Base)
|
54
|
+
# Returns: a String containing a HTML <img> tag pointing to the user's avatar image
|
36
55
|
# The commontator_gravatar_image_tag helper takes a user object,
|
37
|
-
# a border size
|
56
|
+
# a border size and an options hash for Gravatar, and produces a Gravatar image tag
|
38
57
|
# See available options at http://en.gravatar.com/site/implement/images/)
|
39
|
-
#
|
40
|
-
#
|
58
|
+
# Note: Gravatar has several security implications for your users
|
59
|
+
# It makes your users trackable across different sites and
|
60
|
+
# allows de-anonymization attacks against their email addresses
|
61
|
+
# If you absolutely want to keep users' email addresses or identities secret,
|
62
|
+
# do not use Gravatar or similar services
|
63
|
+
# Default: lambda { |user, view|
|
64
|
+
# view.commontator_gravatar_image_tag(
|
41
65
|
# user, 1, :s => 60, :d => 'mm') }
|
42
|
-
config.user_avatar_proc = lambda { |user,
|
43
|
-
|
66
|
+
config.user_avatar_proc = lambda { |user, view|
|
67
|
+
view.commontator_gravatar_image_tag(
|
44
68
|
user, 1, :s => 60, :d => 'mm') }
|
45
69
|
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
|
54
|
-
|
55
|
-
#
|
56
|
-
|
57
|
-
# If anything non-blank is returned, the user's name in comments
|
58
|
-
# will become a hyperlink pointing to this
|
59
|
-
# The main application's routes can be accessed through the main_app object
|
60
|
-
# Default: lambda { |user, main_app| '' } (no link)
|
61
|
-
config.user_link_proc = lambda { |user, main_app| '' }
|
70
|
+
# user_email_proc
|
71
|
+
# Type: Proc
|
72
|
+
# Arguments: a user (acts_as_commontator), a mailer (ActionMailer::Base)
|
73
|
+
# Returns: the user's email address (String)
|
74
|
+
# The default works for Devise's defaults
|
75
|
+
# If the mailer argument is nil, Commontator intends to hash the email and send the hash
|
76
|
+
# to Gravatar, so you should always return the user's email address (if using Gravatar)
|
77
|
+
# If the mailer argument is not nil, then Commontator intends to send an email to
|
78
|
+
# the address returned; you can prevent it from being sent by returning a blank String
|
79
|
+
# Default: lambda { |user, mailer| user.try(:email) || '' }
|
80
|
+
config.user_email_proc = lambda { |user, mailer| user.try(:email) || '' }
|
62
81
|
|
63
82
|
|
64
83
|
|
65
84
|
# Thread/Commontable (acts_as_commontable) Configuration
|
66
85
|
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
|
72
|
-
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
86
|
+
# comment_filter
|
87
|
+
# Type: Arel node (Arel::Nodes::Node) or nil
|
88
|
+
# Arel that filters visible comments
|
89
|
+
# If specified, visible comments will be filtered according to this Arel node
|
90
|
+
# A value of nil will cause no filtering to be done
|
91
|
+
# Moderators can manually override this filter for themselves
|
92
|
+
# Example: Commontator::Comment.arel_table[:deleted_at].eq(nil) (hides deleted comments)
|
93
|
+
# This is not recommended, as it can cause confusion over deleted comments
|
94
|
+
# If using pagination, it can also cause comments to change pages
|
95
|
+
# Default: nil (no filtering - all comments are visible)
|
96
|
+
config.comment_filter = nil
|
97
|
+
|
98
|
+
# thread_read_proc
|
99
|
+
# Type: Proc
|
100
|
+
# Arguments: a thread (Commontator::Thread), a user (acts_as_commontator)
|
101
|
+
# Returns: a Boolean, true iif the user should be allowed to read that thread
|
102
|
+
# Note: can be called with a user object that is nil (if they are not logged in)
|
76
103
|
# Default: lambda { |thread, user| true } (anyone can read any thread)
|
77
104
|
config.thread_read_proc = lambda { |thread, user| true }
|
78
105
|
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
106
|
+
# thread_moderator_proc
|
107
|
+
# Type: Proc
|
108
|
+
# Arguments: a thread (Commontator::Thread), a user (acts_as_commontator)
|
109
|
+
# Returns: a Boolean, true iif the user is a moderator for that thread
|
110
|
+
# If you want global moderators, make this proc true for them regardless of thread
|
84
111
|
# Default: lambda { |thread, user| false } (no moderators)
|
85
112
|
config.thread_moderator_proc = lambda { |thread, user| false }
|
86
113
|
|
87
|
-
#
|
114
|
+
# comment_editing
|
115
|
+
# Type: Symbol
|
116
|
+
# Whether users can edit their own comments
|
88
117
|
# Valid options:
|
89
|
-
# :
|
90
|
-
# :
|
91
|
-
# :
|
92
|
-
#
|
93
|
-
|
94
|
-
config.thread_subscription = :m
|
118
|
+
# :a (always)
|
119
|
+
# :l (only if it's the latest comment)
|
120
|
+
# :n (never)
|
121
|
+
# Default: :l
|
122
|
+
config.comment_editing = :l
|
95
123
|
|
124
|
+
# comment_deletion
|
125
|
+
# Type: Symbol
|
126
|
+
# Whether users can delete their own comments
|
127
|
+
# Valid options:
|
128
|
+
# :a (always)
|
129
|
+
# :l (only if it's the latest comment)
|
130
|
+
# :n (never)
|
131
|
+
# Note: For moderators, see the next option
|
132
|
+
# Default: :l
|
133
|
+
config.comment_deletion = :l
|
134
|
+
|
135
|
+
# moderator_permissions
|
136
|
+
# Type: Symbol
|
137
|
+
# What permissions moderators have
|
138
|
+
# Valid options:
|
139
|
+
# :e (delete and edit comments and close threads)
|
140
|
+
# :d (delete comments and close threads)
|
141
|
+
# :c (close threads only)
|
142
|
+
# Default: :d
|
143
|
+
config.moderator_permissions = :d
|
144
|
+
|
145
|
+
# comment_voting
|
146
|
+
# Type: Symbol
|
96
147
|
# Whether users can vote on other users' comments
|
97
148
|
# Valid options:
|
98
|
-
# :n
|
99
|
-
# :l
|
149
|
+
# :n (no voting)
|
150
|
+
# :l (likes - requires acts_as_votable gem)
|
100
151
|
# :ld (likes/dislikes - requires acts_as_votable gem)
|
101
152
|
# Not yet implemented:
|
102
|
-
# :s
|
103
|
-
# :r
|
104
|
-
# Note: you can format how the votes are displayed by modifying the locale file
|
153
|
+
# :s (star ratings)
|
154
|
+
# :r (reputation system)
|
105
155
|
# Default: :n
|
106
156
|
config.comment_voting = :n
|
107
157
|
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
158
|
+
# vote_count_proc
|
159
|
+
# Type: Proc
|
160
|
+
# Arguments: a thread (Commontator::Thread), pos (Fixnum), neg (Fixnum)
|
161
|
+
# Returns: vote count to be displayed (String)
|
162
|
+
# pos is the number of likes, or the rating, or the reputation
|
111
163
|
# neg is the number of dislikes, if applicable, or 0 otherwise
|
112
|
-
#
|
113
|
-
|
114
|
-
config.voting_text_proc = lambda { |comment_voting, pos, neg|
|
115
|
-
"%+d" % (pos - neg) }
|
164
|
+
# Default: lambda { |thread, pos, neg| "%+d" % (pos - neg) }
|
165
|
+
config.vote_count_proc = lambda { |thread, pos, neg| "%+d" % (pos - neg) }
|
116
166
|
|
167
|
+
# comment_order
|
168
|
+
# Type: Symbol
|
117
169
|
# What order to use for comments
|
118
170
|
# Valid options:
|
119
|
-
# :e
|
120
|
-
# :l
|
171
|
+
# :e (earliest comment first)
|
172
|
+
# :l (latest comment first)
|
121
173
|
# :ve (highest voted first; earliest first if tied)
|
122
174
|
# :vl (highest voted first; latest first if tied)
|
123
175
|
# Notes:
|
@@ -130,72 +182,57 @@ Commontator.configure do |config|
|
|
130
182
|
# Default: :e
|
131
183
|
config.comment_order = :e
|
132
184
|
|
185
|
+
# comments_per_page
|
186
|
+
# Type: Fixnum or nil
|
133
187
|
# Number of comments to display in each page
|
134
188
|
# Set to nil to disable pagination
|
135
189
|
# Any other value requires the will_paginate gem
|
136
190
|
# Default: nil (no pagination)
|
137
191
|
config.comments_per_page = nil
|
138
192
|
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
# Commontator supplies its own RemoteLinkRenderer,
|
143
|
-
# which is exactly like will_paginate's default, except it returns remote links
|
144
|
-
# For more information, see:
|
145
|
-
# https://github.com/mislav/will_paginate/wiki/Link-renderer
|
146
|
-
# Default: lambda { |thread| Commontator::RemoteLinkRenderer }
|
147
|
-
config.wp_link_renderer_proc = lambda { |thread|
|
148
|
-
Commontator::RemoteLinkRenderer }
|
149
|
-
|
150
|
-
# Whether users can edit their own comments
|
151
|
-
# Valid options:
|
152
|
-
# :a (always)
|
153
|
-
# :l (only if it's the latest comment)
|
154
|
-
# :n (never)
|
155
|
-
# Default: :l
|
156
|
-
config.comment_editing = :l
|
157
|
-
|
158
|
-
# Whether users can delete their own comments
|
193
|
+
# thread_subscription
|
194
|
+
# Type: Symbol
|
195
|
+
# Whether users can subscribe to threads to receive activity email notifications
|
159
196
|
# Valid options:
|
160
|
-
# :
|
161
|
-
# :
|
162
|
-
# :
|
163
|
-
#
|
164
|
-
# Default: :
|
165
|
-
config.
|
166
|
-
|
167
|
-
#
|
168
|
-
#
|
169
|
-
|
170
|
-
|
171
|
-
#
|
172
|
-
#
|
173
|
-
#
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
|
182
|
-
|
183
|
-
#
|
184
|
-
#
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
#
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
#
|
193
|
-
# Return the url that contains the commontable's thread
|
197
|
+
# :n (no subscriptions)
|
198
|
+
# :a (automatically subscribe when you comment; cannot do it manually)
|
199
|
+
# :m (manual subscriptions only)
|
200
|
+
# :b (both automatic, when commenting, and manual)
|
201
|
+
# Default: :n
|
202
|
+
config.thread_subscription = :n
|
203
|
+
|
204
|
+
# email_from_proc
|
205
|
+
# Type: Proc
|
206
|
+
# Arguments: a thread (Commontator::Thread)
|
207
|
+
# Returns: the address emails are sent "from" (String)
|
208
|
+
# Important: If using subscriptions, change this to at least match your domain name
|
209
|
+
# Default: lambda { |thread|
|
210
|
+
# "no-reply@#{Rails.application.class.parent.to_s.downcase}.com" }
|
211
|
+
config.email_from_proc = lambda { |thread|
|
212
|
+
"no-reply@#{Rails.application.class.parent.to_s.downcase}.com" }
|
213
|
+
|
214
|
+
# commontable_name_proc
|
215
|
+
# Type: Proc
|
216
|
+
# Arguments: a thread (Commontator::Thread)
|
217
|
+
# Returns: a name that refers to the commontable object (String)
|
218
|
+
# If you have multiple commontable models, you can also pass this
|
219
|
+
# configuration value as an argument to acts_as_commontable for each one
|
220
|
+
# Default: lambda { |thread|
|
221
|
+
# "#{thread.commontable.class.name} ##{thread.commontable.id}" }
|
222
|
+
config.commontable_name_proc = lambda { |thread|
|
223
|
+
"#{thread.commontable.class.name} ##{thread.commontable.id}" }
|
224
|
+
|
225
|
+
# commontable_url_proc
|
226
|
+
# Type: Proc
|
227
|
+
# Arguments: a thread (Commontator::Thread),
|
228
|
+
# the app_routes (ActionDispatch::Routing::RoutesProxy)
|
229
|
+
# Returns: a String containing the url of the view that displays the given thread
|
194
230
|
# This usually is the commontable's "show" page
|
195
|
-
# The main application's routes can be accessed through the
|
196
|
-
# Default: lambda { |commontable,
|
197
|
-
#
|
231
|
+
# The main application's routes can be accessed through the app_routes object
|
232
|
+
# Default: lambda { |commontable, app_routes|
|
233
|
+
# app_routes.polymorphic_url(commontable) }
|
198
234
|
# (defaults to the commontable's show url)
|
199
|
-
config.commontable_url_proc = lambda { |
|
200
|
-
|
235
|
+
config.commontable_url_proc = lambda { |thread, app_routes|
|
236
|
+
app_routes.polymorphic_url(thread.commontable) }
|
201
237
|
end
|
238
|
+
|