Commit defaba50 authored by Maxwell Salzberg's avatar Maxwell Salzberg Committed by danielgrippi

functional 'show me where this post came from' in soup

parent 5dc36b14
...@@ -19,4 +19,16 @@ module InterimStreamHackinessHelper ...@@ -19,4 +19,16 @@ module InterimStreamHackinessHelper
nil nil
end end
end end
def from_group(post)
if params[:controller]== 'soups'
@stream.post_from_group(post)
else
nil
end
end
def what_soup_sentence(post)
from_group(post).map{|x| x.to_s.gsub("_soup", '').gsub('_',' ').titleize}.to_sentence
end
end end
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
-# the COPYRIGHT file. -# the COPYRIGHT file.
.stream_element{:id => post.guid} .stream_element{:id => post.guid, :class => from_group(post)}
.right.controls .right.controls
- if current_user && post.author.owner_id == current_user.id - if current_user && post.author.owner_id == current_user.id
= link_to image_tag('deletelabel.png'), post_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete stream_element_delete", :title => t('delete') = link_to image_tag('deletelabel.png'), post_path(post), :confirm => t('are_you_sure'), :method => :delete, :remote => true, :class => "delete stream_element_delete", :title => t('delete')
...@@ -17,10 +17,9 @@ ...@@ -17,10 +17,9 @@
%p %p
= t('share_visibilites.update.see_it_on_their_profile', :name => person_link(post.author)).html_safe = t('share_visibilites.update.see_it_on_their_profile', :name => person_link(post.author)).html_safe
= link_to t('undo'), share_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true = link_to t('undo'), share_visibility_path(:id => "42", :post_id => post.id), :method => :put, :remote => true
.indicator{:title => "from #{what_soup_sentence(post)}"}
.sm_body .sm_body
= person_image_link(post.author, :size => :thumb_small) = person_image_link(post.author, :size => :thumb_small)
.content .content
%div.post_initial_info %div.post_initial_info
%span.from %span.from
......
...@@ -29,6 +29,10 @@ class Stream::Base ...@@ -29,6 +29,10 @@ class Stream::Base
post_is_from_contact?(post) post_is_from_contact?(post)
end end
def post_from_group(post)
nil
end
# @return [String] # @return [String]
def title def title
'a title' 'a title'
......
...@@ -13,7 +13,7 @@ class Stream::Soup < Stream::Base ...@@ -13,7 +13,7 @@ class Stream::Soup < Stream::Base
def posts def posts
@posts ||= lambda do @posts ||= lambda do
post_ids = aspect_posts_ids + followed_tag_ids + mentioned_post_ids post_ids = aspects_post_ids + followed_tags_post_ids + mentioned_post_ids
post_ids += community_spotlight_post_ids if include_community_spotlight? post_ids += community_spotlight_post_ids if include_community_spotlight?
Post.where(:id => post_ids).for_a_stream(max_time, order) Post.where(:id => post_ids).for_a_stream(max_time, order)
end.call end.call
...@@ -23,18 +23,32 @@ class Stream::Soup < Stream::Base ...@@ -23,18 +23,32 @@ class Stream::Soup < Stream::Base
false false
end end
#emits an enum of the groups which the post appeared
# :spotlight, :aspects, :tags, :mentioned
def post_from_group(post)
[:community_spotlight, :aspects, :followed_tags, :mentioned].collect do |source|
is_in?(source, post)
end.compact
end
private private
def is_in?(sym, post)
if self.send("#{sym.to_s}_post_ids").find{|x| x == post.id}
"#{sym.to_s}_soup".to_sym
end
end
def include_community_spotlight? def include_community_spotlight?
false false
end end
def aspect_posts_ids def aspects_post_ids
@aspect_posts_ids ||= user.visible_shareable_ids(Post, :limit => 15, :order => "#{order} DESC", :max_time => max_time, :all_aspects? => true, :by_members_of => aspect_ids) @aspects_post_ids ||= user.visible_shareable_ids(Post, :limit => 15, :order => "#{order} DESC", :max_time => max_time, :all_aspects? => true, :by_members_of => aspect_ids)
end end
def followed_tag_ids def followed_tags_post_ids
@followed_tag_ids ||= ids(StatusMessage.tag_stream(user, tag_array, max_time, order)) @followed_tags_ids ||= ids(StatusMessage.tag_stream(user, tag_array, max_time, order))
end end
def mentioned_post_ids def mentioned_post_ids
...@@ -47,7 +61,7 @@ class Stream::Soup < Stream::Base ...@@ -47,7 +61,7 @@ class Stream::Soup < Stream::Base
#worthless helpers #worthless helpers
def community_spotlight_person_ids def community_spotlight_person_ids
Person.community_spotlight.select('id').map{|x| x.id} @community_spotlight_person_ids ||= Person.community_spotlight.select('id').map{|x| x.id}
end end
def tag_array def tag_array
......
...@@ -5,5 +5,8 @@ Diaspora.Pages.SoupsIndex = function() { ...@@ -5,5 +5,8 @@ Diaspora.Pages.SoupsIndex = function() {
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav")); self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
self.stream = self.instantiate("Stream", document.find("#aspect_stream_container")); self.stream = self.instantiate("Stream", document.find("#aspect_stream_container"));
self.infiniteScroll = self.instantiate("InfiniteScroll"); self.infiniteScroll = self.instantiate("InfiniteScroll");
$('.indicator').tipsy({fade: true});
}); });
}; };
...@@ -3493,3 +3493,22 @@ ul#getting_started ...@@ -3493,3 +3493,22 @@ ul#getting_started
:margin-top -28px :margin-top -28px
:color #999 :color #999
:padding-right 9px :padding-right 9px
.indicator
:margin-top -15px
:width 14px
:height 4px
:float right
.aspects_soup
.indicator
:background-color red
.community_spotlight_soup
.indicator
:background-color green
.mentioned_soup
.indicator
:background-color blue
.followed_tags_soup
.indicator
:background-color yellow
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment