From ac42021dd561b723f14819656927ee20a636710d Mon Sep 17 00:00:00 2001 From: Caio SBA Date: Thu, 5 Jan 2012 05:17:52 -0300 Subject: [PATCH] Layouts for wall activities done, scraps missing --- app/models/event.rb | 4 ++++ app/models/forum.rb | 9 +++++++++ app/models/uploaded_file.rb | 2 +- app/views/profile/_create_article.rhtml | 6 ++++-- config/initializers/action_tracker.rb | 2 +- public/images/gallery-image-activity-border.png | Bin 0 -> 732 bytes public/stylesheets/application.css | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/unit/article_test.rb | 5 +++++ test/unit/event_test.rb | 3 +++ test/unit/forum_test.rb | 13 +++++++++++++ test/unit/uploaded_file_test.rb | 7 +++++++ 11 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 public/images/gallery-image-activity-border.png diff --git a/app/models/event.rb b/app/models/event.rb index b9ebd8d..d1fea95 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -120,6 +120,10 @@ class Event < Article true end + def notifiable? + true + end + include Noosfero::TranslatableContent include MaybeAddHttp diff --git a/app/models/forum.rb b/app/models/forum.rb index b411e6d..600741a 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -24,4 +24,13 @@ class Forum < Folder def self.icon_name(article = nil) 'forum' end + + def notifiable? + true + end + + def first_paragraph + paragraphs = Hpricot(body).search('p') + paragraphs.empty? ? '' : paragraphs.first.to_html + end end diff --git a/app/models/uploaded_file.rb b/app/models/uploaded_file.rb index 57e6141..3aec60b 100644 --- a/app/models/uploaded_file.rb +++ b/app/models/uploaded_file.rb @@ -4,7 +4,7 @@ # of the file itself is kept. (FIXME?) class UploadedFile < Article - track_actions :upload_image, :after_create, :keep_params => ["view_url", "thumbnail_path", "parent.url", "parent.name"], :if => Proc.new { |a| a.published? && a.image? && !a.parent.nil? && a.parent.gallery? } + track_actions :upload_image, :after_create, :keep_params => ["view_url", "thumbnail_path", "parent.url", "parent.name"], :if => Proc.new { |a| a.published? && a.image? && !a.parent.nil? && a.parent.gallery? }, :custom_target => :parent include ShortFilename diff --git a/app/views/profile/_create_article.rhtml b/app/views/profile/_create_article.rhtml index 6decd36..29429bb 100644 --- a/app/views/profile/_create_article.rhtml +++ b/app/views/profile/_create_article.rhtml @@ -2,8 +2,10 @@ <%= link_to(profile_image(activity.user, :minor), activity.user.url) %>
-

<%= link_to activity.user.name, activity.user.url %> <%= describe activity %>

-
<%= image_tag(activity.params['first_image']) if activity.params['first_image'] %><%= strip_tags(activity.params['lead']).gsub(/(\xA0|\xC2|\s)+/, ' ').gsub(/^\s+/, '') %>
+

<%= link_to activity.user.name, activity.user.url %>

+
+ <%= activity.params['name'] %>
+ <%= image_tag(activity.params['first_image']) unless activity.params['first_image'].blank? %><%= strip_tags(activity.params['lead']).gsub(/(\xA0|\xC2|\s)+/, ' ').gsub(/^\s+/, '') %> <%= link_to(_('See more +'), activity.params['url']) unless activity.get_lead.blank? %>

<%= time_ago_as_sentence(activity.created_at) + ' ' + _('ago') %>

<%= link_to_remote(content_tag(:span, _('Remove')), :url =>{:action => 'remove_activity', :activity_id => activity.id}, :update => "profile-activity-item-#{activity.id}") if logged_in? && current_person == @profile %> diff --git a/config/initializers/action_tracker.rb b/config/initializers/action_tracker.rb index cde4180..22f6db5 100644 --- a/config/initializers/action_tracker.rb +++ b/config/initializers/action_tracker.rb @@ -23,7 +23,7 @@ ActionTrackerConfig.verbs = { }, :upload_image => { - :description => lambda { n_('uploaded 1 image:
%{thumbnails}
%{details}', 'uploaded %{num} images:
%{thumbnails}
%{details}', get_view_url.size) % { :num => get_view_url.size, :thumbnails => '{{ta.collect_group_with_index(:thumbnail_path){ |t,i| content_tag(:span, link_to(image_tag(t), ta.get_view_url[i]))}.last(3).join}}', :details => '{{unique_with_count(ta.collect_group_with_index(:parent_name){ |n,i| link_to(n, ta.get_parent_url[i])}, "%s").join("
")}}' % _("in the gallery") } }, + :description => lambda { n_('uploaded 1 image:
%{thumbnails}
%{details}', 'uploaded %{num} images:
%{thumbnails}
%{details}', get_view_url.size) % { :num => get_view_url.size, :thumbnails => '{{ta.collect_group_with_index(:thumbnail_path){ |t,i| content_tag(:span, image_tag(t) + link_to(nil, ta.get_view_url[i]))}.last(3).join}}', :details => '{{unique_with_count(ta.collect_group_with_index(:parent_name){ |n,i| link_to(n, ta.get_parent_url[i])}, "%s").join("
")}}' % _("in the gallery") } }, :type => :groupable }, diff --git a/public/images/gallery-image-activity-border.png b/public/images/gallery-image-activity-border.png new file mode 100644 index 0000000..7b125f2 Binary files /dev/null and b/public/images/gallery-image-activity-border.png differ diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 88ca7df..735ccb5 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -5911,6 +5911,65 @@ h1#agenda-title { color: #808080; } +#profile-wall li.profile-activity-item.upload_image span, +#profile-wall li.profile-activity-item.upload_image span img, +#profile-wall li.profile-activity-item.upload_image span a { + width: 98px; + height: 86px; + display: block; + overflow: hidden; + position: absolute; +} + +#profile-wall li.profile-activity-item.upload_image span { + position: relative; + float: left; + margin: 5px 5px 5px 0; +} + +#profile-wall li.profile-activity-item.upload_image span a { + background: transparent url(/images/gallery-image-activity-border.png) center center no-repeat; + text-indent: -5000em; +} + +#profile-wall li.profile-activity-item.upload_image .article-comment span, +#profile-wall li.profile-activity-item.upload_image .profile-wall-actions span { + display: inline; + position: static; + margin: 0; + float: none; + width: auto; + height: auto; +} + +#profile-wall li.profile-activity-item ul.profile-wall-activities-comments { + margin-top: 0; +} + +#profile-wall li.profile-activity-item.upload_image .profile-activity-text { + padding-left: 50px; +} + +#profile-wall li.profile-activity-item.join_community .profile-activity-text a img, +#profile-wall li.profile-activity-item.new_friendship .profile-activity-text a img { + margin: 5px 5px 0 0; + padding: 1px; + border: 1px solid #ccc; +} + +#profile-wall li.profile-activity-item.create_article { + position: relative; +} + +.profile-activity-icon { + width: 16px; + height: 16px; + display: inline-block; + position: absolute; + top: 5px; + right: 5px; +} + #profile-activity .profile-wall-scrap-replies li, #profile-network .profile-wall-scrap-replies li, #profile-wall .profile-wall-scrap-replies li { diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 78fb647..6c1cc6d 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -1600,4 +1600,9 @@ assert_equal 'bla', profile.articles.map(&:comments_count) a = fast_create(Article, :body => '

Foo

Bar

') assert_equal '', a.first_image end + + should 'store first image in tracked action' do + a = TinyMceArticle.create! :name => 'Tracked Article', :body => '

FooBar

', :profile_id => profile.id + assert_equal 'foo.png', ActionTracker::Record.last.get_first_image + end end diff --git a/test/unit/event_test.rb b/test/unit/event_test.rb index 7ff9c54..bf603ce 100644 --- a/test/unit/event_test.rb +++ b/test/unit/event_test.rb @@ -274,4 +274,7 @@ class EventTest < ActiveSupport::TestCase assert Event.new.tiny_mce? end + should 'be notifiable' do + assert Event.new.notifiable? + end end diff --git a/test/unit/forum_test.rb b/test/unit/forum_test.rb index 468aea9..b784b55 100644 --- a/test/unit/forum_test.rb +++ b/test/unit/forum_test.rb @@ -110,4 +110,17 @@ class ForumTest < ActiveSupport::TestCase assert !folder.accept_uploads? end + should 'be notifiable' do + assert Forum.new.notifiable? + end + + should 'get first paragraph' do + f = fast_create(Forum, :body => '

First

Second

') + assert_equal '

First

', f.first_paragraph + end + + should 'not get first paragraph' do + f = fast_create(Forum, :body => 'Nothing to do here') + assert_equal '', f.first_paragraph + end end diff --git a/test/unit/uploaded_file_test.rb b/test/unit/uploaded_file_test.rb index 1d7abd6..a08eae1 100644 --- a/test/unit/uploaded_file_test.rb +++ b/test/unit/uploaded_file_test.rb @@ -330,4 +330,11 @@ class UploadedFileTest < ActiveSupport::TestCase assert_equal 'hello_world.php.txt', file.filename end + should 'use the gallery as the parent for action tracker' do + p = fast_create(Gallery, :profile_id => @profile.id) + f = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => p, :profile => @profile) + ta = ActionTracker::Record.last(:conditions => { :verb => "upload_image" }) + assert_equal f.parent, ta.target + end + end -- libgit2 0.21.2