commontator 0.4.1 → 0.5.12
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +35 -23
- data/app/assets/stylesheets/commontator/comments.css +1 -1
- data/app/assets/stylesheets/commontator/comments.css~ +0 -4
- data/app/controllers/commontator/application_controller.rb +4 -5
- data/app/controllers/commontator/application_controller.rb~ +5 -5
- data/app/controllers/commontator/comments_controller.rb +30 -30
- data/app/controllers/commontator/comments_controller.rb~ +31 -31
- data/app/controllers/commontator/subscriptions_controller.rb +8 -7
- data/app/controllers/commontator/subscriptions_controller.rb~ +6 -7
- data/app/controllers/commontator/threads_controller.rb +8 -9
- data/app/controllers/commontator/threads_controller.rb~ +9 -10
- data/app/helpers/commontator/comments_helper.rb~ +14 -24
- data/app/helpers/commontator/subscriptions_helper.rb~ +3 -3
- data/app/helpers/commontator/threads_helper.rb +0 -8
- data/app/helpers/commontator/threads_helper.rb~ +5 -5
- data/app/mailers/commontator/subscriptions_mailer.rb +8 -8
- data/app/mailers/commontator/subscriptions_mailer.rb~ +9 -10
- data/app/models/commontator/comment.rb +14 -6
- data/app/models/commontator/comment.rb~ +15 -12
- data/app/views/commontator/comments/_actions.html.erb +6 -5
- data/app/views/commontator/comments/_actions.html.erb~ +6 -5
- data/app/views/commontator/comments/_body.html.erb +2 -1
- data/app/views/commontator/comments/_body.html.erb~ +1 -2
- data/app/views/commontator/comments/_form.html.erb +8 -3
- data/app/views/commontator/comments/_form.html.erb~ +7 -4
- data/app/views/commontator/comments/_show.html.erb +11 -8
- data/app/views/commontator/comments/_show.html.erb~ +11 -8
- data/app/views/commontator/comments/_votes.html.erb +7 -6
- data/app/views/commontator/comments/create.js.erb +4 -2
- data/app/views/commontator/comments/delete.js.erb +5 -3
- data/app/views/commontator/comments/delete.js.erb~ +5 -3
- data/app/views/commontator/comments/update.js.erb +1 -1
- data/app/views/commontator/comments/update.js.erb~ +1 -1
- data/app/views/commontator/comments/vote.js.erb +2 -1
- data/app/views/commontator/shared/_thread.html.erb +17 -0
- data/app/views/commontator/shared/_thread.html.erb~ +16 -0
- data/app/views/commontator/shared/_thread_link.html.erb~ +16 -0
- data/app/views/commontator/subscriptions/_link.html.erb +3 -2
- data/app/views/commontator/subscriptions/subscribe.js.erb +2 -1
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb +1 -1
- data/app/views/commontator/threads/_show.html.erb +18 -11
- data/app/views/commontator/threads/_show.html.erb~ +18 -11
- data/app/views/commontator/threads/show.js.erb +2 -1
- data/config/initializers/commontator.rb +14 -14
- data/db/migrate/0_install_commontator.rb +3 -3
- data/lib/commontator.rb +5 -6
- data/lib/commontator.rb~ +5 -6
- data/lib/commontator/acts_as_commontable.rb +2 -0
- data/lib/commontator/acts_as_commontator.rb +2 -0
- data/lib/commontator/controller_includes.rb +23 -0
- data/lib/commontator/controller_includes.rb~ +23 -0
- data/lib/commontator/shared_helper.rb +42 -0
- data/lib/commontator/shared_helper.rb~ +42 -0
- data/lib/commontator/shared_methods.rb~ +24 -0
- data/lib/commontator/version.rb +1 -1
- data/lib/commontator/version.rb~ +1 -1
- data/test/dummy/config/initializers/commontator.rb +15 -15
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/1_install_commontator.commontator.rb +3 -3
- data/test/dummy/db/schema.rb +3 -3
- data/test/dummy/log/development.log +64 -0
- metadata +10 -70
- data/app/assets/stylesheets/commontator/application.css~ +0 -88
- data/app/assets/stylesheets/commontator/threads.css~ +0 -13
- data/app/helpers/commontator/application_helper.rb~ +0 -11
- data/app/helpers/commontator/comments_helper.rb +0 -51
- data/app/helpers/commontator/commontable_helper.rb~ +0 -9
- data/app/helpers/commontator/commontator_helper.rb +0 -8
- data/app/helpers/commontator/commontator_helper.rb~ +0 -8
- data/app/helpers/commontator/subscriptions_helper.rb +0 -8
- data/app/mailers/commontator/subscription_mailer.rb~ +0 -38
- data/app/models/commontator/subscription.rb~ +0 -21
- data/app/models/commontator/thread.rb~ +0 -143
- data/app/views/commontator/comments/_votes.html.erb~ +0 -62
- data/app/views/commontator/comments/create.js.erb~ +0 -15
- data/app/views/commontator/comments/destroy.js.erb~ +0 -1
- data/app/views/commontator/comments/edit.html.erb~ +0 -6
- data/app/views/commontator/comments/edit.js.erb~ +0 -5
- data/app/views/commontator/comments/new.html.erb~ +0 -8
- data/app/views/commontator/comments/new.js.erb~ +0 -12
- data/app/views/commontator/comments/vote.js.erb~ +0 -5
- data/app/views/commontator/shared/_thread_link.html.erb +0 -13
- data/app/views/commontator/subscriptions/_index.html.erb~ +0 -16
- data/app/views/commontator/subscriptions/_link.html.erb~ +0 -15
- data/app/views/commontator/subscriptions/_subscription_link.html.erb~ +0 -13
- data/app/views/commontator/subscriptions/create.js.erb~ +0 -5
- data/app/views/commontator/subscriptions/destroy.js.erb~ +0 -3
- data/app/views/commontator/subscriptions/index.html.erb~ +0 -16
- data/app/views/commontator/subscriptions/subscribe.js.erb~ +0 -5
- data/app/views/commontator/subscriptions_mailer/comment_created_email.html.erb~ +0 -6
- data/app/views/commontator/threads/_actions.html.erb~ +0 -28
- data/app/views/commontator/threads/_link.html.erb~ +0 -14
- data/app/views/commontator/threads/close.js.erb~ +0 -5
- data/app/views/commontator/threads/show.html.erb~ +0 -3
- data/app/views/commontator/threads/show.js.erb~ +0 -6
- data/config/initializers/commontator.rb~ +0 -179
- data/config/routes.rb~ +0 -24
- data/db/migrate/0_install_commontator.rb~ +0 -48
- data/lib/commontator/acts_as_commontable.rb~ +0 -39
- data/lib/commontator/acts_as_commontator.rb~ +0 -28
- data/lib/commontator/commontable_config.rb~ +0 -13
- data/lib/commontator/commontator_config.rb~ +0 -13
- data/lib/commontator/routes.rb~ +0 -37
- data/lib/tasks/commontator_tasks.rake~ +0 -41
- data/test/dummy/config/initializers/commontator.rb~ +0 -179
- data/test/dummy/config/routes.rb~ +0 -3
- data/test/functional/comment_thread_subscriptions_controller_test.rb~ +0 -125
- data/test/functional/comments_controller_test.rb~ +0 -184
- data/test/functional/subscriptions_controller_test.rb~ +0 -122
- data/test/unit/comment_test.rb~ +0 -38
- data/test/unit/comment_thread_subscription_test.rb~ +0 -18
- data/test/unit/comment_thread_test.rb~ +0 -60
- data/test/unit/helpers/comment_thread_subscriptions_helper_test.rb~ +0 -7
- data/test/unit/helpers/comments_helper_test.rb~ +0 -7
- data/test/unit/helpers/subscriptions_helper_test.rb~ +0 -4
- data/test/unit/subscription_test.rb~ +0 -15
- data/test/unit/thread_test.rb~ +0 -57
@@ -1,16 +0,0 @@
|
|
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>
|
@@ -1,6 +0,0 @@
|
|
1
|
-
<h4><%= @commontator_name %>'s <%= @thread.config.comment_name %> on <%= @commontable_name %> #<%= @commontable_id %>:</h4>
|
2
|
-
|
3
|
-
<%= render :partial => 'commontator/comments/body',
|
4
|
-
:locals => { :comment => @comment } %>
|
5
|
-
|
6
|
-
<p><a href="<%= @commontable_url %>">click here</a> to visit this thread.</p>
|
@@ -1,28 +0,0 @@
|
|
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 %>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<% # Clients of this partial must supply the following variable:
|
2
|
-
# thread
|
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 %>
|
@@ -1,179 +0,0 @@
|
|
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
|
-
|
5
|
-
# Engine Configuration
|
6
|
-
|
7
|
-
# Method called on ApplicationController to return the current user
|
8
|
-
# Default: 'current_user'
|
9
|
-
config.current_user_method = 'current_user'
|
10
|
-
|
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();' }
|
17
|
-
|
18
|
-
|
19
|
-
# Commontator (User model) Configuration
|
20
|
-
|
21
|
-
# The name used if the commontator's name cannot be retrieved
|
22
|
-
# Default: 'Anonymous'
|
23
|
-
config.commontator_missing_name = 'Anonymous'
|
24
|
-
|
25
|
-
# Whether the commontator's name is clickable in the comment view
|
26
|
-
# Default: false
|
27
|
-
config.commontator_name_clickable = false
|
28
|
-
|
29
|
-
# The method that return the commontator's email address
|
30
|
-
# Default: 'email'
|
31
|
-
config.commontator_email_method = 'email'
|
32
|
-
|
33
|
-
# The method that return the commontator's name
|
34
|
-
# Default: ''
|
35
|
-
config.commontator_name_method = ''
|
36
|
-
|
37
|
-
# Method that returns true if the commontator is an admin for all threads
|
38
|
-
# Admins can always delete other users' comments and close threads
|
39
|
-
# Default: '' (no admins)
|
40
|
-
config.is_admin_method = ''
|
41
|
-
|
42
|
-
|
43
|
-
# Commontable (Commentable model) Configuration
|
44
|
-
|
45
|
-
# What a comment is called in your application
|
46
|
-
# Default: 'comment'
|
47
|
-
config.comment_name = 'comment'
|
48
|
-
|
49
|
-
# Verb used when creating comments (present)
|
50
|
-
# Default: 'post'
|
51
|
-
config.comment_create_verb_present = 'post'
|
52
|
-
|
53
|
-
# Verb used when creating comments (past)
|
54
|
-
# Default: 'posted'
|
55
|
-
config.comment_create_verb_past = 'posted'
|
56
|
-
|
57
|
-
# What a commontable is called in your application
|
58
|
-
# If you have multiple commontable models,
|
59
|
-
# you might want to pass this configuration value
|
60
|
-
# as an argument to acts_as_commontable in each one
|
61
|
-
# Default: 'commontable'
|
62
|
-
config.commontable_name = 'commontable'
|
63
|
-
|
64
|
-
# Proc that returns the commontable url that contains the thread
|
65
|
-
# (defaults to the commontable show url)
|
66
|
-
# Main application's routes can be accessed using main_app object
|
67
|
-
# Default: lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
|
68
|
-
config.commontable_url_proc = lambda { |main_app, commontable| main_app.polymorphic_url(commontable) }
|
69
|
-
|
70
|
-
# Proc that returns the subscription email subject
|
71
|
-
# Default:
|
72
|
-
# lambda do |params|
|
73
|
-
# "#{params[:commontator_name]} #{params[:config].comment_create_verb_past} a " + \
|
74
|
-
# "#{params[:config].comment_name} on #{params[:commontable_name]} ##{params[:commontable_id]}"
|
75
|
-
# end
|
76
|
-
config.subscription_email_subject_proc = lambda do |params|
|
77
|
-
"#{params[:commontator_name]} #{params[:config].comment_create_verb_past} a " + \
|
78
|
-
"#{params[:config].comment_name} on #{params[:commontable_name]} ##{params[:commontable_id]}"
|
79
|
-
end
|
80
|
-
|
81
|
-
# The format of the timestamps used by Commontator
|
82
|
-
# Default: '%b %d %Y, %I:%M %p'
|
83
|
-
config.timestamp_format = '%b %d %Y, %I:%M %p'
|
84
|
-
|
85
|
-
# Whether admins can edit other users' comments
|
86
|
-
# Default: false
|
87
|
-
config.admin_can_edit_comments = false
|
88
|
-
|
89
|
-
# Whether users automatically subscribe to a thread when commenting
|
90
|
-
# Default: false
|
91
|
-
config.auto_subscribe_on_comment = false
|
92
|
-
|
93
|
-
# Whether users can edit their own comments
|
94
|
-
# Default: true
|
95
|
-
config.can_edit_own_comments = true
|
96
|
-
|
97
|
-
# Whether users can edit their own comments
|
98
|
-
# after someone posted a newer comment
|
99
|
-
# Default: false
|
100
|
-
config.can_edit_old_comments = false
|
101
|
-
|
102
|
-
# Whether users can delete their own comments
|
103
|
-
# Default: false
|
104
|
-
config.can_delete_own_comments = false
|
105
|
-
|
106
|
-
# Whether users can delete their own comments
|
107
|
-
# after someone posted a newer comment
|
108
|
-
# Default: false
|
109
|
-
config.can_delete_old_comments = false
|
110
|
-
|
111
|
-
# Whether users can manually subscribe or unsubscribe to threads
|
112
|
-
# Default: true
|
113
|
-
config.can_subscribe_to_thread = true
|
114
|
-
|
115
|
-
# Whether users can vote on other users' comments
|
116
|
-
# Note: requires acts_as_votable gem installed
|
117
|
-
# and configured for your application
|
118
|
-
# Default: false
|
119
|
-
config.comments_can_be_voted_on = false
|
120
|
-
|
121
|
-
# Whether comments should be ordered by vote score
|
122
|
-
# instead of by order posted
|
123
|
-
# Default: false
|
124
|
-
config.comments_ordered_by_votes = false
|
125
|
-
|
126
|
-
# Whether users can read threads closed by admins
|
127
|
-
# Default: true
|
128
|
-
config.closed_threads_are_readable = true
|
129
|
-
|
130
|
-
# Whether comments deleted by admins can be seen
|
131
|
-
# (the content will still be hidden)
|
132
|
-
# Default: true
|
133
|
-
config.deleted_comments_are_visible = true
|
134
|
-
|
135
|
-
# Method called on commontable to return its id
|
136
|
-
# Default: 'id'
|
137
|
-
config.commontable_id_method = 'id'
|
138
|
-
|
139
|
-
# Method called on commontable and passed user as argument
|
140
|
-
# If true, that user is a moderator for that particular commontable's thread
|
141
|
-
# and is given admin-like capabilities for that thread only
|
142
|
-
# Default: '' (no thread-specific moderators)
|
143
|
-
config.can_edit_thread_method = ''
|
144
|
-
|
145
|
-
# Method called on commontable and passed user as argument
|
146
|
-
# If true, that user is allowed to read that commontable's thread
|
147
|
-
# Default: '' (no read restrictions)
|
148
|
-
config.can_read_thread_method = ''
|
149
|
-
|
150
|
-
# Method called on commontable when a comment is created
|
151
|
-
# Passed user, comment as arguments
|
152
|
-
# Default: '' (no callback)
|
153
|
-
config.comment_created_callback = ''
|
154
|
-
|
155
|
-
# Method called on commontable when a comment is edited
|
156
|
-
# Passed user, comment as arguments
|
157
|
-
# Default: '' (no callback)
|
158
|
-
config.comment_edited_callback = ''
|
159
|
-
|
160
|
-
# Method called on commontable when a comment is deleted
|
161
|
-
# Passed user, comment as arguments
|
162
|
-
# Default: '' (no callback)
|
163
|
-
config.comment_deleted_callback = ''
|
164
|
-
|
165
|
-
# Method called on commontable when a thread is closed
|
166
|
-
# Passed user as argument
|
167
|
-
# Default: '' (no callback)
|
168
|
-
config.thread_closed_callback = ''
|
169
|
-
|
170
|
-
# Method called on commontable when a thread is subscribed to
|
171
|
-
# Passed user as argument
|
172
|
-
# Default: '' (no callback)
|
173
|
-
config.subscribe_callback = ''
|
174
|
-
|
175
|
-
# Method called on commontable when a thread is unsubscribed to
|
176
|
-
# Passed user as argument
|
177
|
-
# Default: '' (no callback)
|
178
|
-
config.unsubscribe_callback = ''
|
179
|
-
end
|
data/config/routes.rb~
DELETED
@@ -1,24 +0,0 @@
|
|
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
|
-
put 'subscribe', :to => 'subscriptions#create',
|
16
|
-
:as => 'subscribe',
|
17
|
-
:on => :member
|
18
|
-
put 'unsubscribe', :to => 'subscriptions#destroy',
|
19
|
-
:as => 'unsubscribe',
|
20
|
-
:on => :member
|
21
|
-
end
|
22
|
-
|
23
|
-
resources :subscriptions, :only => [:index]
|
24
|
-
end
|
@@ -1,48 +0,0 @@
|
|
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.integer "cached_votes_total", :default => 0
|
13
|
-
t.integer "cached_votes_up", :default => 0
|
14
|
-
t.integer "cached_votes_down", :default => 0
|
15
|
-
|
16
|
-
t.timestamps
|
17
|
-
end
|
18
|
-
|
19
|
-
create_table "commontator_subscriptions" do |t|
|
20
|
-
t.integer "subscriber_id"
|
21
|
-
t.string "subscriber_type"
|
22
|
-
t.integer "thread_id"
|
23
|
-
t.boolean "is_unread"
|
24
|
-
|
25
|
-
t.timestamps
|
26
|
-
end
|
27
|
-
|
28
|
-
create_table "commontator_threads" do |t|
|
29
|
-
t.integer "commontable_id"
|
30
|
-
t.string "commontable_type"
|
31
|
-
t.datetime "closed_at"
|
32
|
-
t.integer "closer_id"
|
33
|
-
t.string "closer_type"
|
34
|
-
|
35
|
-
t.timestamps
|
36
|
-
end
|
37
|
-
|
38
|
-
add_index :commontator_comments, [:commontator_id, :commontator_type, :thread_id], :name => "index_c_c_on_c_id_and_c_type_and_t_id"
|
39
|
-
add_index :commontator_comments, :thread_id
|
40
|
-
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"
|
41
|
-
add_index :commontator_subscriptions, :thread_id
|
42
|
-
add_index :commontator_threads, [:commontable_id, :commontable_type]
|
43
|
-
|
44
|
-
add_index :commontator_comments, :cached_votes_total
|
45
|
-
add_index :commontator_comments, :cached_votes_up
|
46
|
-
add_index :commontator_comments, :cached_votes_down
|
47
|
-
end
|
48
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Commontator
|
2
|
-
module ActsAsCommontable
|
3
|
-
def self.included(base)
|
4
|
-
base.class_attribute :is_commontable
|
5
|
-
base.is_commontable = false
|
6
|
-
base.extend(ClassMethods)
|
7
|
-
end
|
8
|
-
|
9
|
-
module ClassMethods
|
10
|
-
def acts_as_commontable(options = {})
|
11
|
-
class_eval do
|
12
|
-
has_one :thread, :as => :commontable, :class_name => 'Commontator::Thread', :dependent => :destroy
|
13
|
-
has_many :comments, :class_name => 'Commontator::Comment', :through => :thread
|
14
|
-
has_many :subscriptions, :class_name => 'Commontator::Subscription', :through => :thread
|
15
|
-
|
16
|
-
after_initialize :create_thread, :unless => :thread, :if => :id
|
17
|
-
before_validation :build_thread, :unless => :thread
|
18
|
-
|
19
|
-
validates_presence_of :thread
|
20
|
-
|
21
|
-
cattr_accessor :commontable_config
|
22
|
-
self.commontable_config = Commontator::CommontableConfig.new
|
23
|
-
self.is_commontable = true
|
24
|
-
|
25
|
-
def create_thread
|
26
|
-
thread = Commontator::Thread.new
|
27
|
-
thread.commontable = self
|
28
|
-
thread.save!
|
29
|
-
self.reload
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
alias_method :acts_as_commentable, :acts_as_commontable
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
ActiveRecord::Base.send :include, Commontator::ActsAsCommontable
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Commontator
|
2
|
-
module ActsAsCommontator
|
3
|
-
def self.included(base)
|
4
|
-
base.class_attribute :is_commontator
|
5
|
-
base.is_commontator = false
|
6
|
-
base.extend(ClassMethods)
|
7
|
-
end
|
8
|
-
|
9
|
-
module ClassMethods
|
10
|
-
def acts_as_commontator(options = {})
|
11
|
-
class_eval do
|
12
|
-
has_many :comments, :as => :commontator, :class_name => 'Commontator::Comment', :dependent => :destroy
|
13
|
-
has_many :subscriptions, :as => :subscriber, :class_name => 'Commontator::Subscription', :dependent => :destroy
|
14
|
-
|
15
|
-
cattr_accessor :commontator_config
|
16
|
-
self.commontator_config = Commontator::CommontatorConfig.new(options)
|
17
|
-
self.is_commontator = true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
alias_method :acts_as_commonter, :acts_as_commontator
|
22
|
-
alias_method :acts_as_commentator, :acts_as_commontator
|
23
|
-
alias_method :acts_as_commenter, :acts_as_commontator
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
ActiveRecord::Base.send :include, Commontator::ActsAsCommontator
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Commontator
|
2
|
-
class CommontableConfig
|
3
|
-
Commontator::COMMONTABLE_ATTRIBUTES.each do |attribute|
|
4
|
-
cattr_accessor attribute
|
5
|
-
end
|
6
|
-
|
7
|
-
def initialize(options = {})
|
8
|
-
Commontator::COMMONTABLE_CONFIG.keys.each do |attribute|
|
9
|
-
self.send attribute.to_s + '=', options[attribute] || Commontator.send(attribute)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Commontator
|
2
|
-
class CommontatorConfig
|
3
|
-
Commontator::COMMONTATOR_ATTRIBUTES.keys.each do |attribute|
|
4
|
-
cattr_accessor attribute
|
5
|
-
end
|
6
|
-
|
7
|
-
def initialize(options = {})
|
8
|
-
Commontator::COMMONTATOR_ATTRIBUTES.keys.each do |attribute|
|
9
|
-
self.send attribute.to_s + '=', options[attribute] || Commontator.send(attribute)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|