commontator 0.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
- data/README.md +35 -0
- data/Rakefile +40 -0
- data/app/assets/images/commontator/downvote.png +0 -0
- data/app/assets/images/commontator/downvote_hover.png +0 -0
- data/app/assets/images/commontator/upvote.png +0 -0
- data/app/assets/images/commontator/upvote_hover.png +0 -0
- data/app/assets/stylesheets/commontator/application.css +13 -0
- data/app/assets/stylesheets/commontator/application.css~ +88 -0
- data/app/assets/stylesheets/commontator/comments.css +86 -0
- data/app/assets/stylesheets/commontator/comments.css~ +90 -0
- data/app/assets/stylesheets/commontator/threads.css +13 -0
- data/app/assets/stylesheets/commontator/threads.css~ +13 -0
- data/app/controllers/commontator/application_controller.rb +18 -0
- data/app/controllers/commontator/application_controller.rb~ +16 -0
- data/app/controllers/commontator/comments_controller.rb +143 -0
- data/app/controllers/commontator/comments_controller.rb~ +143 -0
- data/app/controllers/commontator/subscriptions_controller.rb +42 -0
- data/app/controllers/commontator/subscriptions_controller.rb~ +40 -0
- data/app/controllers/commontator/threads_controller.rb +42 -0
- data/app/controllers/commontator/threads_controller.rb~ +43 -0
- data/app/helpers/commontator/application_helper.rb +11 -0
- data/app/helpers/commontator/application_helper.rb~ +11 -0
- data/app/helpers/commontator/comments_helper.rb +47 -0
- data/app/helpers/commontator/comments_helper.rb~ +58 -0
- data/app/helpers/commontator/commontable_helper.rb~ +9 -0
- data/app/helpers/commontator/commontator_helper.rb +8 -0
- data/app/helpers/commontator/commontator_helper.rb~ +8 -0
- data/app/helpers/commontator/subscriptions_helper.rb +8 -0
- data/app/helpers/commontator/subscriptions_helper.rb~ +8 -0
- data/app/helpers/commontator/threads_helper.rb +21 -0
- data/app/helpers/commontator/threads_helper.rb~ +32 -0
- data/app/mailers/commontator/subscription_mailer.rb~ +38 -0
- data/app/mailers/commontator/subscriptions_mailer.rb +51 -0
- data/app/mailers/commontator/subscriptions_mailer.rb~ +51 -0
- data/app/models/commontator/comment.rb +84 -0
- data/app/models/commontator/comment.rb~ +84 -0
- data/app/models/commontator/subscription.rb +21 -0
- data/app/models/commontator/subscription.rb~ +21 -0
- data/app/models/commontator/thread.rb +138 -0
- data/app/models/commontator/thread.rb~ +141 -0
- data/app/views/commontator/comments/_actions.html.erb +32 -0
- data/app/views/commontator/comments/_actions.html.erb~ +33 -0
- data/app/views/commontator/comments/_body.html.erb +7 -0
- data/app/views/commontator/comments/_body.html.erb~ +8 -0
- data/app/views/commontator/comments/_form.html.erb +20 -0
- data/app/views/commontator/comments/_form.html.erb~ +21 -0
- data/app/views/commontator/comments/_show.html.erb +41 -0
- data/app/views/commontator/comments/_show.html.erb~ +45 -0
- data/app/views/commontator/comments/_votes.html.erb +60 -0
- data/app/views/commontator/comments/_votes.html.erb~ +62 -0
- data/app/views/commontator/comments/create.js.erb +15 -0
- data/app/views/commontator/comments/create.js.erb~ +15 -0
- data/app/views/commontator/comments/delete.js.erb +15 -0
- data/app/views/commontator/comments/delete.js.erb~ +15 -0
- data/app/views/commontator/comments/destroy.js.erb~ +1 -0
- data/app/views/commontator/comments/edit.html.erb +6 -0
- data/app/views/commontator/comments/edit.html.erb~ +6 -0
- data/app/views/commontator/comments/edit.js.erb +5 -0
- data/app/views/commontator/comments/edit.js.erb~ +5 -0
- data/app/views/commontator/comments/new.html.erb +8 -0
- data/app/views/commontator/comments/new.html.erb~ +8 -0
- data/app/views/commontator/comments/new.js.erb +12 -0
- data/app/views/commontator/comments/new.js.erb~ +12 -0
- data/app/views/commontator/comments/update.js.erb +7 -0
- data/app/views/commontator/comments/update.js.erb~ +7 -0
- data/app/views/commontator/comments/vote.js.erb +5 -0
- data/app/views/commontator/comments/vote.js.erb~ +5 -0
- data/app/views/commontator/commontator/_thread.html.erb +14 -0
- data/app/views/commontator/commontator/_thread.html.erb~ +15 -0
- data/app/views/commontator/subscriptions/_subscription_link.html.erb +12 -0
- data/app/views/commontator/subscriptions/_subscription_link.html.erb~ +12 -0
- data/app/views/commontator/subscriptions/create.js.erb +5 -0
- data/app/views/commontator/subscriptions/create.js.erb~ +3 -0
- data/app/views/commontator/subscriptions/destroy.js.erb +5 -0
- data/app/views/commontator/subscriptions/destroy.js.erb~ +3 -0
- data/app/views/commontator/subscriptions/index.html.erb +16 -0
- data/app/views/commontator/subscriptions/index.html.erb~ +16 -0
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb +14 -0
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb~ +14 -0
- data/app/views/commontator/threads/_show.html.erb +26 -0
- data/app/views/commontator/threads/_show.html.erb~ +26 -0
- data/app/views/commontator/threads/show.html.erb +3 -0
- data/app/views/commontator/threads/show.js.erb +6 -0
- data/app/views/layouts/commontator/application.html.erb +14 -0
- data/config/initializers/commontator.rb +7 -0
- data/config/routes.rb +24 -0
- data/config/routes.rb~ +22 -0
- data/db/migrate/0_install_commontator.rb +40 -0
- data/db/migrate/0_install_commontator.rb~ +40 -0
- data/lib/commontator.rb +66 -0
- data/lib/commontator.rb~ +66 -0
- data/lib/commontator/acts_as_commontable.rb +39 -0
- data/lib/commontator/acts_as_commontable.rb~ +42 -0
- data/lib/commontator/acts_as_commontator.rb +28 -0
- data/lib/commontator/acts_as_commontator.rb~ +37 -0
- data/lib/commontator/commontable_config.rb +13 -0
- data/lib/commontator/commontator_config.rb +13 -0
- data/lib/commontator/engine.rb +5 -0
- data/lib/commontator/routes.rb~ +37 -0
- data/lib/commontator/version.rb +3 -0
- data/lib/commontator/version.rb~ +3 -0
- data/test/commontator_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +16 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +204 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/functional/comment_thread_subscriptions_controller_test.rb~ +125 -0
- data/test/functional/comments_controller_test.rb +181 -0
- data/test/functional/comments_controller_test.rb~ +184 -0
- data/test/functional/subscriptions_controller_test.rb +122 -0
- data/test/functional/subscriptions_controller_test.rb~ +122 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/comment_test.rb +35 -0
- data/test/unit/comment_test.rb~ +38 -0
- data/test/unit/comment_thread_subscription_test.rb~ +18 -0
- data/test/unit/comment_thread_test.rb~ +60 -0
- data/test/unit/helpers/comment_thread_subscriptions_helper_test.rb~ +7 -0
- data/test/unit/helpers/comments_helper_test.rb +4 -0
- data/test/unit/helpers/comments_helper_test.rb~ +7 -0
- data/test/unit/helpers/subscriptions_helper_test.rb +4 -0
- data/test/unit/helpers/subscriptions_helper_test.rb~ +4 -0
- data/test/unit/subscription_test.rb +15 -0
- data/test/unit/subscription_test.rb~ +15 -0
- data/test/unit/thread_test.rb +57 -0
- data/test/unit/thread_test.rb~ +57 -0
- metadata +301 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<% # Clients of this partial must supply the following variable:
|
|
2
|
+
# commontable
|
|
3
|
+
%>
|
|
4
|
+
|
|
5
|
+
<% user = send(Commontator.current_user_method) %>
|
|
6
|
+
<% thread = commontable.thread %>
|
|
7
|
+
|
|
8
|
+
<% if thread.can_be_read_by?(user) %>
|
|
9
|
+
<%= stylesheet_link_tag "commontator/application", :media => "all" %>
|
|
10
|
+
|
|
11
|
+
<div id="thread_<%= thread.id %>_div" class="thread">
|
|
12
|
+
<%= link_to 'View ' + thread.config.comment_name.pluralize, commontator.thread_path(thread), :remote => true %>
|
|
13
|
+
</div>
|
|
14
|
+
<% end %>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<% # Clients of this partial must supply the following variable:
|
|
2
|
+
# commontable
|
|
3
|
+
%>
|
|
4
|
+
|
|
5
|
+
<% user = send(Commontator.current_user_method) %>
|
|
6
|
+
<% thread = commontable.thread %>
|
|
7
|
+
|
|
8
|
+
<% if thread.can_be_read_by?(user) %>
|
|
9
|
+
<%= stylesheet_link_tag "commontator/application", :media => "all" %>
|
|
10
|
+
<%= javascript_include_tag "commontator/application" %>
|
|
11
|
+
|
|
12
|
+
<div id="thread_<%= thread.id %>_div" class="thread">
|
|
13
|
+
<%= link_to 'View ' + thread.config.comment_name.pluralize, commontator.thread_path(thread), :remote => true %>
|
|
14
|
+
</div>
|
|
15
|
+
<% end %>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<% # Clients of this partial must supply the following variable:
|
|
2
|
+
# thread
|
|
3
|
+
%>
|
|
4
|
+
|
|
5
|
+
<% subscription = thread.is_subscribed?(@commontator)
|
|
6
|
+
<% sub_string = subscription ? "unsubscribe" : "subscribe" %>
|
|
7
|
+
<%= link_to sub_string.capitalize,
|
|
8
|
+
polymorphic_path([sub_string, commontable, :comments]),
|
|
9
|
+
:confirm => (subscription ? \
|
|
10
|
+
"Are you sure you want to unsubscribe from ' + commontable_name(thread) + '?\n" : \
|
|
11
|
+
nil),
|
|
12
|
+
:remote => true %>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<% # Clients of this partial must supply the following variable:
|
|
2
|
+
# comment_commontable_thread
|
|
3
|
+
%>
|
|
4
|
+
|
|
5
|
+
<% subscription = comment_commontable_thread.is_subscribed?(@user)
|
|
6
|
+
<% sub_string = subscription ? "unsubscribe" : "subscribe" %>
|
|
7
|
+
<%= link_to sub_string.capitalize,
|
|
8
|
+
polymorphic_path([sub_string, commontable, :comments]),
|
|
9
|
+
:confirm => (subscription ? \
|
|
10
|
+
"Are you sure you want to unsubscribe from ' + commontable_name(comment_commontable_thread) + '?\n" : \
|
|
11
|
+
nil),
|
|
12
|
+
:remote => true %>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<%= heading("Listing your subscriptions") %>
|
|
2
|
+
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<th width="100%"></th>
|
|
6
|
+
<th></th>
|
|
7
|
+
</tr>
|
|
8
|
+
|
|
9
|
+
<% @threads.each do |thread| %>
|
|
10
|
+
<tr>
|
|
11
|
+
<td><%= commontable_name(thread) %></td>
|
|
12
|
+
<td><%= link_to 'Unsubscribe', polymorphic_path([:unsubscribe, thread.commontable, :comments]),
|
|
13
|
+
:confirm => 'Are you sure you want to unsubscribe from ' + commontable_name(thread) + '?' %></td>
|
|
14
|
+
</tr>
|
|
15
|
+
<% end %>
|
|
16
|
+
</table>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<%= heading("Listing your subscriptions") %>
|
|
2
|
+
|
|
3
|
+
<table>
|
|
4
|
+
<tr>
|
|
5
|
+
<th width="100%"></th>
|
|
6
|
+
<th></th>
|
|
7
|
+
</tr>
|
|
8
|
+
|
|
9
|
+
<% @threads.each do |thread| %>
|
|
10
|
+
<tr>
|
|
11
|
+
<td><%= commentable_name(thread) %></td>
|
|
12
|
+
<td><%= link_to 'Unsubscribe', polymorphic_path([:unsubscribe, thread.commontable, :comments]),
|
|
13
|
+
:confirm => 'Are you sure you want to unsubscribe from ' + commontable_name(thread) + '?' %></td>
|
|
14
|
+
</tr>
|
|
15
|
+
<% end %>
|
|
16
|
+
</table>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<h4><%= @commontator_name %>'s <%= @thread.config.comment_name %> on <%= @commontable_name %> #<%= @commontable_id %></h4>
|
|
2
|
+
|
|
3
|
+
<pre style="white-space: pre-wrap;
|
|
4
|
+
white-space: -moz-pre-wrap !important;
|
|
5
|
+
white-space: -pre-wrap;
|
|
6
|
+
white-space: -o-pre-wrap;
|
|
7
|
+
word-wrap: break-word;"><%= @comment.body %></pre>
|
|
8
|
+
|
|
9
|
+
<p>Please use the links below to reply to this message:</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>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<h4><%= @commontator_name %>'s <%= @thread.config.comment_name %> on <%= @commontable_name %> #<%= @commontable_id %></h4>
|
|
2
|
+
|
|
3
|
+
<pre style="white-space: pre-wrap;
|
|
4
|
+
white-space: -moz-pre-wrap !important;
|
|
5
|
+
white-space: -pre-wrap;
|
|
6
|
+
white-space: -o-pre-wrap;
|
|
7
|
+
word-wrap: break-word;"><%= @comment.body %></pre>
|
|
8
|
+
|
|
9
|
+
<p>Please use the links below to reply to this message:</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>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<% # Clients of this partial must supply the following variable:
|
|
2
|
+
# thread
|
|
3
|
+
%>
|
|
4
|
+
|
|
5
|
+
<span id="thread_<%= thread.id %>_header_span" class="thread_header">
|
|
6
|
+
<%= thread.config.comment_name.capitalize.pluralize %>
|
|
7
|
+
</span>
|
|
8
|
+
|
|
9
|
+
<div id="thread_<%= thread.id %>_comment_list_div" class="thread_comment_list">
|
|
10
|
+
<% thread.comments.each do |comment| %>
|
|
11
|
+
<% next unless comment.can_be_read_by?(@commontator) %>
|
|
12
|
+
<%= render :partial => 'commontator/comments/show',
|
|
13
|
+
:locals => {:comment => comment} %>
|
|
14
|
+
<% end %>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<% unless thread.is_closed? %>
|
|
18
|
+
|
|
19
|
+
<div id="thread_<%= thread.id %>_new_comment_div" class="thread_new_comment"></div>
|
|
20
|
+
|
|
21
|
+
<span id="thread_<%= thread.id %>_new_comment_link_span" class="thread_new_comment_link">
|
|
22
|
+
<%= link_to thread.config.comment_create_verb_present.capitalize + ' ' + thread.config.comment_name,
|
|
23
|
+
new_thread_comment_path(thread), :remote => true %>
|
|
24
|
+
</span>
|
|
25
|
+
|
|
26
|
+
<% end %>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<% # Clients of this partial must supply the following variable:
|
|
2
|
+
# thread
|
|
3
|
+
%>
|
|
4
|
+
|
|
5
|
+
<span id="thread_<%= thread.id %>_header_span" class="thread_header">
|
|
6
|
+
<%= thread.config.comment_name.capitalize.pluralize %>
|
|
7
|
+
</span>
|
|
8
|
+
|
|
9
|
+
<div id="thread_<%= thread.id %>_comment_list_div" class="thread_comment_list">
|
|
10
|
+
<% thread.comments.each do |comment| %>
|
|
11
|
+
<% next unless comment.can_be_read_by?(@commontator)is_deleted? && !thread.config.deleted_comments_are_visible %>
|
|
12
|
+
<%= render :partial => 'commontator/comments/show',
|
|
13
|
+
:locals => {:comment => comment} %>
|
|
14
|
+
<% end %>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<% unless thread.is_closed? %>
|
|
18
|
+
|
|
19
|
+
<div id="thread_<%= thread.id %>_new_comment_div" class="thread_new_comment"></div>
|
|
20
|
+
|
|
21
|
+
<span id="thread_<%= thread.id %>_new_comment_link_span" class="thread_new_comment_link">
|
|
22
|
+
<%= link_to thread.config.comment_create_verb_present.capitalize + ' ' + thread.config.comment_name,
|
|
23
|
+
new_thread_comment_path(thread), :remote => true %>
|
|
24
|
+
</span>
|
|
25
|
+
|
|
26
|
+
<% end %>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Commontator</title>
|
|
5
|
+
<%= stylesheet_link_tag "commontator/application", :media => "all" %>
|
|
6
|
+
<%= javascript_include_tag "commontator/application" %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<%= yield %>
|
|
12
|
+
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Commontator::Engine.routes.draw do
|
|
2
|
+
resources :threads, :only => [:show] do
|
|
3
|
+
resources :comments, :except => [:index, :destroy], :shallow => true do
|
|
4
|
+
put 'delete', :on => :member
|
|
5
|
+
put 'undelete', :on => :member
|
|
6
|
+
|
|
7
|
+
put 'upvote', :on => :member
|
|
8
|
+
put 'downvote', :on => :member
|
|
9
|
+
put 'unvote', :on => :member
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
put 'close', :on => :member
|
|
13
|
+
put 'reopen', :on => :member
|
|
14
|
+
|
|
15
|
+
get 'subscribe', :to => 'subscriptions#create',
|
|
16
|
+
:as => 'subscribe',
|
|
17
|
+
:on => :member
|
|
18
|
+
get 'unsubscribe', :to => 'subscriptions#destroy',
|
|
19
|
+
:as => 'unsubscribe',
|
|
20
|
+
:on => :member
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
resources :subscriptions, :only => [:index]
|
|
24
|
+
end
|
data/config/routes.rb~
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Commontator::Engine.routes.draw do
|
|
2
|
+
resources :threads, :only => [:show] do
|
|
3
|
+
resources :comments, :except => [:index, :destroy], :shallow => true do
|
|
4
|
+
put 'delete', :on => :member
|
|
5
|
+
put 'undelete', :on => :member
|
|
6
|
+
put 'upvote', :on => :member
|
|
7
|
+
put 'downvote', :on => :member
|
|
8
|
+
put 'unvote', :on => :member
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
put 'close', :on => :member
|
|
12
|
+
put 'reopen', :on => :member
|
|
13
|
+
get 'subscribe', :to => 'subscriptions#create',
|
|
14
|
+
:as => 'subscribe',
|
|
15
|
+
:on => :member
|
|
16
|
+
get 'unsubscribe', :to => 'subscriptions#destroy',
|
|
17
|
+
:as => 'unsubscribe',
|
|
18
|
+
:on => :member
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
resources :subscriptions, :only => [:index]
|
|
22
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
class InstallCommontator < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table "commontator_comments" do |t|
|
|
4
|
+
t.text "body"
|
|
5
|
+
t.integer "commontator_id"
|
|
6
|
+
t.string "commontator_type"
|
|
7
|
+
t.datetime "deleted_at"
|
|
8
|
+
t.integer "deleter_id"
|
|
9
|
+
t.string "deleter_type"
|
|
10
|
+
t.integer "thread_id"
|
|
11
|
+
|
|
12
|
+
t.timestamps
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
create_table "commontator_subscriptions" do |t|
|
|
16
|
+
t.integer "subscriber_id"
|
|
17
|
+
t.string "subscriber_type"
|
|
18
|
+
t.integer "thread_id"
|
|
19
|
+
t.boolean "is_unread"
|
|
20
|
+
|
|
21
|
+
t.timestamps
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
create_table "commontator_threads" do |t|
|
|
25
|
+
t.integer "commontable_id"
|
|
26
|
+
t.string "commontable_type"
|
|
27
|
+
t.datetime "closed_at"
|
|
28
|
+
t.integer "closer_id"
|
|
29
|
+
t.string "closer_type"
|
|
30
|
+
|
|
31
|
+
t.timestamps
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
add_index :commontator_comments, [:commontator_id, :commontator_type, :thread_id], :name => "index_c_c_on_c_id_and_c_type_and_t_id"
|
|
35
|
+
add_index :commontator_comments, :thread_id
|
|
36
|
+
add_index :commontator_subscriptions, [:subscriber_id, :subscriber_type, :thread_id], :unique => true, :name => "index_c_s_on_s_id_and_s_type_and_t_id"
|
|
37
|
+
add_index :commontator_subscriptions, :thread_id
|
|
38
|
+
add_index :commontator_threads, [:commontable_id, :commontable_type]
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
class InstallCommontator < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table "commontator_comments" do |t|
|
|
4
|
+
t.text "body"
|
|
5
|
+
t.integer "commontator_id"
|
|
6
|
+
t.string "commontator_type"
|
|
7
|
+
t.datetime "deleted_at"
|
|
8
|
+
t.integer "deleter_id"
|
|
9
|
+
t.string "deleter_type"
|
|
10
|
+
t.integer "thread_id"
|
|
11
|
+
|
|
12
|
+
t.timestamps
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
create_table "commontator_subscriptions" do |t|
|
|
16
|
+
t.integer "subscriber_id"
|
|
17
|
+
t.string "subscriber_type"
|
|
18
|
+
t.integer "thread_id"
|
|
19
|
+
t.boolean "is_unread"
|
|
20
|
+
|
|
21
|
+
t.timestamps
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
create_table "commontator_threads" do |t|
|
|
25
|
+
t.integer "commontable_id"
|
|
26
|
+
t.string "commontable_type"
|
|
27
|
+
t.datetime "closed_at"
|
|
28
|
+
t.integer "closer_id"
|
|
29
|
+
t.string "closer_type"
|
|
30
|
+
|
|
31
|
+
t.timestamps
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
add_index :commontator_comments, [:commontator_id, :commontator_type, :thread_id], :name => "index_c_c_on_c_id_and_c_type_and_t_id"
|
|
35
|
+
add_index :commontator_comments, :thread_id
|
|
36
|
+
add_index :commontator_subscriptions, [:subscriber_id, :subscriber_type, :thread_id], :unique => true
|
|
37
|
+
add_index :commontator_subscriptions, :thread_id
|
|
38
|
+
add_index :commontator_threads, [:commontable_id, :commontable_type]
|
|
39
|
+
end
|
|
40
|
+
end
|
data/lib/commontator.rb
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module Commontator
|
|
2
|
+
# Attributes and default values
|
|
3
|
+
|
|
4
|
+
# Can be overriden in initializer only
|
|
5
|
+
ENGINE_CONFIG = {
|
|
6
|
+
:current_user_method => 'current_user',
|
|
7
|
+
:heading_proc => nil,
|
|
8
|
+
:javascript_proc => nil,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
# Can be overriden in initializer and acts_as_commontator
|
|
12
|
+
COMMONTATOR_CONFIG = {
|
|
13
|
+
:commontator_name_clickable => false,
|
|
14
|
+
:commontator_email_method => 'email',
|
|
15
|
+
:commontator_name_method => '',
|
|
16
|
+
:is_admin_method => ''
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# Can be overriden in initializer and acts_as_commontable
|
|
20
|
+
COMMONTABLE_CONFIG = {
|
|
21
|
+
:comment_name => 'comment',
|
|
22
|
+
:comment_create_verb_present => 'post',
|
|
23
|
+
:comment_create_verb_past => 'posted',
|
|
24
|
+
:commontable_name => 'commontable',
|
|
25
|
+
:subscription_email_subject_proc => Proc.new {|params| \
|
|
26
|
+
"#{params[:commontator_name]} #{params[:config].comment_create_verb_past} a " + \
|
|
27
|
+
"#{params[:config].comment_name} on #{params[:commontable_name]} ##{params[:commontable_id]}"},
|
|
28
|
+
:subscription_email_body_proc => nil,
|
|
29
|
+
:timestamp_format => '%b %d %Y, %I:%M %p',
|
|
30
|
+
:admin_can_edit_comments => false,
|
|
31
|
+
:auto_subscribe_on_comment => false,
|
|
32
|
+
:can_edit_old_comments => false,
|
|
33
|
+
:can_edit_own_comments => true,
|
|
34
|
+
:can_delete_old_comments => false,
|
|
35
|
+
:can_delete_own_comments => false,
|
|
36
|
+
:can_subscribe_to_thread => true,
|
|
37
|
+
:comments_can_be_voted_on => false,
|
|
38
|
+
:closed_threads_are_readable => true,
|
|
39
|
+
:deleted_comments_are_visible => true,
|
|
40
|
+
:commontable_id_method => 'id',
|
|
41
|
+
:can_edit_thread_method => '',
|
|
42
|
+
:can_read_thread_method => '',
|
|
43
|
+
:comment_created_callback => '',
|
|
44
|
+
:comment_edited_callback => '',
|
|
45
|
+
:comment_deleted_callback => '',
|
|
46
|
+
:thread_closed_callback => '',
|
|
47
|
+
:subscribe_callback => '',
|
|
48
|
+
:unsubscribe_callback => ''
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
ENGINE_CONFIG.merge(COMMONTATOR_CONFIG.merge(\
|
|
52
|
+
COMMONTABLE_CONFIG)).each do |key, value|
|
|
53
|
+
mattr_accessor key
|
|
54
|
+
self.send key.to_s + '=', value
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.configure
|
|
58
|
+
yield self
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
require 'commontator/engine'
|
|
63
|
+
require 'commontator/commontator_config'
|
|
64
|
+
require 'commontator/commontable_config'
|
|
65
|
+
require 'commontator/acts_as_commontator'
|
|
66
|
+
require 'commontator/acts_as_commontable'
|