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
nil
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
......@@ -3,7 +3,7 @@
-# the COPYRIGHT file.
.stream_element{:id => post.guid}
.stream_element{:id => post.guid, :class => from_group(post)}
.right.controls
- 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')
......@@ -17,10 +17,9 @@
%p
= 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
.indicator{:title => "from #{what_soup_sentence(post)}"}
.sm_body
= person_image_link(post.author, :size => :thumb_small)
.content
%div.post_initial_info
%span.from
......
......@@ -29,6 +29,10 @@ class Stream::Base
post_is_from_contact?(post)
end
def post_from_group(post)
nil
end
# @return [String]
def title
'a title'
......
......@@ -13,7 +13,7 @@ class Stream::Soup < Stream::Base
def posts
@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.where(:id => post_ids).for_a_stream(max_time, order)
end.call
......@@ -23,18 +23,32 @@ class Stream::Soup < Stream::Base
false
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
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?
false
end
def aspect_posts_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)
def aspects_post_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
def followed_tag_ids
@followed_tag_ids ||= ids(StatusMessage.tag_stream(user, tag_array, max_time, order))
def followed_tags_post_ids
@followed_tags_ids ||= ids(StatusMessage.tag_stream(user, tag_array, max_time, order))
end
def mentioned_post_ids
......@@ -47,7 +61,7 @@ class Stream::Soup < Stream::Base
#worthless helpers
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
def tag_array
......
......@@ -5,5 +5,8 @@ Diaspora.Pages.SoupsIndex = function() {
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
self.stream = self.instantiate("Stream", document.find("#aspect_stream_container"));
self.infiniteScroll = self.instantiate("InfiniteScroll");
$('.indicator').tipsy({fade: true});
});
};
......@@ -3493,3 +3493,22 @@ ul#getting_started
:margin-top -28px
:color #999
: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