who wants a goat that fetches SOAP?!!
This commit is contained in:
parent
213a1af0bc
commit
44b0887e0a
11 changed files with 96 additions and 6 deletions
9
app/controllers/soups_controller.rb
Normal file
9
app/controllers/soups_controller.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
require File.join(Rails.root, 'lib', 'stream', 'soup_stream')
|
||||||
|
|
||||||
|
class SoupsController < ApplicationController
|
||||||
|
before_filter :redirect_unless_admin
|
||||||
|
|
||||||
|
def index
|
||||||
|
default_stream_action(SoupStream)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -16,6 +16,8 @@ module StreamHelper
|
||||||
featured_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
featured_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
||||||
elsif controller.instance_of?(MentionsController)
|
elsif controller.instance_of?(MentionsController)
|
||||||
mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
||||||
|
elsif controller.instance_of?(SoupsController)
|
||||||
|
soup_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
||||||
elsif controller.instance_of?(PostsController)
|
elsif controller.instance_of?(PostsController)
|
||||||
public_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
public_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
||||||
elsif controller.instance_of?(AspectsController)
|
elsif controller.instance_of?(AspectsController)
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,12 @@ class StatusMessage < Post
|
||||||
)).select('DISTINCT posts.*')
|
)).select('DISTINCT posts.*')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.tag_stream(user, tag_array, max_time, order)
|
||||||
|
owned_or_visible_by_user(user).
|
||||||
|
joins(:tags).where(:tags => {:name => tag_array}).
|
||||||
|
for_a_stream(max_time, order)
|
||||||
|
end
|
||||||
|
|
||||||
def text(opts = {})
|
def text(opts = {})
|
||||||
self.formatted_message(opts)
|
self.formatted_message(opts)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -844,6 +844,9 @@ en:
|
||||||
public:
|
public:
|
||||||
title: "Public Activity"
|
title: "Public Activity"
|
||||||
contacts_title: "Recent Posters"
|
contacts_title: "Recent Posters"
|
||||||
|
soup:
|
||||||
|
titile: "The Soup"
|
||||||
|
contacts_title: "People in your Soup"
|
||||||
|
|
||||||
users:
|
users:
|
||||||
logged_out:
|
logged_out:
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ Diaspora::Application.routes.draw do
|
||||||
|
|
||||||
get 'featured_users' => "contacts#featured", :as => 'featured_users'
|
get 'featured_users' => "contacts#featured", :as => 'featured_users'
|
||||||
|
|
||||||
|
get 'soup' => "soups#index", :as => 'soup'
|
||||||
|
|
||||||
resources :people, :except => [:edit, :update] do
|
resources :people, :except => [:edit, :update] do
|
||||||
resources :status_messages
|
resources :status_messages
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class BaseStream
|
||||||
end
|
end
|
||||||
|
|
||||||
def title
|
def title
|
||||||
'change me in lib/base_stream.rb!'
|
'a title'
|
||||||
end
|
end
|
||||||
|
|
||||||
def posts
|
def posts
|
||||||
|
|
@ -48,7 +48,7 @@ class BaseStream
|
||||||
end
|
end
|
||||||
|
|
||||||
def contacts_link
|
def contacts_link
|
||||||
'change me in lib/base_stream.rb!'
|
'#'
|
||||||
end
|
end
|
||||||
|
|
||||||
#helpers
|
#helpers
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class AspectStream < BaseStream
|
||||||
def aspects
|
def aspects
|
||||||
@aspects ||= lambda do
|
@aspects ||= lambda do
|
||||||
a = user.aspects
|
a = user.aspects
|
||||||
a = a.where(:id => @inputted_aspect_ids) if @inputted_aspect_ids.length > 0
|
a = a.where(:id => @inputted_aspect_ids) if @inputted_aspect_ids.any?
|
||||||
a
|
a
|
||||||
end.call
|
end.call
|
||||||
end
|
end
|
||||||
|
|
|
||||||
50
lib/stream/soup_stream.rb
Normal file
50
lib/stream/soup_stream.rb
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
class SoupStream < BaseStream
|
||||||
|
def link(opts)
|
||||||
|
Rails.application.routes.url_helpers.soup_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def title
|
||||||
|
I18n.t('streams.soup.title')
|
||||||
|
end
|
||||||
|
|
||||||
|
def contacts_title
|
||||||
|
I18n.t('streams.soup.contacts_title')
|
||||||
|
end
|
||||||
|
|
||||||
|
def posts
|
||||||
|
post_ids = aspect_posts_ids + followed_tag_ids + mentioned_post_ids
|
||||||
|
post_ids += featured_user_post_ids
|
||||||
|
Post.where(:id => post_ids).for_a_stream(max_time, order)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def aspect_posts_ids
|
||||||
|
user.visible_post_ids(:limit => 15, :order => order, :max_time => max_time)
|
||||||
|
end
|
||||||
|
|
||||||
|
def followed_tag_ids
|
||||||
|
StatusMessage.tag_stream(user, tag_array, max_time, order).map{|x| x.id}
|
||||||
|
end
|
||||||
|
|
||||||
|
def mentioned_post_ids
|
||||||
|
ids(StatusMessage.where_person_is_mentioned(user.person).for_a_stream(max_time, order))
|
||||||
|
end
|
||||||
|
|
||||||
|
def featured_user_post_ids
|
||||||
|
ids(Post.all_public.where(:author_id => featured_user_ids).for_a_stream(max_time, order))
|
||||||
|
end
|
||||||
|
|
||||||
|
#worthless helpers
|
||||||
|
def featured_user_ids
|
||||||
|
ids(Person.featured_users)
|
||||||
|
end
|
||||||
|
|
||||||
|
def tag_array
|
||||||
|
user.followed_tags.map{|x| x.name}
|
||||||
|
end
|
||||||
|
|
||||||
|
def ids(enumerable)
|
||||||
|
enumerable.map{|x| x.id}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -15,9 +15,7 @@ class TagStream < BaseStream
|
||||||
# @return [ActiveRecord::Association<Post>] AR association of posts
|
# @return [ActiveRecord::Association<Post>] AR association of posts
|
||||||
def posts
|
def posts
|
||||||
return [] if tag_string.empty?
|
return [] if tag_string.empty?
|
||||||
@posts ||= StatusMessage.owned_or_visible_by_user(user).
|
@posts ||= StatusMessage.tag_stream(user, tag_array, max_time, order)
|
||||||
joins(:tags).where(:tags => {:name => tag_array}).
|
|
||||||
for_a_stream(@max_time, @order)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def contacts_title
|
def contacts_title
|
||||||
|
|
|
||||||
9
public/javascripts/pages/soups-index.js
Normal file
9
public/javascripts/pages/soups-index.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
Diaspora.Pages.SoupsIndex = function() {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
this.subscribe("page/ready", function(evt, document) {
|
||||||
|
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");
|
||||||
|
});
|
||||||
|
};
|
||||||
12
spec/lib/stream/soups_stream_spec.rb
Normal file
12
spec/lib/stream/soups_stream_spec.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
|
||||||
|
|
||||||
|
describe SoupStream do
|
||||||
|
before do
|
||||||
|
@stream = SoupStream.new(Factory(:user), :max_time => Time.now, :order => 'updated_at')
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'shared behaviors' do
|
||||||
|
it_should_behave_like 'it is a stream'
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue