commontator 0.2.4 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/stylesheets/commontator/threads.css +4 -0
- data/app/assets/stylesheets/commontator/threads.css~ +1 -1
- data/app/controllers/commontator/application_controller.rb +5 -0
- data/app/controllers/commontator/application_controller.rb~ +8 -1
- data/app/controllers/commontator/comments_controller.rb +24 -31
- data/app/controllers/commontator/comments_controller.rb~ +25 -32
- data/app/controllers/commontator/subscriptions_controller.rb +8 -18
- data/app/controllers/commontator/subscriptions_controller.rb~ +10 -16
- data/app/controllers/commontator/threads_controller.rb +3 -5
- data/app/controllers/commontator/threads_controller.rb~ +3 -6
- data/app/helpers/commontator/application_helper.rb +2 -6
- data/app/helpers/commontator/application_helper.rb~ +4 -4
- data/app/helpers/commontator/commontator_helper.rb +2 -2
- data/app/helpers/commontator/commontator_helper.rb~ +2 -2
- data/app/helpers/commontator/threads_helper.rb +1 -1
- data/app/helpers/commontator/threads_helper.rb~ +5 -12
- data/app/mailers/commontator/subscriptions_mailer.rb +15 -11
- data/app/mailers/commontator/subscriptions_mailer.rb~ +15 -12
- data/app/models/commontator/comment.rb +2 -2
- data/app/models/commontator/thread.rb +11 -11
- data/app/models/commontator/thread.rb~ +7 -9
- data/app/views/commontator/comments/_actions.html.erb +13 -16
- data/app/views/commontator/comments/_actions.html.erb~ +13 -17
- data/app/views/commontator/comments/create.js.erb +1 -1
- data/app/views/commontator/comments/create.js.erb~ +2 -2
- data/app/views/commontator/comments/delete.js.erb +1 -1
- data/app/views/commontator/comments/delete.js.erb~ +2 -2
- data/app/views/commontator/comments/edit.js.erb +1 -1
- data/app/views/commontator/comments/edit.js.erb~ +2 -2
- data/app/views/commontator/comments/new.js.erb +1 -1
- data/app/views/commontator/comments/new.js.erb~ +2 -2
- data/app/views/commontator/comments/update.js.erb +1 -1
- data/app/views/commontator/comments/update.js.erb~ +2 -2
- data/app/views/commontator/comments/vote.js.erb +1 -1
- data/app/views/commontator/comments/vote.js.erb~ +2 -2
- data/app/views/commontator/{commontator/_thread.html.erb~ → shared/_thread_link.html.erb} +1 -3
- data/app/views/commontator/subscriptions/{index.html.erb → _index.html.erb~} +0 -0
- data/app/views/commontator/subscriptions/_link.html.erb +15 -0
- data/app/views/commontator/subscriptions/_link.html.erb~ +15 -0
- data/app/views/commontator/subscriptions/_subscription_link.html.erb~ +8 -7
- data/app/views/commontator/subscriptions/create.js.erb~ +4 -2
- data/app/views/commontator/subscriptions/subscribe.js.erb +5 -0
- data/app/views/commontator/subscriptions/subscribe.js.erb~ +5 -0
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb +4 -12
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb~ +4 -12
- data/app/views/commontator/threads/_actions.html.erb~ +28 -0
- data/app/views/commontator/{commontator/_thread.html.erb → threads/_link.html.erb~} +1 -1
- data/app/views/commontator/threads/_show.html.erb +30 -2
- data/app/views/commontator/threads/_show.html.erb~ +31 -3
- data/app/views/commontator/threads/close.js.erb~ +5 -0
- data/app/views/commontator/threads/{show.html.erb → show.html.erb~} +0 -0
- data/app/views/commontator/threads/show.js.erb +1 -1
- data/app/views/commontator/threads/show.js.erb~ +6 -0
- data/config/initializers/commontator.rb +17 -11
- data/config/initializers/commontator.rb~ +16 -11
- data/config/routes.rb +2 -4
- data/config/routes.rb~ +4 -2
- data/lib/commontator.rb +1 -1
- data/lib/commontator.rb~ +2 -2
- data/lib/commontator/version.rb +1 -1
- data/lib/commontator/version.rb~ +1 -1
- data/test/dummy/config/initializers/commontator.rb +23 -12
- data/test/dummy/config/initializers/commontator.rb~ +174 -0
- data/test/dummy/log/development.log +6 -0
- metadata +15 -11
- data/app/views/commontator/comments/edit.html.erb +0 -6
- data/app/views/commontator/comments/new.html.erb +0 -8
- data/app/views/commontator/subscriptions/_subscription_link.html.erb +0 -12
- data/app/views/commontator/subscriptions/create.js.erb +0 -5
- data/app/views/commontator/subscriptions/destroy.js.erb +0 -5
@@ -1,4 +1,4 @@
|
|
1
|
-
<% @thread.comments.each do |comment|
|
1
|
+
<% @thread.comments.each do |comment| %>
|
2
2
|
$("#comment_<%= comment.id.to_s %>_actions_span").html("<%= escape_javascript(
|
3
3
|
render :partial => 'actions',
|
4
4
|
:locals => {:comment => comment}) %>");
|
@@ -12,4 +12,4 @@ $("#thread_<%= @thread.id %>_new_comment_div").hide();
|
|
12
12
|
|
13
13
|
$("#thread_<%= @thread.id %>_new_comment_link_span").show();
|
14
14
|
|
15
|
-
<%=
|
15
|
+
<%= javascript_proc(self) %>
|
@@ -6,10 +6,10 @@ $("#comment_<%= @comment.id.to_s %>_timestamp_span").html("<%= escape_javascript
|
|
6
6
|
|
7
7
|
$("#comment_<%= @comment.id.to_s %>_actions_span").html("<%= escape_javascript(
|
8
8
|
render :partial => 'actions',
|
9
|
-
:locals => {:comment => comment}) %>");
|
9
|
+
:locals => {:comment => @comment}) %>");
|
10
10
|
|
11
11
|
$("#comment_<%= @comment.id %>_votes_span").html("<%= escape_javascript(
|
12
12
|
render :partial => 'votes',
|
13
13
|
:locals => {:comment => @comment}) %>");
|
14
14
|
|
15
|
-
<%=
|
15
|
+
<%= javascript_proc(self) %>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
$("#comment_<%= @comment.id.to_s %>
|
1
|
+
$("#comment_<%= @comment.id.to_s %>_body_div").html("<%= escape_javascript(
|
2
2
|
render :partial => 'form',
|
3
3
|
:locals => {:comment => @comment}) %>");
|
4
4
|
|
5
|
-
<%=
|
5
|
+
<%= javascript_proc(self) %>
|
@@ -5,8 +5,8 @@ $("#thread_<%= @thread.id %>_new_comment_div").html("<%= escape_javascript(
|
|
5
5
|
:thread => @thread
|
6
6
|
}) %>");
|
7
7
|
|
8
|
-
$("#thread_<%= @thread.id %>_new_comment_div").
|
8
|
+
$("#thread_<%= @thread.id %>_new_comment_div").show();
|
9
9
|
|
10
10
|
$("#thread_<%= @thread.id %>_new_comment_link_span").hide();
|
11
11
|
|
12
|
-
<%=
|
12
|
+
<%= javascript_proc(self) %>
|
@@ -1,7 +1,7 @@
|
|
1
|
-
$("#comment_<%= @comment.id.to_s %>
|
1
|
+
$("#comment_<%= @comment.id.to_s %>_body_div").html("<%= escape_javascript(
|
2
2
|
render :partial => 'body', :locals => {:comment => @comment}) %>");
|
3
3
|
|
4
4
|
$("#comment_<%= @comment.id.to_s %>_timestamp_span").html("<%= escape_javascript(
|
5
5
|
comment_timestamp(@comment)) %>");
|
6
6
|
|
7
|
-
<%=
|
7
|
+
<%= javascript_proc(self) %>
|
@@ -1,13 +1,11 @@
|
|
1
1
|
<% # Clients of this partial must supply the following variable:
|
2
|
-
#
|
2
|
+
# thread
|
3
3
|
%>
|
4
4
|
|
5
5
|
<% user = send(Commontator.current_user_method) %>
|
6
|
-
<% thread = commontable.thread %>
|
7
6
|
|
8
7
|
<% if thread.can_be_read_by?(user) %>
|
9
8
|
<%= stylesheet_link_tag "commontator/application", :media => "all" %>
|
10
|
-
<%= javascript_include_tag "commontator/application" %>
|
11
9
|
|
12
10
|
<div id="thread_<%= thread.id %>_div" class="thread">
|
13
11
|
<%= link_to 'View ' + thread.config.comment_name.pluralize, commontator.thread_path(thread), :remote => true %>
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% # Clients of this partial must supply the following variable:
|
2
|
+
# thread
|
3
|
+
%>
|
4
|
+
|
5
|
+
<% is_subscribed = thread.is_subscribed?(@commontator) %>
|
6
|
+
<% sub_string = is_subscribed ? "unsubscribe" : "subscribe" %>
|
7
|
+
<%= link_to sub_string.capitalize,
|
8
|
+
polymorphic_path([sub_string, thread]),
|
9
|
+
:confirm => (is_subscribed ? \
|
10
|
+
"Are you sure you want to unsubscribe from this thread?" : \
|
11
|
+
nil),
|
12
|
+
:method => :put,
|
13
|
+
:id => "thread_#{thread.id.to_s}_#{sub_string}_link",
|
14
|
+
:class => "thread_#{sub_string}_link",
|
15
|
+
:remote => true %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% # Clients of this partial must supply the following variable:
|
2
|
+
# thread
|
3
|
+
%>
|
4
|
+
|
5
|
+
<% is_subscribed = thread.is_subscribed?(@commontator) %>
|
6
|
+
<% sub_string = is_subscribed ? "unsubscribe" : "subscribe" %>
|
7
|
+
<%= link_to sub_string.capitalize,
|
8
|
+
polymorphic_path([sub_string, thread]),
|
9
|
+
:confirm => (is_subscribed ? \
|
10
|
+
"Are you sure you want to unsubscribe from this thread?\n" : \
|
11
|
+
nil),
|
12
|
+
:method => :put,
|
13
|
+
:id => "thread_#{thread.id.to_s}_#{sub_string}_link",
|
14
|
+
:class => "thread_#{sub_string}_link",
|
15
|
+
:remote => true %>
|
@@ -1,12 +1,13 @@
|
|
1
1
|
<% # Clients of this partial must supply the following variable:
|
2
|
-
#
|
2
|
+
# thread
|
3
3
|
%>
|
4
4
|
|
5
|
-
<%
|
6
|
-
<% sub_string =
|
5
|
+
<% is_subscribed = thread.is_subscribed?(@commontator)
|
6
|
+
<% sub_string = is_subscribed ? "unsubscribe" : "subscribe" %>
|
7
7
|
<%= link_to sub_string.capitalize,
|
8
|
-
polymorphic_path([sub_string,
|
9
|
-
:confirm => (
|
10
|
-
|
11
|
-
|
8
|
+
polymorphic_path([sub_string, thread]),
|
9
|
+
:confirm => (is_subscribed ? \
|
10
|
+
"Are you sure you want to unsubscribe from ' + \
|
11
|
+
commontable_name(thread) + '?\n" : nil),
|
12
|
+
:method => :put,
|
12
13
|
:remote => true %>
|
@@ -1,3 +1,5 @@
|
|
1
|
-
$("#
|
1
|
+
$("#subscription_span").html("<%= escape_javascript(
|
2
2
|
render :partial => 'subscription_link',
|
3
|
-
:locals => {:
|
3
|
+
:locals => {:thread => @thread}) %>");
|
4
|
+
|
5
|
+
<%= javascript_callback %>
|
@@ -1,14 +1,6 @@
|
|
1
|
-
<h4><%= @commontator_name %>'s <%= @thread.config.comment_name %> on <%= @commontable_name %> #<%= @commontable_id
|
1
|
+
<h4><%= @commontator_name %>'s <%= @thread.config.comment_name %> on <%= @commontable_name %> #<%= @commontable_id %>:</h4>
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
white-space: -pre-wrap;
|
6
|
-
white-space: -o-pre-wrap;
|
7
|
-
word-wrap: break-word;"><%= @comment.body %></pre>
|
3
|
+
<%= render :partial => 'commontator/comments/body',
|
4
|
+
:locals => { :comment => @comment } %>
|
8
5
|
|
9
|
-
<p
|
10
|
-
|
11
|
-
<p><%= link_to "Visit " + @commontable_name, main_app.polymorphic_path(@commontable) %></p>
|
12
|
-
<p><%= link_to "View " + @thread.config.comment_name.pluralize + " on " + @commontable_name, @thread %></p>
|
13
|
-
<p><%= link_to "Post a new " + @thread.config.comment_name, new_thread_comment_path(@thread) %></p>
|
14
|
-
<p><%= link_to "Unsubscribe from this thread", unsubscribe_thread_path(@thread) %></p>
|
6
|
+
<p><a href="<%= @commontable_url %>">Click here</a> to visit this thread.</p>
|
@@ -1,14 +1,6 @@
|
|
1
|
-
<h4><%= @commontator_name %>'s <%= @thread.config.comment_name %> on <%= @commontable_name %> #<%= @commontable_id
|
1
|
+
<h4><%= @commontator_name %>'s <%= @thread.config.comment_name %> on <%= @commontable_name %> #<%= @commontable_id %>:</h4>
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
white-space: -pre-wrap;
|
6
|
-
white-space: -o-pre-wrap;
|
7
|
-
word-wrap: break-word;"><%= @comment.body %></pre>
|
3
|
+
<%= render :partial => 'commontator/comments/body',
|
4
|
+
:locals => { :comment => @comment } %>
|
8
5
|
|
9
|
-
<p
|
10
|
-
|
11
|
-
<p><%= link_to "Visit " + @commontable_name, @commontable %></p>
|
12
|
-
<p><%= link_to "View " + @thread.config.comment_name.pluralize + " on " + @commontable_name, @thread %></p>
|
13
|
-
<p><%= link_to "Post a new " + @thread.config.comment_name, new_thread_comment_path(@thread) %></p>
|
14
|
-
<p><%= link_to "Unsubscribe from this thread", unsubscribe_thread_path(@thread) %></p>
|
6
|
+
<p><a href="<%= @commontable_url %>">click here</a> to visit this thread.</p>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<% # Clients of this partial must supply the following variables:
|
2
|
+
# thread
|
3
|
+
%>
|
4
|
+
|
5
|
+
<% can_subscribe = thread.can_subscribe?(@commontator) %>
|
6
|
+
<% can_edit = thread.can_be_edited_by?(@commontator) %>
|
7
|
+
|
8
|
+
<% if can_subscribe %>
|
9
|
+
<span id="thread_<%= thread.id.to_s %>_subscription_span" class="thread_subscription">
|
10
|
+
<%= render :partial => 'commontator/subscriptions/link',
|
11
|
+
:locals => {:thread => thread} %>
|
12
|
+
</span>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
<% if can_edit %>
|
18
|
+
<% is_closed = thread.is_closed?
|
19
|
+
<% close_string = is_closed ? "reopen" : "close" %>
|
20
|
+
<%= link_to close_string.capitalize,
|
21
|
+
polymorphic_path([close_string, thread]),
|
22
|
+
:confirm => (!is_closed ? \
|
23
|
+
'Are you sure you want to close this thread' : nil),
|
24
|
+
:method => :put,
|
25
|
+
:id => "thread_#{thread.id.to_s}_#{close_string}_link",
|
26
|
+
:class => "thread_#{close_string}_link",
|
27
|
+
:remote => true %>
|
28
|
+
<% end %>
|
@@ -2,11 +2,37 @@
|
|
2
2
|
# thread
|
3
3
|
%>
|
4
4
|
|
5
|
-
|
5
|
+
<% can_subscribe = thread.can_subscribe?(@commontator) %>
|
6
|
+
<% can_edit = thread.can_be_edited_by?(@commontator) %>
|
7
|
+
|
8
|
+
<span id="thread_<%= thread.id.to_s %>_header_span" class="thread_header">
|
6
9
|
<%= thread.config.comment_name.capitalize.pluralize %>
|
7
10
|
</span>
|
8
11
|
|
9
|
-
<
|
12
|
+
<span id="thread_<%= thread.id.to_s %>_actions_span" class="thread_actions">
|
13
|
+
<% if can_subscribe %>
|
14
|
+
<span id="thread_<%= thread.id.to_s %>_subscription_span" class="thread_subscription">
|
15
|
+
<%= render :partial => 'commontator/subscriptions/link',
|
16
|
+
:locals => {:thread => thread} %>
|
17
|
+
</span>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
<% if can_edit %>
|
23
|
+
<% is_closed = thread.is_closed? %>
|
24
|
+
<% close_string = is_closed ? "reopen" : "close" %>
|
25
|
+
<%= link_to close_string.capitalize,
|
26
|
+
polymorphic_path([close_string, thread]),
|
27
|
+
:confirm => (!is_closed ? \
|
28
|
+
'Are you sure you want to close this thread?' : nil),
|
29
|
+
:method => :put,
|
30
|
+
:id => "thread_#{thread.id.to_s}_#{close_string}_link",
|
31
|
+
:class => "thread_#{close_string}_link" %>
|
32
|
+
<% end %>
|
33
|
+
</span>
|
34
|
+
|
35
|
+
<div id="thread_<%= thread.id.to_s %>_comment_list_div" class="thread_comment_list">
|
10
36
|
<% thread.ordered_comments.each do |comment| %>
|
11
37
|
<% next unless comment.can_be_read_by?(@commontator) %>
|
12
38
|
<%= render :partial => 'commontator/comments/show',
|
@@ -16,6 +42,8 @@
|
|
16
42
|
|
17
43
|
<% unless thread.is_closed? %>
|
18
44
|
|
45
|
+
<br/>
|
46
|
+
|
19
47
|
<div id="thread_<%= thread.id %>_new_comment_div" class="thread_new_comment"></div>
|
20
48
|
|
21
49
|
<span id="thread_<%= thread.id %>_new_comment_link_span" class="thread_new_comment_link">
|
@@ -2,12 +2,38 @@
|
|
2
2
|
# thread
|
3
3
|
%>
|
4
4
|
|
5
|
-
|
5
|
+
<% can_subscribe = thread.can_subscribe?(@commontator) %>
|
6
|
+
<% can_edit = thread.can_be_edited_by?(@commontator) %>
|
7
|
+
|
8
|
+
<span id="thread_<%= thread.id.to_s %>_header_span" class="thread_header">
|
6
9
|
<%= thread.config.comment_name.capitalize.pluralize %>
|
7
10
|
</span>
|
8
11
|
|
9
|
-
<
|
10
|
-
<%
|
12
|
+
<span id="thread_<%= thread.id.to_s %>_actions_span" class="thread_actions">
|
13
|
+
<% if can_subscribe %>
|
14
|
+
<span id="thread_<%= thread.id.to_s %>_subscription_span" class="thread_subscription">
|
15
|
+
<%= render :partial => 'commontator/subscriptions/link',
|
16
|
+
:locals => {:thread => thread} %>
|
17
|
+
</span>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
<% if can_edit %>
|
23
|
+
<% is_closed = thread.is_closed? %>
|
24
|
+
<% close_string = is_closed ? "reopen" : "close" %>
|
25
|
+
<%= link_to close_string.capitalize,
|
26
|
+
polymorphic_path([close_string, thread]),
|
27
|
+
:confirm => (!is_closed ? \
|
28
|
+
'Are you sure you want to close this thread' : nil),
|
29
|
+
:method => :put,
|
30
|
+
:id => "thread_#{thread.id.to_s}_#{close_string}_link",
|
31
|
+
:class => "thread_#{close_string}_link" %>
|
32
|
+
<% end %>
|
33
|
+
</span>
|
34
|
+
|
35
|
+
<div id="thread_<%= thread.id.to_s %>_comment_list_div" class="thread_comment_list">
|
36
|
+
<% thread.ordered_comments.each do |comment| %>
|
11
37
|
<% next unless comment.can_be_read_by?(@commontator) %>
|
12
38
|
<%= render :partial => 'commontator/comments/show',
|
13
39
|
:locals => {:comment => comment} %>
|
@@ -16,6 +42,8 @@
|
|
16
42
|
|
17
43
|
<% unless thread.is_closed? %>
|
18
44
|
|
45
|
+
<br/>
|
46
|
+
|
19
47
|
<div id="thread_<%= thread.id %>_new_comment_div" class="thread_new_comment"></div>
|
20
48
|
|
21
49
|
<span id="thread_<%= thread.id %>_new_comment_link_span" class="thread_new_comment_link">
|
File without changes
|
@@ -8,13 +8,12 @@ Commontator.configure do |config|
|
|
8
8
|
# Default: 'current_user'
|
9
9
|
config.current_user_method = 'current_user'
|
10
10
|
|
11
|
-
# Proc that is called
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
#
|
16
|
-
#
|
17
|
-
config.javascript_proc = nil
|
11
|
+
# Proc that is called after any javascript runs (e.g. to clear flash)
|
12
|
+
# It is passed the 'self' object 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
|
+
# 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| '$("#error_explanation").remove();' }
|
18
17
|
|
19
18
|
|
20
19
|
# Commontator (User model) Configuration
|
@@ -57,14 +56,20 @@ Commontator.configure do |config|
|
|
57
56
|
# as an argument to acts_as_commontable in each one
|
58
57
|
# Default: 'commontable'
|
59
58
|
config.commontable_name = 'commontable'
|
59
|
+
|
60
|
+
# Proc that returns the commontable url that contains the thread
|
61
|
+
# (defaults to the commontable show url)
|
62
|
+
# Main application's routes can be accessed using main_app object
|
63
|
+
# Default: lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
|
64
|
+
config.commontable_url_proc = lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
|
60
65
|
|
61
66
|
# Proc that returns the subscription email subject
|
62
67
|
# Default:
|
63
|
-
#
|
68
|
+
# lambda do |params|
|
64
69
|
# "#{params[:commontator_name]} #{params[:config].comment_create_verb_past} a " + \
|
65
70
|
# "#{params[:config].comment_name} on #{params[:commontable_name]} ##{params[:commontable_id]}"
|
66
71
|
# end
|
67
|
-
config.subscription_email_subject_proc =
|
72
|
+
config.subscription_email_subject_proc = lambda do |params|
|
68
73
|
"#{params[:commontator_name]} #{params[:config].comment_create_verb_past} a " + \
|
69
74
|
"#{params[:config].comment_name} on #{params[:commontable_name]} ##{params[:commontable_id]}"
|
70
75
|
end
|
@@ -128,8 +133,9 @@ Commontator.configure do |config|
|
|
128
133
|
config.commontable_id_method = 'id'
|
129
134
|
|
130
135
|
# Method called on commontable and passed user as argument
|
131
|
-
# If true, that user is
|
132
|
-
#
|
136
|
+
# If true, that user is a moderator for that particular commontable's thread
|
137
|
+
# and is given admin-like capabilities for that thread only
|
138
|
+
# Default: '' (no thread-specific moderators)
|
133
139
|
config.can_edit_thread_method = ''
|
134
140
|
|
135
141
|
# Method called on commontable and passed user as argument
|