Commit 313d6915b177f4941a3fb4c3341ba90671d3fc85

Authored by Daniela Feitosa
1 parent cb35a9eb

Fixes on AI1826

Duplicated comments when it has answers
Displaying comment title
Fixed avatar images on comment
Article title far from article lead
Only displaying 1000 cahrs
Creating activities on communities feed
Fixes on rightbar and leftbar
app/models/image.rb
@@ -13,7 +13,7 @@ class Image < ActiveRecord::Base @@ -13,7 +13,7 @@ class Image < ActiveRecord::Base
13 :thumbnails => { :big => '150x150', 13 :thumbnails => { :big => '150x150',
14 :thumb => '100x100', 14 :thumb => '100x100',
15 :portrait => '64x64', 15 :portrait => '64x64',
16 - :minor => '50x50', 16 + :minor => '50x50>',
17 :icon => '20x20!' }, 17 :icon => '20x20!' },
18 :max_size => 5.megabytes # remember to update validate message below 18 :max_size => 5.megabytes # remember to update validate message below
19 19
app/views/profile/_comment.rhtml
@@ -17,7 +17,11 @@ @@ -17,7 +17,11 @@
17 17
18 <div class="comment-details"> 18 <div class="comment-details">
19 <div class="comment-text"> 19 <div class="comment-text">
20 - <%= link_to(comment.author_name, comment.author.url) %> <%= txt2html comment.body %> 20 + <%= link_to(comment.author_name, comment.author.url) %>
  21 + <% unless comment.title.blank? %>
  22 + <span class="comment-title"><%= comment.title %></span><br/>
  23 + <% end %>
  24 + <%= txt2html comment.body %>
21 </div> 25 </div>
22 <div class="profile-activity-time"> 26 <div class="profile-activity-time">
23 <%= time_ago_as_sentence(comment.created_at) %> 27 <%= time_ago_as_sentence(comment.created_at) %>
app/views/profile/_create_article.rhtml
@@ -7,9 +7,9 @@ @@ -7,9 +7,9 @@
7 <%= _("on community %s") % link_to(activity.target.profile.short_name(20), activity.target.profile.url) if activity.target.profile.is_a?(Community) %> 7 <%= _("on community %s") % link_to(activity.target.profile.short_name(20), activity.target.profile.url) if activity.target.profile.is_a?(Community) %>
8 </p> 8 </p>
9 <div class='profile-activity-lead'> 9 <div class='profile-activity-lead'>
10 - <b><%= link_to(activity.params['name'], activity.params['url']) %></b>  
11 - <span title='<%= activity.target.class.short_description %>' class='profile-activity-icon icon-new icon-new<%= activity.target.class.icon_name %>'></span><br />  
12 - <%= image_tag(activity.params['first_image']) unless activity.params['first_image'].blank? %><%= strip_tags(activity.params['lead']).gsub(/(\xA0|\xC2|\s)+/, ' ').gsub(/^\s+/, '') %> <small><%= link_to(_('See more'), activity.params['url']) unless activity.get_lead.blank? %></small> 10 + <div class='article-name'><%= link_to(activity.params['name'], activity.params['url']) %></div>
  11 + <span title='<%= activity.target.class.short_description %>' class='profile-activity-icon icon-new icon-new<%= activity.target.class.icon_name %>'></span>
  12 + <%= image_tag(activity.params['first_image']) unless activity.params['first_image'].blank? %><%= strip_tags(truncate(activity.params['lead'], 1000, '...')).gsub(/(\xA0|\xC2|\s)+/, ' ').gsub(/^\s+/, '') %> <small><%= link_to(_('See more'), activity.params['url']) unless activity.get_lead.blank? %></small>
13 </div> 13 </div>
14 <%= content_tag(:p, link_to(_('See complete forum'), activity.get_url), :class => 'see-forum') if activity.target.is_a?(Forum) %> 14 <%= content_tag(:p, link_to(_('See complete forum'), activity.get_url), :class => 'see-forum') if activity.target.is_a?(Forum) %>
15 <p class='profile-activity-time'><%= time_ago_as_sentence(activity.created_at) %></p> 15 <p class='profile-activity-time'><%= time_ago_as_sentence(activity.created_at) %></p>
app/views/profile/_profile_comments.rhtml
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 <% end %> 7 <% end %>
8 8
9 <ul class="profile-wall-activities-comments" style="<%= 'display:none;' if (activity.comments_count > 2) %>" > 9 <ul class="profile-wall-activities-comments" style="<%= 'display:none;' if (activity.comments_count > 2) %>" >
10 - <%= render :partial => 'comment', :collection => activity.comments %> 10 + <%= render :partial => 'comment', :collection => activity.comments_as_thread %>
11 </ul> 11 </ul>
12 12
13 <%= render :partial => 'profile_comment_form', :locals => { :activity => activity, :tab_action => tab_action } %> 13 <%= render :partial => 'profile_comment_form', :locals => { :activity => activity, :tab_action => tab_action } %>
public/designs/templates/leftbar/stylesheets/style.css
@@ -55,19 +55,13 @@ @@ -55,19 +55,13 @@
55 height: 144px; 55 height: 144px;
56 } 56 }
57 57
58 -#profile-wall li.profile-activity-item.upload_image span a,  
59 -#profile-network li.profile-activity-item.upload_image span a {  
60 - background-image: url(/images/gallery-image-activity-border-onecol.png);  
61 -}  
62 -  
63 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span, 58 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span,
64 -#profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span img, 59 +#profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a img,
65 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a, 60 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a,
66 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span, 61 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span,
67 -#profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span img, 62 +#profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a img,
68 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a { 63 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a {
69 - width: 549px;  
70 - height: 254px; 64 + max-width: 540px;
71 } 65 }
72 66
73 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a, 67 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a,
public/designs/templates/rightbar/stylesheets/style.css
@@ -55,22 +55,11 @@ @@ -55,22 +55,11 @@
55 height: 144px; 55 height: 144px;
56 } 56 }
57 57
58 -#profile-wall li.profile-activity-item.upload_image span a,  
59 -#profile-network li.profile-activity-item.upload_image span a {  
60 - background-image: url(/images/gallery-image-activity-border-onecol.png);  
61 -}  
62 -  
63 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span, 58 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span,
64 -#profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span img, 59 +#profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a img,
65 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a, 60 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a,
66 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span, 61 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span,
67 -#profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span img,  
68 -#profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a {  
69 - width: 549px;  
70 - height: 254px;  
71 -}  
72 -  
73 -#profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a, 62 +#profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a img,
74 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a { 63 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a {
75 - background-image: url(/images/gallery-image-activity-border-big-onecol.png); 64 + max-width: 540px;
76 } 65 }
public/stylesheets/application.css
@@ -1203,6 +1203,10 @@ a.comment-picture { @@ -1203,6 +1203,10 @@ a.comment-picture {
1203 color: #888; 1203 color: #888;
1204 } 1204 }
1205 1205
  1206 +.comment-title {
  1207 + font-size: 12px;
  1208 + font-weight: bold;
  1209 +}
1206 .comment-created-at { 1210 .comment-created-at {
1207 padding-right: 9px; 1211 padding-right: 9px;
1208 } 1212 }
@@ -5913,6 +5917,11 @@ h1#agenda-title { @@ -5913,6 +5917,11 @@ h1#agenda-title {
5913 margin: 5px 0; 5917 margin: 5px 0;
5914 } 5918 }
5915 5919
  5920 +.profile-activity-lead .article-name {
  5921 + font-weight: bold;
  5922 + margin-bottom: 5px;
  5923 +}
  5924 +
5916 .profile-activity-article-forum .profile-activity-lead { 5925 .profile-activity-article-forum .profile-activity-lead {
5917 height: 50px; 5926 height: 50px;
5918 width: 297px; 5927 width: 297px;
@@ -5980,7 +5989,8 @@ h1#agenda-title { @@ -5980,7 +5989,8 @@ h1#agenda-title {
5980 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a img, 5989 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a img,
5981 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span, 5990 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span,
5982 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a img { 5991 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a img {
5983 - width: 383px; 5992 + width: auto;
  5993 + max-width: 383px;
5984 height: auto; 5994 height: auto;
5985 } 5995 }
5986 5996
@@ -6006,13 +6016,11 @@ h1#agenda-title { @@ -6006,13 +6016,11 @@ h1#agenda-title {
6006 6016
6007 #profile-wall li.profile-activity-item.upload_image span a, 6017 #profile-wall li.profile-activity-item.upload_image span a,
6008 #profile-network li.profile-activity-item.upload_image span a { 6018 #profile-network li.profile-activity-item.upload_image span a {
6009 - Xbackground: transparent url(/images/gallery-image-activity-border.png) center center no-repeat;  
6010 text-indent: -5000em; 6019 text-indent: -5000em;
6011 } 6020 }
6012 6021
6013 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a, 6022 #profile-wall li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a,
6014 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a { 6023 #profile-network li.profile-activity-item.upload_image .activity-gallery-images-count-1 span a {
6015 - Xbackground-image: url(/images/gallery-image-activity-border-big.png);  
6016 position: relative; 6024 position: relative;
6017 } 6025 }
6018 6026
@@ -6365,8 +6373,8 @@ h1#agenda-title { @@ -6365,8 +6373,8 @@ h1#agenda-title {
6365 6373
6366 #profile-wall .profile-wall-activities-comments img, 6374 #profile-wall .profile-wall-activities-comments img,
6367 #profile-network .profile-wall-activities-comments img { 6375 #profile-network .profile-wall-activities-comments img {
6368 - width: 33px;  
6369 - height: 33px; 6376 + max-width: 50px;
  6377 + max-height: 50px;
6370 } 6378 }
6371 6379
6372 #profile-wall .profile-wall-activities-comments .comment_reply, 6380 #profile-wall .profile-wall-activities-comments .comment_reply,
@@ -6378,8 +6386,8 @@ h1#agenda-title { @@ -6378,8 +6386,8 @@ h1#agenda-title {
6378 6386
6379 #profile-wall .profile-wall-activities-comments .comment-picture, 6387 #profile-wall .profile-wall-activities-comments .comment-picture,
6380 #profile-network .profile-wall-activities-comments .comment-picture { 6388 #profile-network .profile-wall-activities-comments .comment-picture {
6381 - width: 33px;  
6382 - margin-right: 10px; 6389 + width: 50px;
  6390 + text-align: center;
6383 } 6391 }
6384 6392
6385 #profile-wall .profile-wall-activities-comments .comment-text p, 6393 #profile-wall .profile-wall-activities-comments .comment-text p,
test/unit/comment_test.rb
@@ -321,6 +321,22 @@ class CommentTest &lt; ActiveSupport::TestCase @@ -321,6 +321,22 @@ class CommentTest &lt; ActiveSupport::TestCase
321 assert result[1].replies.empty? 321 assert result[1].replies.empty?
322 end 322 end
323 323
  324 + should "return activities comments as a thread" do
  325 + person = fast_create(Person)
  326 + a = TextileArticle.create!(:profile => person, :name => 'My article', :body => 'Article body')
  327 + c0 = Comment.create!(:source => a, :body => 'My comment', :author => person)
  328 + c1 = Comment.create!(:reply_of_id => c0.id, :source => a, :body => 'bla', :author => person)
  329 + c2 = Comment.create!(:reply_of_id => c1.id, :source => a, :body => 'bla', :author => person)
  330 + c3 = Comment.create!(:reply_of_id => c0.id, :source => a, :body => 'bla', :author => person)
  331 + c4 = Comment.create!(:source => a, :body => 'My comment', :author => person)
  332 + result = a.activity.comments_as_thread
  333 + assert_equal c0, result[0]
  334 + assert_equal [c1, c3], result[0].replies
  335 + assert_equal [c2], result[0].replies[0].replies
  336 + assert_equal c4, result[1]
  337 + assert result[1].replies.empty?
  338 + end
  339 +
324 should 'provide author url for authenticated user' do 340 should 'provide author url for authenticated user' do
325 author = Person.new 341 author = Person.new
326 author.expects(:url).returns('http://blabla.net/author') 342 author.expects(:url).returns('http://blabla.net/author')
vendor/plugins/action_tracker_has_comments/init.rb
@@ -9,4 +9,15 @@ ActionTracker::Record.module_eval do @@ -9,4 +9,15 @@ ActionTracker::Record.module_eval do
9 "source_type = '#{type}' AND source_id = '#{id}'" 9 "source_type = '#{type}' AND source_id = '#{id}'"
10 end 10 end
11 11
  12 + def comments_as_thread
  13 + result = {}
  14 + root = []
  15 + self.comments.each do |c|
  16 + c.replies = []
  17 + result[c.id] ||= c
  18 + c.reply_of_id.nil? ? root << c : result[c.reply_of_id].replies << c
  19 + end
  20 + root
  21 + end
  22 +
12 end 23 end