commontator 4.4.1 → 4.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/images/commontator/downvote.png +0 -0
- data/app/assets/images/commontator/downvote_active.png +0 -0
- data/app/assets/images/commontator/downvote_disabled.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_active.png +0 -0
- data/app/assets/images/commontator/upvote_disabled.png +0 -0
- data/app/assets/images/commontator/upvote_hover.png +0 -0
- data/app/assets/stylesheets/commontator/comments.css +17 -14
- data/app/assets/stylesheets/commontator/threads.css +48 -0
- data/app/models/commontator/thread.rb +12 -0
- data/app/views/commontator/comments/_votes.html.erb +8 -6
- data/app/views/commontator/shared/_thread.html.erb +9 -4
- data/app/views/commontator/threads/_reply.html.erb +17 -0
- data/app/views/commontator/threads/_show.html.erb +22 -17
- data/app/views/commontator/threads/show.js.erb +3 -1
- data/config/initializers/commontator.rb +31 -6
- data/lib/commontator.rb +3 -1
- data/lib/commontator/controller_includes.rb +3 -0
- data/lib/commontator/remote_link_renderer.rb +10 -0
- data/lib/commontator/shared_helper.rb +1 -1
- data/lib/commontator/version.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +4120 -0
- 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
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a273f377e74d4449ebd729e1865c6dcbc9e4c0c5
|
4
|
+
data.tar.gz: c8c70279649288314df84db409d04835dee64d42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c73e175a971bd4d7618a42681d0559f612668fa8ea1e7e3ec6f84eb786420e990ef8f47b42528dbf0c64e21bff66958829ea68972c2739483d798c3583358eed
|
7
|
+
data.tar.gz: 52ba09e55c25a169190e25d85b60279f26f7febe15fa9253ac06d41e6699a4af9f59e7ea3fef0a2a01509f3bf0c13c332221dbc4df8a26afd1bad57e68ddb246
|
data/README.md
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -9,14 +9,14 @@
|
|
9
9
|
margin-top: 15px;
|
10
10
|
margin-bottom: 15px;
|
11
11
|
|
12
|
-
padding-top:
|
13
|
-
padding-bottom:
|
14
|
-
padding-left:
|
15
|
-
padding-right:
|
12
|
+
padding-top: 5px;
|
13
|
+
padding-bottom: 5px;
|
14
|
+
padding-left: 10px;
|
15
|
+
padding-right: 10px;
|
16
16
|
|
17
17
|
color: #000;
|
18
|
-
border-color: #
|
19
|
-
background-color: #
|
18
|
+
border-color: #DDD;
|
19
|
+
background-color: #FFF;
|
20
20
|
|
21
21
|
clear: both;
|
22
22
|
}
|
@@ -59,7 +59,7 @@
|
|
59
59
|
}
|
60
60
|
|
61
61
|
.comment_timestamp {
|
62
|
-
color: #
|
62
|
+
color: #666;
|
63
63
|
}
|
64
64
|
|
65
65
|
.comment_votes {
|
@@ -82,19 +82,22 @@
|
|
82
82
|
margin: 0px;
|
83
83
|
}
|
84
84
|
|
85
|
-
.comment_vote_count {
|
86
|
-
margin-top: 7px;
|
87
|
-
margin-bottom: 7px;
|
88
|
-
}
|
89
|
-
|
90
85
|
.comment_upvote {
|
91
86
|
display: block;
|
92
|
-
height:
|
87
|
+
height: 18px;
|
88
|
+
margin-top: 7px;
|
89
|
+
margin-bottom: 7px;
|
90
|
+
margin-left: 5px;
|
91
|
+
margin-right: 5px;
|
93
92
|
}
|
94
93
|
|
95
94
|
.comment_downvote {
|
96
95
|
display: block;
|
97
|
-
height:
|
96
|
+
height: 18px;
|
97
|
+
margin-top: 7px;
|
98
|
+
margin-bottom: 7px;
|
99
|
+
margin-left: 5px;
|
100
|
+
margin-right: 5px;
|
98
101
|
}
|
99
102
|
|
100
103
|
.comment_like {
|
@@ -10,8 +10,56 @@
|
|
10
10
|
font-size: 16px;
|
11
11
|
font-weight: bold;
|
12
12
|
font-style: normal;
|
13
|
+
margin-top: 5px;
|
14
|
+
margin-bottom: 5px;
|
15
|
+
display: block;
|
13
16
|
}
|
14
17
|
|
15
18
|
.thread_new_comment {
|
16
19
|
display: none;
|
20
|
+
}
|
21
|
+
|
22
|
+
.thread_new_comment_link {
|
23
|
+
display: block;
|
24
|
+
}
|
25
|
+
|
26
|
+
/* Modified from:
|
27
|
+
http://www.strangerstudios.com/sandbox/pagination/diggstyle.php */
|
28
|
+
.thread_pagination {
|
29
|
+
padding: 3px;
|
30
|
+
margin: 3px;
|
31
|
+
}
|
32
|
+
|
33
|
+
.thread_pagination a {
|
34
|
+
padding: 2px 5px 2px 5px;
|
35
|
+
margin: 2px;
|
36
|
+
border: 1px solid #999;
|
37
|
+
|
38
|
+
text-decoration: none;
|
39
|
+
color: #666;
|
40
|
+
}
|
41
|
+
|
42
|
+
.thread_pagination a:hover,
|
43
|
+
.thread_pagination a:active {
|
44
|
+
border: 1px solid #555;
|
45
|
+
|
46
|
+
color: #000;
|
47
|
+
}
|
48
|
+
|
49
|
+
.thread_pagination em {
|
50
|
+
padding: 2px 5px 2px 5px;
|
51
|
+
margin: 2px;
|
52
|
+
border: 1px solid #555;
|
53
|
+
|
54
|
+
font-weight: bold;
|
55
|
+
background-color: #555;
|
56
|
+
color: #FFF;
|
57
|
+
}
|
58
|
+
|
59
|
+
.thread_pagination span {
|
60
|
+
padding: 2px 5px 2px 5px;
|
61
|
+
margin: 2px;
|
62
|
+
border: 1px solid #EEE;
|
63
|
+
|
64
|
+
color: #DDD;
|
17
65
|
}
|
@@ -15,6 +15,12 @@ module Commontator
|
|
15
15
|
commontable.try(:commontable_config) || Commontator
|
16
16
|
end
|
17
17
|
|
18
|
+
def will_paginate?
|
19
|
+
return false if config.comments_per_page.nil? || !comments.respond_to?(:paginate)
|
20
|
+
require 'commontator/remote_link_renderer'
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
18
24
|
def ordered_comments
|
19
25
|
case config.comment_order.to_sym
|
20
26
|
when :l then comments.order('id DESC')
|
@@ -24,6 +30,12 @@ module Commontator
|
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
33
|
+
def paginated_comments(page, per_page)
|
34
|
+
oc = ordered_comments
|
35
|
+
return oc unless will_paginate?
|
36
|
+
oc.paginate(:page => page, :per_page => per_page)
|
37
|
+
end
|
38
|
+
|
27
39
|
def is_closed?
|
28
40
|
!closed_at.blank?
|
29
41
|
end
|
@@ -24,12 +24,13 @@
|
|
24
24
|
<%= form_tag commontator.unvote_comment_path(comment),
|
25
25
|
:method => :put,
|
26
26
|
:remote => true do %>
|
27
|
-
<%= image_submit_tag "commontator/
|
27
|
+
<%= image_submit_tag "commontator/upvote_active.png",
|
28
28
|
:onmouseover => "this.src='/assets/commontator/upvote.png'",
|
29
|
-
:onmouseout => "this.src='/assets/commontator/
|
29
|
+
:onmouseout => "this.src='/assets/commontator/upvote_active.png'"
|
30
|
+
%>
|
30
31
|
<% end %>
|
31
32
|
<% else %>
|
32
|
-
<%= image_tag "commontator/
|
33
|
+
<%= image_tag "commontator/upvote_disabled.png" %>
|
33
34
|
<% end %>
|
34
35
|
</span>
|
35
36
|
<% end %>
|
@@ -54,12 +55,13 @@
|
|
54
55
|
<%= form_tag commontator.unvote_comment_path(comment),
|
55
56
|
:method => :put,
|
56
57
|
:remote => true do %>
|
57
|
-
<%= image_submit_tag "commontator/
|
58
|
+
<%= image_submit_tag "commontator/downvote_active.png",
|
58
59
|
:onmouseover => "this.src='/assets/commontator/downvote.png'",
|
59
|
-
:onmouseout => "this.src='/assets/commontator/
|
60
|
+
:onmouseout => "this.src='/assets/commontator/downvote_active.png'"
|
61
|
+
%>
|
60
62
|
<% end %>
|
61
63
|
<% else %>
|
62
|
-
<%= image_tag "commontator/
|
64
|
+
<%= image_tag "commontator/downvote_disabled.png" %>
|
63
65
|
<% end %>
|
64
66
|
</span>
|
65
67
|
<% end %>
|
@@ -10,11 +10,16 @@
|
|
10
10
|
|
11
11
|
<div id="thread_<%= thread.id %>_div" class="thread" style="display: none;">
|
12
12
|
<% if @commontator_thread_show %>
|
13
|
-
<%= render :partial => 'commontator/threads/show',
|
14
|
-
|
13
|
+
<%= render :partial => 'commontator/threads/show',
|
14
|
+
:locals => {:thread => thread,
|
15
|
+
:user => user,
|
16
|
+
:page => @commontator_page,
|
17
|
+
:per_page => @commontator_per_page} %>
|
15
18
|
<% else %>
|
16
|
-
<%= link_to "#{t 'commontator.thread.actions.show'} (#{subscription ?
|
17
|
-
|
19
|
+
<%= link_to "#{t 'commontator.thread.actions.show'} (#{subscription ?
|
20
|
+
(subscription.unread.to_s + '/' + thread.comments.count.to_s) :
|
21
|
+
thread.comments.count.to_s})", commontator.thread_path(thread),
|
22
|
+
:remote => true %>
|
18
23
|
<% end %>
|
19
24
|
</div>
|
20
25
|
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% # Clients of this partial must supply the following variables:
|
2
|
+
# thread
|
3
|
+
# user
|
4
|
+
%>
|
5
|
+
|
6
|
+
<% if thread.is_closed? %>
|
7
|
+
<p><%= t 'commontator.thread.status.closed_by' %></p>
|
8
|
+
<% elsif !user %>
|
9
|
+
<p><%= t 'commontator.require_login' %>.</p>
|
10
|
+
<% else %>
|
11
|
+
<div id="thread_<%= thread.id %>_new_comment_div" class="thread_new_comment"></div>
|
12
|
+
|
13
|
+
<span id="thread_<%= thread.id %>_new_comment_link_span" class="thread_new_comment_link">
|
14
|
+
<%= link_to t('commontator.comment.actions.new'),
|
15
|
+
commontator.new_thread_comment_path(thread), :remote => true %>
|
16
|
+
</span>
|
17
|
+
<% end %>
|
@@ -1,16 +1,13 @@
|
|
1
1
|
<% # Clients of this partial must supply the following variables:
|
2
2
|
# thread
|
3
3
|
# user
|
4
|
+
# page
|
5
|
+
# per_page
|
4
6
|
%>
|
5
7
|
|
6
8
|
<% can_subscribe = thread.can_subscribe?(user) %>
|
7
9
|
<% can_edit = thread.can_be_edited_by?(user) %>
|
8
10
|
|
9
|
-
<span id="thread_<%= thread.id.to_s %>_header_span" class="thread_header">
|
10
|
-
<%= t "commontator.thread.status.#{thread.is_closed? ? 'closed' : 'open'}",
|
11
|
-
:closer_name => thread.closer.try(:commontator_name) %>
|
12
|
-
</span>
|
13
|
-
|
14
11
|
<span id="thread_<%= thread.id.to_s %>_actions_span" class="thread_actions">
|
15
12
|
<% if can_subscribe %>
|
16
13
|
<span id="thread_<%= thread.id.to_s %>_subscription_span" class="thread_subscription">
|
@@ -35,21 +32,29 @@
|
|
35
32
|
<% end %>
|
36
33
|
</span>
|
37
34
|
|
35
|
+
<span id="thread_<%= thread.id.to_s %>_header_span" class="thread_header">
|
36
|
+
<%= t "commontator.thread.status.#{thread.is_closed? ? 'closed' : 'open'}",
|
37
|
+
:closer_name => thread.closer.try(:commontator_name) %>
|
38
|
+
</span>
|
39
|
+
|
40
|
+
<% if thread.config.comment_order == :l %>
|
41
|
+
<%= render :partial => 'reply', :locals => {:thread => thread, :user => user} %>
|
42
|
+
<% end %>
|
43
|
+
|
38
44
|
<div id="thread_<%= thread.id.to_s %>_comment_list_div" class="thread_comment_list">
|
45
|
+
<% comments = thread.paginated_comments(page, per_page) %>
|
39
46
|
<%= render :partial => 'commontator/comments/list',
|
40
|
-
:locals => {:comments =>
|
47
|
+
:locals => {:comments => comments,
|
41
48
|
:user => user} %>
|
42
49
|
</div>
|
43
50
|
|
44
|
-
<% if thread.
|
45
|
-
<
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
commontator.new_thread_comment_path(thread), :remote => true %>
|
54
|
-
</span>
|
51
|
+
<% if thread.will_paginate? %>
|
52
|
+
<div id="thread_<%= thread.id.to_s %>_pagination_div" class="thread_pagination">
|
53
|
+
<%= will_paginate comments,
|
54
|
+
:renderer => thread.config.wp_link_renderer_proc.call(thread) %>
|
55
|
+
</div>
|
56
|
+
<% end %>
|
57
|
+
|
58
|
+
<% if thread.config.comment_order != :l %>
|
59
|
+
<%= render :partial => 'reply', :locals => {:thread => thread, :user => user} %>
|
55
60
|
<% end %>
|
@@ -2,6 +2,8 @@ $("#thread_<%= @thread.id %>_div").html(
|
|
2
2
|
"<%= escape_javascript(
|
3
3
|
render :partial => 'show',
|
4
4
|
:locals => {:thread => @thread,
|
5
|
-
:user => @user
|
5
|
+
:user => @user,
|
6
|
+
:page => @commontator_page,
|
7
|
+
:per_page => @commontator_per_page}) %>");
|
6
8
|
|
7
9
|
<%= javascript_proc %>
|
@@ -19,7 +19,7 @@ Commontator.configure do |config|
|
|
19
19
|
# However, the view_context does not include the main application's helpers
|
20
20
|
# Default: lambda { |view_context| '$("#error_explanation").remove();' }
|
21
21
|
config.javascript_proc = lambda { |view_context|
|
22
|
-
|
22
|
+
'$("#error_explanation").remove();' }
|
23
23
|
|
24
24
|
|
25
25
|
|
@@ -40,8 +40,8 @@ Commontator.configure do |config|
|
|
40
40
|
# view_context.commontator_gravatar_image_tag(
|
41
41
|
# user, 1, :s => 60, :d => 'mm') }
|
42
42
|
config.user_avatar_proc = lambda { |user, view_context|
|
43
|
-
|
44
|
-
|
43
|
+
view_context.commontator_gravatar_image_tag(
|
44
|
+
user, 1, :s => 60, :d => 'mm') }
|
45
45
|
|
46
46
|
# Proc called with a user and a mailer object as arguments
|
47
47
|
# If the mailer argument is nil, the email is for internal use only and
|
@@ -65,7 +65,7 @@ Commontator.configure do |config|
|
|
65
65
|
# Thread/Commontable (acts_as_commontable) Configuration
|
66
66
|
|
67
67
|
# Proc called with a mailer object as argument
|
68
|
-
# Returns the address emails are sent
|
68
|
+
# Returns the address emails are sent "from"
|
69
69
|
# Important: Change this to at least match your domain name
|
70
70
|
# Default: lambda { |mailer| 'no-reply@example.com' }
|
71
71
|
config.email_from_proc = lambda { |mailer| 'no-reply@example.com' }
|
@@ -112,7 +112,7 @@ Commontator.configure do |config|
|
|
112
112
|
# Returns the text to be displayed in between the voting buttons
|
113
113
|
# Default: lambda { |comment_voting, pos, neg| "%+d" % (pos - neg) }
|
114
114
|
config.voting_text_proc = lambda { |comment_voting, pos, neg|
|
115
|
-
|
115
|
+
"%+d" % (pos - neg) }
|
116
116
|
|
117
117
|
# What order to use for comments
|
118
118
|
# Valid options:
|
@@ -120,9 +120,33 @@ Commontator.configure do |config|
|
|
120
120
|
# :l (latest comment first)
|
121
121
|
# :ve (highest voted first; earliest first if tied)
|
122
122
|
# :vl (highest voted first; latest first if tied)
|
123
|
+
# Notes:
|
124
|
+
# :e is usually used in forums (discussions)
|
125
|
+
# :l is usually used in blogs (opinions)
|
126
|
+
# :ve and :vl are usually used where it makes sense to rate comments
|
127
|
+
# based on usefulness (q&a, reviews, guides, etc.)
|
128
|
+
# If :l is selected, the "reply to thread" form will appear before the comments
|
129
|
+
# Otherwise, it will appear after the comments
|
123
130
|
# Default: :e
|
124
131
|
config.comment_order = :e
|
125
132
|
|
133
|
+
# Number of comments to display in each page
|
134
|
+
# Set to nil to disable pagination
|
135
|
+
# Any other value requires the will_paginate gem
|
136
|
+
# Default: nil (no pagination)
|
137
|
+
config.comments_per_page = nil
|
138
|
+
|
139
|
+
# Proc called with a thread as argument
|
140
|
+
# Returns a LinkRenderer to be used with will_paginate for that thread,
|
141
|
+
# assuming pagination is enabled
|
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
|
+
|
126
150
|
# Whether users can edit their own comments
|
127
151
|
# Valid options:
|
128
152
|
# :a (always)
|
@@ -166,7 +190,8 @@ Commontator.configure do |config|
|
|
166
190
|
"#{commontable.class.name} ##{commontable.id}" }
|
167
191
|
|
168
192
|
# Proc called with main_app and a commontable object as arguments
|
169
|
-
# Return the url that contains the commontable's thread
|
193
|
+
# Return the url that contains the commontable's thread
|
194
|
+
# This usually is the commontable's "show" page
|
170
195
|
# The main application's routes can be accessed through the main_app object
|
171
196
|
# Default: lambda { |commontable, main_app|
|
172
197
|
# main_app.polymorphic_url(commontable) }
|
data/lib/commontator.rb
CHANGED
@@ -27,6 +27,8 @@ module Commontator
|
|
27
27
|
:comment_voting,
|
28
28
|
:voting_text_proc,
|
29
29
|
:comment_order,
|
30
|
+
:comments_per_page,
|
31
|
+
:wp_link_renderer_proc,
|
30
32
|
:comment_editing,
|
31
33
|
:comment_deletion,
|
32
34
|
:moderators_can_edit_comments,
|
@@ -96,4 +98,4 @@ module Commontator
|
|
96
98
|
end
|
97
99
|
|
98
100
|
require 'commontator/acts_as_commontator'
|
99
|
-
require 'commontator/acts_as_commontable'
|
101
|
+
require 'commontator/acts_as_commontable'
|
@@ -14,6 +14,9 @@ module Commontator
|
|
14
14
|
thread = commontable.thread
|
15
15
|
raise SecurityTransgression unless thread.can_be_read_by?(user)
|
16
16
|
thread.mark_as_read_for(user)
|
17
|
+
@commontator_page = params[:page] || 1
|
18
|
+
@commontator_per_page = params[:per_page] ||\
|
19
|
+
thread.config.comments_per_page
|
17
20
|
@commontator_thread_show = true
|
18
21
|
end
|
19
22
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'will_paginate/view_helpers/action_view'
|
2
|
+
|
3
|
+
module Commontator
|
4
|
+
class RemoteLinkRenderer < WillPaginate::ActionView::LinkRenderer
|
5
|
+
def link(text, target, attributes = {})
|
6
|
+
attributes = attributes.merge('data-remote' => true)
|
7
|
+
super(text, target, attributes)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|