commontator 4.8.0 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/MIT-LICENSE +0 -1
- data/README.md +1 -2
- data/app/assets/stylesheets/commontator/application.css +0 -1
- data/app/assets/stylesheets/commontator/comments.css +0 -1
- data/app/assets/stylesheets/commontator/threads.css +4 -9
- data/app/controllers/commontator/application_controller.rb +4 -4
- data/app/controllers/commontator/comments_controller.rb +5 -7
- data/app/controllers/commontator/subscriptions_controller.rb +1 -2
- data/app/controllers/commontator/threads_controller.rb +1 -3
- data/app/helpers/commontator/application_helper.rb +0 -1
- data/app/mailers/commontator/subscriptions_mailer.rb +0 -1
- data/app/models/commontator/comment.rb +0 -1
- data/app/models/commontator/subscription.rb +0 -1
- data/app/models/commontator/thread.rb +0 -1
- data/app/views/commontator/comments/_actions.html.erb +0 -1
- data/app/views/commontator/comments/_body.html.erb +0 -1
- data/app/views/commontator/comments/_form.html.erb +0 -1
- data/app/views/commontator/comments/_list.html.erb +2 -3
- data/app/views/commontator/comments/_show.html.erb +5 -6
- data/app/views/commontator/comments/_votes.html.erb +0 -1
- data/app/views/commontator/comments/cancel.js.erb +11 -4
- data/app/views/commontator/comments/create.js.erb +14 -7
- data/app/views/commontator/comments/delete.js.erb +5 -6
- data/app/views/commontator/comments/edit.js.erb +1 -2
- data/app/views/commontator/comments/new.js.erb +7 -10
- data/app/views/commontator/comments/update.js.erb +1 -2
- data/app/views/commontator/comments/vote.js.erb +2 -3
- data/app/views/commontator/shared/_thread.html.erb +4 -5
- data/app/views/commontator/subscriptions/_link.html.erb +0 -1
- data/app/views/commontator/subscriptions/subscribe.js.erb +2 -3
- data/app/views/commontator/subscriptions_mailer/comment_created.html.erb +0 -1
- data/app/views/commontator/threads/_reply.html.erb +25 -12
- data/app/views/commontator/threads/_show.html.erb +16 -17
- data/app/views/commontator/threads/_show.js.erb +5 -6
- data/app/views/commontator/threads/show.js.erb +5 -6
- data/config/initializers/commontator.rb +12 -1
- data/config/locales/commontator/en.yml +0 -1
- data/config/routes.rb +0 -1
- data/db/migrate/0_install_commontator.rb +26 -22
- data/lib/commontator.rb +1 -1
- data/lib/commontator/acts_as_commontable.rb +0 -1
- data/lib/commontator/acts_as_commontator.rb +0 -1
- data/lib/commontator/commontable_config.rb +0 -1
- data/lib/commontator/commontator_config.rb +0 -1
- data/lib/commontator/controller_includes.rb +9 -0
- data/lib/commontator/engine.rb +0 -1
- data/lib/commontator/link_renderer.rb +0 -1
- data/lib/commontator/security_transgression.rb +0 -1
- data/lib/commontator/shared_helper.rb +3 -3
- data/lib/commontator/version.rb +1 -2
- data/lib/tasks/commontator_tasks.rake +0 -1
- data/spec/app/controllers/commontator/comments_controller_spec.rb +2 -3
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +0 -1
- data/spec/app/controllers/commontator/threads_controller_spec.rb +0 -1
- data/spec/app/helpers/commontator/application_helper_spec.rb +0 -1
- data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb +0 -1
- data/spec/app/models/commontator/comment_spec.rb +0 -1
- data/spec/app/models/commontator/subscription_spec.rb +0 -1
- data/spec/app/models/commontator/thread_spec.rb +0 -1
- data/spec/dummy/README.md +0 -1
- data/spec/dummy/Rakefile +0 -1
- data/spec/dummy/app/assets/javascripts/application.js +0 -1
- data/spec/dummy/app/assets/stylesheets/application.css +0 -1
- data/spec/dummy/app/controllers/application_controller.rb +0 -1
- data/spec/dummy/app/controllers/dummy_models_controller.rb +0 -1
- data/spec/dummy/app/helpers/application_helper.rb +0 -1
- data/spec/dummy/app/models/dummy_model.rb +0 -1
- data/spec/dummy/app/models/dummy_user.rb +0 -1
- data/spec/dummy/app/views/dummy_model/show.html.erb +0 -1
- data/spec/dummy/app/views/layouts/application.html.erb +0 -1
- data/spec/dummy/config.ru +0 -1
- data/spec/dummy/config/application.rb +0 -1
- data/spec/dummy/config/boot.rb +0 -1
- data/spec/dummy/config/database.yml +0 -1
- data/spec/dummy/config/environment.rb +0 -1
- data/spec/dummy/config/environments/development.rb +0 -1
- data/spec/dummy/config/environments/production.rb +0 -1
- data/spec/dummy/config/environments/test.rb +0 -1
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -1
- data/spec/dummy/config/initializers/commontator.rb +0 -1
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -1
- data/spec/dummy/config/initializers/inflections.rb +0 -1
- data/spec/dummy/config/initializers/mime_types.rb +0 -1
- data/spec/dummy/config/initializers/secret_token.rb +0 -1
- data/spec/dummy/config/initializers/session_store.rb +0 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -1
- data/spec/dummy/config/routes.rb +0 -1
- data/spec/dummy/db/migrate/1_create_dummy_models.rb +0 -1
- data/spec/dummy/db/migrate/2_create_dummy_users.rb +0 -1
- data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb +0 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +6202 -0
- data/spec/dummy/public/404.html +0 -1
- data/spec/dummy/public/422.html +0 -1
- data/spec/dummy/public/500.html +0 -1
- data/spec/dummy/script/rails +0 -1
- data/spec/dummy/tmp/cache/assets/test/sprockets/72b63dddbc5c995f79af8e3c94904fd9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a473b3873e554893372a53d71f5e9879 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a77b1a9223d168112e1705c29220116f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/afa63eb365bdf4f42584b17ac9176b9d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d2244ccef8e05bb993f75715af0344cc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/decb63cac838a5314aa0c22a979f5ac9 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f721383d531f067d82b071e14aed7a92 +0 -0
- data/spec/lib/commontator/acts_as_commontable_spec.rb +0 -1
- data/spec/lib/commontator/acts_as_commontator_spec.rb +0 -1
- data/spec/lib/commontator/commontable_config_spec.rb +0 -1
- data/spec/lib/commontator/commontator_config_spec.rb +0 -1
- data/spec/lib/commontator/controller_includes_spec.rb +0 -1
- data/spec/lib/commontator/shared_helper_spec.rb +0 -1
- data/spec/lib/commontator_spec.rb +0 -1
- metadata +2 -2
@@ -2,18 +2,31 @@
|
|
2
2
|
# thread
|
3
3
|
# user
|
4
4
|
# per_page
|
5
|
-
%>
|
6
5
|
|
7
|
-
|
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>
|
6
|
+
hidden_class = @new_comment.nil? ? ' hidden' : '' %>
|
13
7
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
<div id="thread_<%= thread.id %>_reply" class="thread_reply">
|
9
|
+
<% if thread.is_closed? %>
|
10
|
+
<p><%= t 'commontator.thread.status.cannot_post' %></p>
|
11
|
+
<% elsif !user %>
|
12
|
+
<p><%= t 'commontator.require_login' %>.</p>
|
13
|
+
<% else %>
|
14
|
+
<div id="thread_<%= thread.id %>_new_comment_form_div" class="thread_new_comment_form<%=
|
15
|
+
hidden_class %>">
|
16
|
+
<% unless @new_comment.nil? %>
|
17
|
+
<%= render :partial => 'commontator/comments/form',
|
18
|
+
:locals => { :comment => @new_comment,
|
19
|
+
:thread => thread,
|
20
|
+
:per_page => per_page } %>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
19
23
|
|
24
|
+
<% if @new_comment.nil? %>
|
25
|
+
<div id="thread_<%= thread.id %>_new_comment_link_div" class="thread_new_comment_link">
|
26
|
+
<%= link_to t('commontator.comment.actions.new'),
|
27
|
+
commontator.new_thread_comment_path(thread, :per_page => per_page),
|
28
|
+
:remote => true %>
|
29
|
+
</div>
|
30
|
+
<% end %>
|
31
|
+
<% end %>
|
32
|
+
</div>
|
@@ -14,8 +14,8 @@
|
|
14
14
|
<% if can_subscribe %>
|
15
15
|
<span id="thread_<%= thread.id.to_s %>_subscription_span" class="thread_subscription">
|
16
16
|
<%= render :partial => 'commontator/subscriptions/link',
|
17
|
-
:locals => {:thread => thread,
|
18
|
-
|
17
|
+
:locals => { :thread => thread,
|
18
|
+
:user => user } %>
|
19
19
|
</span>
|
20
20
|
<% end %>
|
21
21
|
|
@@ -53,25 +53,25 @@
|
|
53
53
|
|
54
54
|
<% if thread.config.comment_order == :l %>
|
55
55
|
<%= render :partial => 'commontator/threads/reply',
|
56
|
-
:locals => {:thread => thread, :user => user, :per_page => per_page} %>
|
56
|
+
:locals => { :thread => thread, :user => user, :per_page => per_page } %>
|
57
57
|
<% end %>
|
58
58
|
|
59
59
|
<div id="thread_<%= thread.id.to_s %>_comment_list_div" class="thread_comment_list">
|
60
60
|
<% comments = show_all ? thread.ordered_comments(true) : thread.paginated_comments(page, per_page) %>
|
61
61
|
<%= render :partial => 'commontator/comments/list',
|
62
|
-
:locals => {:comments => comments,
|
63
|
-
|
62
|
+
:locals => { :comments => comments,
|
63
|
+
:user => user } %>
|
64
64
|
</div>
|
65
65
|
|
66
66
|
<% if thread.will_paginate? && !show_all %>
|
67
67
|
<div id="thread_<%= thread.id.to_s %>_pagination_div" class="thread_pagination">
|
68
68
|
<div id="thread_<%= thread.id.to_s %>_page_entries_info_div" class="thread_page_entries_info">
|
69
69
|
<%= page_entries_info comments,
|
70
|
-
:params => {:controller => 'commontator/threads',
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
70
|
+
:params => { :controller => 'commontator/threads',
|
71
|
+
:action => 'show',
|
72
|
+
:id => thread.id,
|
73
|
+
:page => page,
|
74
|
+
:per_page => per_page } %>.
|
75
75
|
</div>
|
76
76
|
|
77
77
|
<div id="thread_<%= thread.id.to_s %>_will_paginate_div" class="thread_will_paginate">
|
@@ -79,17 +79,16 @@
|
|
79
79
|
:renderer => Commontator::LinkRenderer,
|
80
80
|
:routes_proxy => commontator,
|
81
81
|
:remote => true,
|
82
|
-
:params => {:controller => 'commontator/threads',
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
82
|
+
:params => { :controller => 'commontator/threads',
|
83
|
+
:action => 'show',
|
84
|
+
:id => thread.id,
|
85
|
+
:page => page,
|
86
|
+
:per_page => per_page } %>
|
87
87
|
</div>
|
88
88
|
</div>
|
89
89
|
<% end %>
|
90
90
|
|
91
91
|
<% if thread.config.comment_order != :l %>
|
92
92
|
<%= render :partial => 'commontator/threads/reply',
|
93
|
-
:locals => {:thread => thread, :user => user, :per_page => per_page} %>
|
93
|
+
:locals => { :thread => thread, :user => user, :per_page => per_page } %>
|
94
94
|
<% end %>
|
95
|
-
|
@@ -11,9 +11,8 @@ $("#thread_<%= thread.id %>_div").html(
|
|
11
11
|
"<%= escape_javascript(
|
12
12
|
render :partial => 'commontator/threads/show',
|
13
13
|
:formats => [:html],
|
14
|
-
:locals => {:thread => thread,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
:locals => { :thread => thread,
|
15
|
+
:user => user,
|
16
|
+
:page => page,
|
17
|
+
:per_page => per_page,
|
18
|
+
:show_all => show_all }) %>");
|
@@ -1,9 +1,8 @@
|
|
1
1
|
<%= render :partial => 'show',
|
2
|
-
:locals => {:thread => @thread,
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
:locals => { :thread => @thread,
|
3
|
+
:user => @user,
|
4
|
+
:page => @commontator_page,
|
5
|
+
:per_page => @commontator_per_page,
|
6
|
+
:show_all => @show_all } %>
|
7
7
|
|
8
8
|
<%= javascript_proc %>
|
9
|
-
|
@@ -19,6 +19,7 @@ Commontator.configure do |config|
|
|
19
19
|
# Arguments: a view (ActionView::Base)
|
20
20
|
# Returns: a String that is appended to Commontator JS views
|
21
21
|
# Can be used, for example, to display/clear Rails error messages
|
22
|
+
# or to reapply JQuery UI styles after Ajax calls
|
22
23
|
# Objects visible in view templates can be accessed
|
23
24
|
# through the view object (for example, view.flash)
|
24
25
|
# However, the view does not include the main application's helpers
|
@@ -182,6 +183,17 @@ Commontator.configure do |config|
|
|
182
183
|
# Default: :e
|
183
184
|
config.comment_order = :e
|
184
185
|
|
186
|
+
# new_comment_style
|
187
|
+
# Type: Symbol
|
188
|
+
# How to display the "new comment" form
|
189
|
+
# Valid options:
|
190
|
+
# :t (always present in the thread's page)
|
191
|
+
# :l (link to the form; opens in the same page using JS)
|
192
|
+
# Not yet implemented:
|
193
|
+
# :n (link to the form; opens in a new window)
|
194
|
+
# Default: :l
|
195
|
+
config.new_comment_style = :l
|
196
|
+
|
185
197
|
# comments_per_page
|
186
198
|
# Type: Fixnum or nil
|
187
199
|
# Number of comments to display in each page
|
@@ -235,4 +247,3 @@ Commontator.configure do |config|
|
|
235
247
|
config.commontable_url_proc = lambda { |thread, app_routes|
|
236
248
|
app_routes.polymorphic_url(thread.commontable) }
|
237
249
|
end
|
238
|
-
|
data/config/routes.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
class InstallCommontator < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
create_table
|
4
|
-
t.string
|
5
|
-
t.integer
|
6
|
-
t.string
|
7
|
-
t.integer
|
8
|
-
t.integer
|
9
|
-
t.text
|
10
|
-
t.datetime
|
3
|
+
create_table :commontator_comments do |t|
|
4
|
+
t.string :creator_type
|
5
|
+
t.integer :creator_id
|
6
|
+
t.string :editor_type
|
7
|
+
t.integer :editor_id
|
8
|
+
t.integer :thread_id, :null => false
|
9
|
+
t.text :body, :null => false
|
10
|
+
t.datetime :deleted_at
|
11
11
|
|
12
12
|
t.integer :cached_votes_up, :default => 0
|
13
13
|
t.integer :cached_votes_down, :default => 0
|
@@ -15,34 +15,38 @@ class InstallCommontator < ActiveRecord::Migration
|
|
15
15
|
t.timestamps
|
16
16
|
end
|
17
17
|
|
18
|
-
add_index :commontator_comments, [:creator_id, :creator_type, :thread_id],
|
18
|
+
add_index :commontator_comments, [:creator_id, :creator_type, :thread_id],
|
19
|
+
:name => 'index_commontator_comments_on_c_id_and_c_type_and_t_id'
|
19
20
|
add_index :commontator_comments, [:thread_id, :created_at]
|
20
21
|
|
21
22
|
add_index :commontator_comments, :cached_votes_up
|
22
23
|
add_index :commontator_comments, :cached_votes_down
|
23
24
|
|
24
|
-
create_table
|
25
|
-
t.string
|
26
|
-
t.integer
|
27
|
-
t.integer
|
25
|
+
create_table :commontator_subscriptions do |t|
|
26
|
+
t.string :subscriber_type, :null => false
|
27
|
+
t.integer :subscriber_id, :null => false
|
28
|
+
t.integer :thread_id, :null => false
|
28
29
|
|
29
30
|
t.timestamps
|
30
31
|
end
|
31
32
|
|
32
|
-
add_index :commontator_subscriptions, [:subscriber_id, :subscriber_type, :thread_id],
|
33
|
+
add_index :commontator_subscriptions, [:subscriber_id, :subscriber_type, :thread_id],
|
34
|
+
:unique => true,
|
35
|
+
:name => 'index_commontator_subscriptions_on_s_id_and_s_type_and_t_id'
|
33
36
|
add_index :commontator_subscriptions, :thread_id
|
34
37
|
|
35
|
-
create_table
|
36
|
-
t.string
|
37
|
-
t.integer
|
38
|
-
t.datetime
|
39
|
-
t.string
|
40
|
-
t.integer
|
38
|
+
create_table :commontator_threads do |t|
|
39
|
+
t.string :commontable_type
|
40
|
+
t.integer :commontable_id
|
41
|
+
t.datetime :closed_at
|
42
|
+
t.string :closer_type
|
43
|
+
t.integer :closer_id
|
41
44
|
|
42
45
|
t.timestamps
|
43
46
|
end
|
44
47
|
|
45
|
-
add_index :commontator_threads, [:commontable_id, :commontable_type],
|
48
|
+
add_index :commontator_threads, [:commontable_id, :commontable_type],
|
49
|
+
:unique => true,
|
50
|
+
:name => 'index_commontator_threads_on_c_id_and_c_type'
|
46
51
|
end
|
47
52
|
end
|
48
|
-
|
data/lib/commontator.rb
CHANGED
@@ -29,6 +29,7 @@ module Commontator
|
|
29
29
|
:comment_voting,
|
30
30
|
:vote_count_proc,
|
31
31
|
:comment_order,
|
32
|
+
:new_comment_style,
|
32
33
|
:comments_per_page,
|
33
34
|
:thread_subscription,
|
34
35
|
:email_from_proc,
|
@@ -135,4 +136,3 @@ end
|
|
135
136
|
|
136
137
|
require 'commontator/acts_as_commontator'
|
137
138
|
require 'commontator/acts_as_commontable'
|
138
|
-
|
@@ -8,6 +8,14 @@ module Commontator
|
|
8
8
|
end
|
9
9
|
|
10
10
|
protected
|
11
|
+
|
12
|
+
def commontator_set_new_comment(thread, user)
|
13
|
+
return if thread.nil? || thread.config.new_comment_style != :t
|
14
|
+
new_comment = Comment.new
|
15
|
+
new_comment.thread = thread
|
16
|
+
new_comment.creator = user
|
17
|
+
@new_comment = new_comment if new_comment.can_be_created_by?(user)
|
18
|
+
end
|
11
19
|
|
12
20
|
def commontator_thread_show(commontable)
|
13
21
|
user = Commontator.current_user_proc.call(self)
|
@@ -17,6 +25,7 @@ module Commontator
|
|
17
25
|
@commontator_page = params[:page] || 1
|
18
26
|
@commontator_per_page = params[:per_page] || thread.config.comments_per_page
|
19
27
|
@commontator_thread_show = true
|
28
|
+
commontator_set_new_comment(thread, user)
|
20
29
|
end
|
21
30
|
end
|
22
31
|
end
|
data/lib/commontator/engine.rb
CHANGED
@@ -2,10 +2,11 @@ module Commontator
|
|
2
2
|
module SharedHelper
|
3
3
|
def commontator_thread(commontable)
|
4
4
|
user = Commontator.current_user_proc.call(self)
|
5
|
+
thread = commontable.thread
|
5
6
|
|
6
7
|
render(:partial => 'commontator/shared/thread',
|
7
|
-
:locals => {:thread =>
|
8
|
-
|
8
|
+
:locals => { :thread => thread,
|
9
|
+
:user => user }).html_safe
|
9
10
|
end
|
10
11
|
|
11
12
|
def commontator_gravatar_image_tag(user, border = 1, options = {})
|
@@ -22,4 +23,3 @@ module Commontator
|
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
25
|
-
|
data/lib/commontator/version.rb
CHANGED
@@ -546,7 +546,7 @@ module Commontator
|
|
546
546
|
@user.can_read = true
|
547
547
|
sign_in @user
|
548
548
|
|
549
|
-
attributes = {:body => 'Something else'}
|
549
|
+
attributes = { :body => 'Something else' }
|
550
550
|
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
551
551
|
assigns(:comment).errors.must_be_empty
|
552
552
|
|
@@ -571,7 +571,7 @@ module Commontator
|
|
571
571
|
@user.can_read = true
|
572
572
|
sign_in @user
|
573
573
|
|
574
|
-
attributes = {:body => 'Something else'}
|
574
|
+
attributes = { :body => 'Something else' }
|
575
575
|
post :create, :thread_id => @thread.id, :comment => attributes, :use_route => :commontator
|
576
576
|
assigns(:comment).errors.must_be_empty
|
577
577
|
|
@@ -580,4 +580,3 @@ module Commontator
|
|
580
580
|
end
|
581
581
|
end
|
582
582
|
end
|
583
|
-
|
data/spec/dummy/README.md
CHANGED
data/spec/dummy/Rakefile
CHANGED