commontator 4.5.4 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/MIT-LICENSE +2 -1
- data/README.md +31 -34
- data/Rakefile +3 -2
- data/app/assets/stylesheets/commontator/application.css +1 -0
- data/app/assets/stylesheets/commontator/comments.css +1 -0
- data/app/assets/stylesheets/commontator/threads.css +13 -7
- data/{spec/dummy/tmp/cache/assets/test/sprockets/a473b3873e554893372a53d71f5e9879 → app/assets/stylesheets/commontator/threads.css~} +0 -0
- data/app/controllers/commontator/application_controller.rb +14 -14
- data/app/controllers/commontator/application_controller.rb~ +35 -0
- data/app/controllers/commontator/comments_controller.rb +8 -7
- data/app/controllers/commontator/comments_controller.rb~ +153 -0
- data/app/controllers/commontator/subscriptions_controller.rb +1 -0
- data/app/controllers/commontator/threads_controller.rb +7 -2
- data/app/helpers/commontator/application_helper.rb +1 -0
- data/app/mailers/commontator/subscriptions_mailer.rb +8 -10
- data/app/mailers/commontator/subscriptions_mailer.rb~ +44 -0
- data/app/models/commontator/comment.rb +14 -13
- data/app/models/commontator/comment.rb~ +119 -0
- data/app/models/commontator/subscription.rb +8 -4
- data/app/models/commontator/thread.rb +64 -43
- data/app/models/commontator/thread.rb~ +159 -0
- data/app/views/commontator/comments/_actions.html.erb +1 -0
- data/app/views/commontator/comments/_body.html.erb +2 -1
- data/app/views/commontator/comments/_form.html.erb +5 -1
- data/app/views/commontator/comments/_form.html.erb~ +39 -0
- data/app/views/commontator/comments/_list.html.erb +1 -1
- data/app/views/commontator/comments/_show.html.erb +5 -3
- data/app/views/commontator/comments/_show.html.erb~ +49 -0
- data/app/views/commontator/comments/_votes.html.erb +2 -1
- data/app/views/commontator/comments/_votes.html.erb~ +69 -0
- data/app/views/commontator/comments/cancel.js.erb +1 -0
- data/app/views/commontator/comments/create.js.erb +6 -4
- data/app/views/commontator/comments/create.js.erb~ +14 -0
- data/app/views/commontator/comments/delete.js.erb +1 -0
- data/app/views/commontator/comments/edit.js.erb +1 -0
- data/app/views/commontator/comments/new.js.erb +3 -1
- data/app/views/commontator/comments/new.js.erb~ +13 -0
- data/app/views/commontator/comments/update.js.erb +1 -0
- data/app/views/commontator/comments/vote.js.erb +1 -0
- data/app/views/commontator/shared/_thread.html.erb +4 -5
- data/app/views/commontator/subscriptions/_link.html.erb +2 -1
- data/app/views/commontator/subscriptions/_link.html.erb~ +16 -0
- data/app/views/commontator/subscriptions/subscribe.js.erb +1 -0
- data/app/views/commontator/subscriptions_mailer/comment_created.html.erb +1 -0
- data/app/views/commontator/threads/_reply.html.erb +4 -2
- data/app/views/commontator/threads/_reply.html.erb~ +19 -0
- data/app/views/commontator/threads/_show.html.erb +44 -9
- data/app/views/commontator/threads/_show.html.erb~ +95 -0
- data/app/views/commontator/threads/_show.js.erb +19 -0
- data/app/views/commontator/threads/show.js.erb +4 -4
- data/config/initializers/commontator.rb +169 -132
- data/config/initializers/commontator.rb~ +238 -0
- data/config/locales/commontator/en.yml +12 -3
- data/config/locales/commontator/en.yml~ +104 -0
- data/config/routes.rb +1 -0
- data/db/migrate/0_install_commontator.rb +9 -11
- data/db/migrate/0_install_commontator.rb~ +54 -0
- data/lib/commontator.rb +57 -16
- data/lib/commontator.rb~ +142 -0
- data/lib/commontator/acts_as_commontable.rb +12 -14
- data/lib/commontator/acts_as_commontator.rb +1 -16
- data/lib/commontator/commontable_config.rb +1 -0
- data/lib/commontator/commontator_config.rb +1 -0
- data/lib/commontator/controller_includes.rb +3 -3
- data/lib/commontator/engine.rb +1 -0
- data/lib/commontator/link_renderer.rb +29 -0
- data/lib/commontator/security_transgression.rb +1 -0
- data/lib/commontator/shared_helper.rb +7 -5
- data/lib/commontator/version.rb +2 -1
- data/lib/tasks/commontator_tasks.rake +1 -0
- data/spec/app/controllers/commontator/comments_controller_spec.rb +12 -11
- data/spec/app/controllers/commontator/subscriptions_controller_spec.rb +2 -1
- data/spec/app/controllers/commontator/threads_controller_spec.rb +2 -1
- data/spec/app/helpers/commontator/application_helper_spec.rb +2 -1
- data/spec/app/mailers/commontator/subscriptions_mailer_spec.rb +2 -1
- data/spec/app/models/commontator/comment_spec.rb +18 -11
- data/spec/app/models/commontator/comment_spec.rb~ +74 -0
- data/spec/app/models/commontator/subscription_spec.rb +18 -8
- data/spec/app/models/commontator/thread_spec.rb +28 -42
- data/spec/dummy/README.md +1 -0
- data/spec/dummy/Rakefile +1 -0
- data/spec/dummy/app/assets/javascripts/application.js +1 -0
- data/spec/dummy/app/assets/stylesheets/application.css +1 -0
- data/spec/dummy/app/controllers/application_controller.rb +1 -0
- data/spec/dummy/app/controllers/dummy_models_controller.rb +1 -0
- data/spec/dummy/app/helpers/application_helper.rb +1 -0
- data/spec/dummy/app/models/dummy_model.rb +1 -0
- data/spec/dummy/app/models/dummy_user.rb +7 -2
- data/spec/dummy/app/models/dummy_user.rb~ +16 -0
- data/spec/dummy/app/views/dummy_model/show.html.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +1 -0
- data/spec/dummy/config.ru +1 -0
- data/spec/dummy/config/boot.rb +1 -0
- data/spec/dummy/config/database.yml +1 -0
- data/spec/dummy/config/environment.rb +1 -0
- data/spec/dummy/config/environments/development.rb +1 -0
- data/spec/dummy/config/environments/production.rb +1 -0
- data/spec/dummy/config/environments/test.rb +1 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +1 -0
- data/spec/dummy/config/initializers/commontator.rb +6 -1
- data/spec/dummy/config/initializers/commontator.rb~ +15 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +1 -0
- data/spec/dummy/config/initializers/inflections.rb +1 -0
- data/spec/dummy/config/initializers/mime_types.rb +1 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -0
- data/spec/dummy/config/initializers/session_store.rb +1 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -0
- data/spec/dummy/config/routes.rb +1 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/1_create_dummy_models.rb +1 -0
- data/spec/dummy/db/migrate/2_create_dummy_users.rb +1 -0
- data/spec/dummy/db/migrate/3_acts_as_votable_migration.rb +1 -0
- data/spec/dummy/db/schema.rb +10 -13
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/404.html +1 -0
- data/spec/dummy/public/422.html +1 -0
- data/spec/dummy/public/500.html +1 -0
- data/spec/dummy/script/rails +1 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{72b63dddbc5c995f79af8e3c94904fd9 → 02d4b791eb831cf2057bf4703a1218d1} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{a77b1a9223d168112e1705c29220116f → 0f196a1a50363b0a076ec6e1ee5417f6} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a3fb9025f90ff05a6fd4afc7ded2692c +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a41c8be5379abec3c0d0d98e2f0d5609 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/c69ee3cc5796188d873574179290a6ef +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{f721383d531f067d82b071e14aed7a92 → e1f674c11941d62aac1764ef3a7134e4} +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/{d2244ccef8e05bb993f75715af0344cc → e85565206c3e5fdf9dfeb367c85557b1} +0 -0
- data/spec/lib/commontator/acts_as_commontable_spec.rb +3 -2
- data/spec/lib/commontator/acts_as_commontator_spec.rb +2 -5
- data/spec/lib/commontator/commontable_config_spec.rb +8 -5
- data/spec/lib/commontator/commontator_config_spec.rb +2 -1
- data/spec/lib/commontator/controller_includes_spec.rb +2 -1
- data/spec/lib/commontator/shared_helper_spec.rb +2 -1
- data/spec/lib/commontator_spec.rb +2 -1
- data/spec/{test_helper.rb → spec_helper.rb} +0 -0
- metadata +154 -135
- data/lib/commontator/remote_link_renderer.rb +0 -10
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/log/development.log +0 -36
- data/spec/dummy/log/test.log +0 -22683
- data/spec/dummy/tmp/cache/assets/test/sprockets/afa63eb365bdf4f42584b17ac9176b9d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/decb63cac838a5314aa0c22a979f5ac9 +0 -0
@@ -0,0 +1,159 @@
|
|
1
|
+
module Commontator
|
2
|
+
class Thread < ActiveRecord::Base
|
3
|
+
belongs_to :closer, :polymorphic => true
|
4
|
+
belongs_to :commontable, :polymorphic => true
|
5
|
+
|
6
|
+
has_many :comments, :dependent => :destroy
|
7
|
+
has_many :subscriptions, :dependent => :destroy
|
8
|
+
|
9
|
+
validates_presence_of :commontable, :unless => :is_closed?
|
10
|
+
validates_uniqueness_of :commontable_id,
|
11
|
+
:scope => :commontable_type,
|
12
|
+
:allow_nil => true
|
13
|
+
|
14
|
+
def config
|
15
|
+
@config ||= commontable.try(:commontable_config) || Commontator
|
16
|
+
end
|
17
|
+
|
18
|
+
def will_paginate?
|
19
|
+
return false if config.comments_per_page.nil? || !comments.respond_to?(:paginate)
|
20
|
+
require 'commontator/link_renderer'
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
def is_filtered?
|
25
|
+
will_paginate? || config.comment_filter
|
26
|
+
end
|
27
|
+
|
28
|
+
def filtered_comments
|
29
|
+
cf = config.comment_filter
|
30
|
+
return comments if cf.nil?
|
31
|
+
comments.where(cf)
|
32
|
+
end
|
33
|
+
|
34
|
+
def ordered_comments(override = false)
|
35
|
+
vc = override ? comments : filtered_comments
|
36
|
+
case config.comment_order.to_sym
|
37
|
+
when :l then vc.order('id DESC')
|
38
|
+
when :ve then vc.order('cached_votes_down - cached_votes_up')
|
39
|
+
when :vl then vc.order('cached_votes_down - cached_votes_up', 'id DESC')
|
40
|
+
else vc
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def paginated_comments(page = 1, per_page = config.comments_per_page)
|
45
|
+
oc = ordered_comments
|
46
|
+
return oc unless will_paginate?
|
47
|
+
oc.paginate(:page => page, :per_page => per_page)
|
48
|
+
end
|
49
|
+
|
50
|
+
def new_comment_page(per_page = config.comments_per_page)
|
51
|
+
return 1 if per_page.nil? || per_page.to_i <= 0
|
52
|
+
comment_index = \
|
53
|
+
case config.comment_order.to_sym
|
54
|
+
when :l
|
55
|
+
1 # First comment
|
56
|
+
when :ve
|
57
|
+
comment_arel = Comment.arel_table
|
58
|
+
# Last comment with rating = 0
|
59
|
+
filtered_comments.where((comment_arel[:cached_votes_up] - comment_arel[:cached_votes_down]).gteq 0).count
|
60
|
+
when :vl
|
61
|
+
comment_arel = Comment.arel_table
|
62
|
+
# First comment with rating = 0
|
63
|
+
filtered_comments.where((comment_arel[:cached_votes_up] - comment_arel[:cached_votes_down]).gt 0).count + 1
|
64
|
+
else
|
65
|
+
filtered_comments.count # Last comment
|
66
|
+
end
|
67
|
+
(comment_index.to_f/per_page.to_i).ceil
|
68
|
+
end
|
69
|
+
|
70
|
+
def is_closed?
|
71
|
+
!closed_at.blank?
|
72
|
+
end
|
73
|
+
|
74
|
+
def close(user = nil)
|
75
|
+
return false if is_closed?
|
76
|
+
self.closed_at = Time.now
|
77
|
+
self.closer = user
|
78
|
+
save
|
79
|
+
end
|
80
|
+
|
81
|
+
def reopen
|
82
|
+
return false unless is_closed? && !commontable.nil?
|
83
|
+
self.closed_at = nil
|
84
|
+
save
|
85
|
+
end
|
86
|
+
|
87
|
+
def subscribers
|
88
|
+
subscriptions.collect{|s| s.subscriber}
|
89
|
+
end
|
90
|
+
|
91
|
+
def subscription_for(subscriber)
|
92
|
+
return nil if !subscriber || !subscriber.is_commontator
|
93
|
+
subscriber.subscriptions.where(:thread_id => self.id).first
|
94
|
+
end
|
95
|
+
|
96
|
+
def subscribe(subscriber)
|
97
|
+
return false unless subscriber.is_commontator && !subscription_for(subscriber)
|
98
|
+
subscription = Subscription.new
|
99
|
+
subscription.subscriber = subscriber
|
100
|
+
subscription.thread = self
|
101
|
+
subscription.save
|
102
|
+
end
|
103
|
+
|
104
|
+
def unsubscribe(subscriber)
|
105
|
+
subscription = subscription_for(subscriber)
|
106
|
+
return false unless subscription
|
107
|
+
subscription.destroy
|
108
|
+
end
|
109
|
+
|
110
|
+
def mark_as_read_for(subscriber)
|
111
|
+
subscription = subscription_for(subscriber)
|
112
|
+
return false unless subscription
|
113
|
+
subscription.touch
|
114
|
+
end
|
115
|
+
|
116
|
+
# Creates a new empty thread and assigns it to the commontable
|
117
|
+
# The old thread is kept in the database for archival purposes
|
118
|
+
def clear
|
119
|
+
return if commontable.blank? || !is_closed?
|
120
|
+
new_thread = Thread.new
|
121
|
+
new_thread.commontable = commontable
|
122
|
+
|
123
|
+
with_lock do
|
124
|
+
self.commontable = nil
|
125
|
+
save!
|
126
|
+
new_thread.save!
|
127
|
+
subscriptions.each do |s|
|
128
|
+
s.thread = new_thread
|
129
|
+
s.save!
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
##################
|
135
|
+
# Access Control #
|
136
|
+
##################
|
137
|
+
|
138
|
+
# Reader capabilities (user can be nil or false)
|
139
|
+
def can_be_read_by?(user)
|
140
|
+
return true if can_be_edited_by?(user)
|
141
|
+
!commontable.nil? &&\
|
142
|
+
config.thread_read_proc.call(self, user)
|
143
|
+
end
|
144
|
+
|
145
|
+
# Thread moderator capabilities
|
146
|
+
def can_be_edited_by?(user)
|
147
|
+
!commontable.nil? && !user.nil? && user.is_commontator &&\
|
148
|
+
config.thread_moderator_proc.call(self, user)
|
149
|
+
end
|
150
|
+
|
151
|
+
def can_subscribe?(user)
|
152
|
+
thread_sub = config.thread_subscription.to_sym
|
153
|
+
!is_closed? && !user.nil? && user.is_commontator &&\
|
154
|
+
(thread_sub == :m || thread_sub == :b) &&\
|
155
|
+
can_be_read_by?(user)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
@@ -1,7 +1,8 @@
|
|
1
1
|
<% # Clients of this partial must provide the following variables:
|
2
2
|
# comment
|
3
3
|
#
|
4
|
-
#
|
4
|
+
# Optionally, they can also supply the following variables:
|
5
|
+
per_page ||= nil
|
5
6
|
thread ||= nil
|
6
7
|
no_remote ||= false
|
7
8
|
%>
|
@@ -22,6 +23,8 @@
|
|
22
23
|
|
23
24
|
<%= form_for([commontator, thread, comment],
|
24
25
|
:remote => !no_remote) do |f| %>
|
26
|
+
|
27
|
+
<%= hidden_field_tag :per_page, per_page %>
|
25
28
|
|
26
29
|
<div class="comment_form_field">
|
27
30
|
<%= f.text_area :body, :rows => '7' %>
|
@@ -33,3 +36,4 @@
|
|
33
36
|
</div>
|
34
37
|
|
35
38
|
<% end %>
|
39
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<% # Clients of this partial must provide the following variables:
|
2
|
+
# comment
|
3
|
+
#
|
4
|
+
# Optionally, they can also supply the following variables:
|
5
|
+
per_page ||= nil
|
6
|
+
thread ||= nil
|
7
|
+
no_remote ||= false
|
8
|
+
%>
|
9
|
+
|
10
|
+
<% config = comment.thread.config %>
|
11
|
+
|
12
|
+
<% if comment.errors.any? %>
|
13
|
+
<div class="comment_error_explanation">
|
14
|
+
<h3><%= t "commontator.comment.errors.#{comment.id.blank? ? 'create' : 'update'}" %></h3>
|
15
|
+
|
16
|
+
<ul>
|
17
|
+
<% comment.errors.full_messages.each do |msg| %>
|
18
|
+
<li><%= msg %></li>
|
19
|
+
<% end %>
|
20
|
+
</ul>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
<%= form_for([commontator, thread, comment],
|
25
|
+
:remote => !no_remote) do |f| %>
|
26
|
+
|
27
|
+
<%= f.hidden_field :per_page, per_page %>
|
28
|
+
|
29
|
+
<div class="comment_form_field">
|
30
|
+
<%= f.text_area :body, :rows => '7' %>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div class="comment_form_actions">
|
34
|
+
<%= f.submit t("commontator.comment.actions.#{comment.id.blank? ? 'create' : 'update'}") %>
|
35
|
+
<%= f.submit t('commontator.comment.actions.cancel'), :name => 'cancel' %>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<% end %>
|
39
|
+
|
@@ -4,9 +4,10 @@
|
|
4
4
|
%>
|
5
5
|
|
6
6
|
<% creator = comment.creator
|
7
|
-
name =
|
8
|
-
link =
|
9
|
-
avatar =
|
7
|
+
name = Commontator.commontator_name(creator) || ''
|
8
|
+
link = Commontator.commontator_link(creator) || ''
|
9
|
+
avatar = Commontator.commontator_avatar(creator, self) || ''
|
10
|
+
%>
|
10
11
|
|
11
12
|
<div id="comment_<%= comment.id.to_s %>_div" class="comment">
|
12
13
|
<div id="comment_<%= comment.id.to_s %>_top_div" class="comment_div">
|
@@ -45,3 +46,4 @@
|
|
45
46
|
</span>
|
46
47
|
</div>
|
47
48
|
</div>
|
49
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<% # Clients of this partial must supply the following variables:
|
2
|
+
# comment
|
3
|
+
# user
|
4
|
+
%>
|
5
|
+
|
6
|
+
<% creator = comment.creator
|
7
|
+
name = Commontator.commontator_name(creator) || ''
|
8
|
+
link = Commontator.commontator_link(creator) || ''
|
9
|
+
avatar = Commontator.commontator_avatar(creator, self) || ''
|
10
|
+
%>
|
11
|
+
|
12
|
+
<div id="comment_<%= comment.id.to_s %>_div" class="comment">
|
13
|
+
<div id="comment_<%= comment.id.to_s %>_top_div" class="comment_div">
|
14
|
+
<span id="comment_<%= comment.id.to_s %>_commontator_span" class="comment_commontator">
|
15
|
+
<%= link.blank? ? name : link_to(name, link) %>
|
16
|
+
</span>
|
17
|
+
<span id="comment_<%= comment.id.to_s %>_actions_span" class="comment_actions">
|
18
|
+
<%= render :partial => 'commontator/comments/actions',
|
19
|
+
:locals => {:comment => comment,
|
20
|
+
:user => user} %>
|
21
|
+
</span>
|
22
|
+
</div>
|
23
|
+
<div id="comment_<%= comment.id.to_s %>_middle_div" class="comment_div">
|
24
|
+
<span id="comment_<%= comment.id.to_s %>_avatar_span" class="comment_avatar">
|
25
|
+
<%= avatar %>
|
26
|
+
</span>
|
27
|
+
<span id="comment_<%= comment.id.to_s %>_votes_span" class="comment_votes">
|
28
|
+
<%= render :partial => 'commontator/comments/votes',
|
29
|
+
:locals => {:comment => comment,
|
30
|
+
:user => user} %>
|
31
|
+
</span>
|
32
|
+
<div id="comment_<%= comment.id.to_s %>_body_div" class="comment_body">
|
33
|
+
<%= render :partial => 'commontator/comments/body',
|
34
|
+
:locals => {:comment => comment} %>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
<div id="comment_<%= comment.id.to_s %>_bottom_div" class="comment_div">
|
38
|
+
<span id="comment_<%= comment.id.to_s %>_created_timestamp_span" class="comment_timestamp">
|
39
|
+
<%= comment.created_timestamp %>
|
40
|
+
</span>
|
41
|
+
<br/>
|
42
|
+
<span id="comment_<%= comment.id.to_s %>_updated_timestamp_span" class="comment_timestamp">
|
43
|
+
<% if comment.is_modified? %>
|
44
|
+
<%= comment.updated_timestamp %>
|
45
|
+
<% end %>
|
46
|
+
</span>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
|
@@ -37,7 +37,7 @@
|
|
37
37
|
|
38
38
|
<span id="comment_<%= comment.id %>_vote_count_span" class="comment_vote_count">
|
39
39
|
<% config = comment.thread.config %>
|
40
|
-
<%= config.
|
40
|
+
<%= config.vote_count_proc.call(comment.thread,
|
41
41
|
comment.upvotes.size, comment.downvotes.size) %>
|
42
42
|
</span>
|
43
43
|
|
@@ -66,3 +66,4 @@
|
|
66
66
|
</span>
|
67
67
|
<% end %>
|
68
68
|
<% end %>
|
69
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
<% # Clients of this partial must provide the following variables:
|
2
|
+
# comment
|
3
|
+
# user
|
4
|
+
%>
|
5
|
+
|
6
|
+
<% if comment.can_be_voted_on? %>
|
7
|
+
<% can_vote = comment.can_be_voted_on_by?(user) %>
|
8
|
+
<% vote = comment.get_vote_by(user) %>
|
9
|
+
<% comment_voting = comment.thread.config.comment_voting.to_sym %>
|
10
|
+
|
11
|
+
<% if comment_voting == :ld || comment_voting == :l %>
|
12
|
+
<% vtype = (comment_voting == :ld) ? 'upvote' : 'like' %>
|
13
|
+
<span id="comment_<%= comment.id %>_<%= vtype %>_span"
|
14
|
+
class="comment_<%= vtype %>">
|
15
|
+
<% if can_vote && (vote.blank? || !vote.vote_flag) %>
|
16
|
+
<%= form_tag commontator.upvote_comment_path(comment),
|
17
|
+
:method => :put,
|
18
|
+
:remote => true do %>
|
19
|
+
<%= image_submit_tag "commontator/upvote.png",
|
20
|
+
:onmouseover => "this.src='/assets/commontator/upvote_hover.png'",
|
21
|
+
:onmouseout => "this.src='/assets/commontator/upvote.png'" %>
|
22
|
+
<% end %>
|
23
|
+
<% elsif can_vote %>
|
24
|
+
<%= form_tag commontator.unvote_comment_path(comment),
|
25
|
+
:method => :put,
|
26
|
+
:remote => true do %>
|
27
|
+
<%= image_submit_tag "commontator/upvote_active.png",
|
28
|
+
:onmouseover => "this.src='/assets/commontator/upvote.png'",
|
29
|
+
:onmouseout => "this.src='/assets/commontator/upvote_active.png'"
|
30
|
+
%>
|
31
|
+
<% end %>
|
32
|
+
<% else %>
|
33
|
+
<%= image_tag "commontator/upvote_disabled.png" %>
|
34
|
+
<% end %>
|
35
|
+
</span>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<span id="comment_<%= comment.id %>_vote_count_span" class="comment_vote_count">
|
39
|
+
<% config = comment.thread.config %>
|
40
|
+
<%= config.vote_count_proc.call(config.comment_voting,
|
41
|
+
comment.upvotes.size, comment.downvotes.size) %>
|
42
|
+
</span>
|
43
|
+
|
44
|
+
<% if comment_voting == :ld %>
|
45
|
+
<span id="comment_<%= comment.id %>_downvote_span" class="comment_downvote">
|
46
|
+
<% if can_vote && (vote.blank? || vote.vote_flag) %>
|
47
|
+
<%= form_tag commontator.downvote_comment_path(comment),
|
48
|
+
:method => :put,
|
49
|
+
:remote => true do %>
|
50
|
+
<%= image_submit_tag "commontator/downvote.png",
|
51
|
+
:onmouseover => "this.src='/assets/commontator/downvote_hover.png'",
|
52
|
+
:onmouseout => "this.src='/assets/commontator/downvote.png'" %>
|
53
|
+
<% end %>
|
54
|
+
<% elsif can_vote %>
|
55
|
+
<%= form_tag commontator.unvote_comment_path(comment),
|
56
|
+
:method => :put,
|
57
|
+
:remote => true do %>
|
58
|
+
<%= image_submit_tag "commontator/downvote_active.png",
|
59
|
+
:onmouseover => "this.src='/assets/commontator/downvote.png'",
|
60
|
+
:onmouseout => "this.src='/assets/commontator/downvote_active.png'"
|
61
|
+
%>
|
62
|
+
<% end %>
|
63
|
+
<% else %>
|
64
|
+
<%= image_tag "commontator/downvote_disabled.png" %>
|
65
|
+
<% end %>
|
66
|
+
</span>
|
67
|
+
<% end %>
|
68
|
+
<% end %>
|
69
|
+
|
@@ -1,7 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
:
|
1
|
+
<%= render :partial => 'commontator/threads/show',
|
2
|
+
:locals => {:thread => @thread,
|
3
|
+
:user => @user,
|
4
|
+
:page => @thread.new_comment_page(@per_page),
|
5
|
+
:per_page => @per_page} %>
|
5
6
|
|
6
7
|
$("#thread_<%= @thread.id %>_new_comment_div").hide();
|
7
8
|
|
@@ -10,3 +11,4 @@ $("#thread_<%= @thread.id %>_new_comment_link_span").fadeIn();
|
|
10
11
|
$("#comment_<%= @comment.id.to_s %>_div").hide().fadeIn()[0].scrollIntoView();
|
11
12
|
|
12
13
|
<%= javascript_proc %>
|
14
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%= render :partial => 'commontator/threads/show',
|
2
|
+
:locals => {:thread => @thread,
|
3
|
+
:user => @user,
|
4
|
+
:page => @thread.new_comment_page_for(@comment, @per_page),
|
5
|
+
:per_page => @per_page} %>
|
6
|
+
|
7
|
+
$("#thread_<%= @thread.id %>_new_comment_div").hide();
|
8
|
+
|
9
|
+
$("#thread_<%= @thread.id %>_new_comment_link_span").fadeIn();
|
10
|
+
|
11
|
+
$("#comment_<%= @comment.id.to_s %>_div").hide().fadeIn()[0].scrollIntoView();
|
12
|
+
|
13
|
+
<%= javascript_proc %>
|
14
|
+
|