like stream new
This commit is contained in:
parent
873e04f24d
commit
23fa7a0a3e
10 changed files with 94 additions and 0 deletions
11
app/controllers/like_stream_controller.rb
Normal file
11
app/controllers/like_stream_controller.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
require File.join(Rails.root, 'lib','stream', 'likes')
|
||||||
|
|
||||||
|
class LikeStreamController < ApplicationController
|
||||||
|
def index
|
||||||
|
default_stream_action(Stream::Likes)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -24,6 +24,8 @@ module StreamHelper
|
||||||
aspects_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :a_ids => @stream.aspect_ids, :sort_order => session[:sort_order])
|
aspects_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :a_ids => @stream.aspect_ids, :sort_order => session[:sort_order])
|
||||||
elsif controller.instance_of?(CommentStreamController)
|
elsif controller.instance_of?(CommentStreamController)
|
||||||
comment_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
comment_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
||||||
|
elsif controller.instance_of?(LikeStreamController)
|
||||||
|
like_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
||||||
else
|
else
|
||||||
raise 'in order to use pagination for this new controller, update next_page_path in stream helper'
|
raise 'in order to use pagination for this new controller, update next_page_path in stream helper'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ class StatusMessage < Post
|
||||||
scope :where_person_is_mentioned, lambda { |person|
|
scope :where_person_is_mentioned, lambda { |person|
|
||||||
joins(:mentions).where(:mentions => {:person_id => person.id})
|
joins(:mentions).where(:mentions => {:person_id => person.id})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope :liked_by, lambda { |person|
|
||||||
|
joins(:likes).where(:likes => {:author_id => person.id})
|
||||||
|
}
|
||||||
|
|
||||||
scope :commented_by, lambda { |person|
|
scope :commented_by, lambda { |person|
|
||||||
joins(:comments).where(:comments => {:author_id => person.id}).group("posts.id")
|
joins(:comments).where(:comments => {:author_id => person.id}).group("posts.id")
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,12 @@
|
||||||
%b
|
%b
|
||||||
= link_to t('streams.comment_stream.title'), comment_stream_path, :class => 'home_selector'
|
= link_to t('streams.comment_stream.title'), comment_stream_path, :class => 'home_selector'
|
||||||
|
|
||||||
|
.section
|
||||||
|
%ul.left_nav
|
||||||
|
%li
|
||||||
|
%b
|
||||||
|
= link_to t('streams.like_stream.title'), like_stream_path, :class => 'home_selector'
|
||||||
|
|
||||||
.section#followed_tags_listing
|
.section#followed_tags_listing
|
||||||
= render 'tags/followed_tags_listings'
|
= render 'tags/followed_tags_listings'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -891,6 +891,10 @@ en:
|
||||||
title: "Commented Posts"
|
title: "Commented Posts"
|
||||||
contacts_title: "People who posts you commented"
|
contacts_title: "People who posts you commented"
|
||||||
|
|
||||||
|
like_stream:
|
||||||
|
title: "Like Stream"
|
||||||
|
contacts_title: "People who Posts you like"
|
||||||
|
|
||||||
followed_tag:
|
followed_tag:
|
||||||
title: "#Followed Tags"
|
title: "#Followed Tags"
|
||||||
contacts_title: "People who dig these tags"
|
contacts_title: "People who dig these tags"
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@ Diaspora::Application.routes.draw do
|
||||||
|
|
||||||
get 'comment_stream' => 'comment_stream#index', :as => 'comment_stream'
|
get 'comment_stream' => 'comment_stream#index', :as => 'comment_stream'
|
||||||
|
|
||||||
|
get 'like_stream' => 'like_stream#index', :as => 'like_stream'
|
||||||
|
|
||||||
get 'tags/:name' => 'tags#show', :as => 'tag'
|
get 'tags/:name' => 'tags#show', :as => 'tag'
|
||||||
|
|
||||||
resources :apps, :only => [:show]
|
resources :apps, :only => [:show]
|
||||||
|
|
|
||||||
22
lib/stream/likes.rb
Normal file
22
lib/stream/likes.rb
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
class Stream::Likes < Stream::Base
|
||||||
|
def link(opts={})
|
||||||
|
Rails.application.routes.url_helpers.like_stream_path(opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
def title
|
||||||
|
I18n.translate("streams.like_stream.title")
|
||||||
|
end
|
||||||
|
|
||||||
|
# @return [ActiveRecord::Association<Post>] AR association of posts
|
||||||
|
def posts
|
||||||
|
@posts ||= StatusMessage.liked_by(self.user.person)
|
||||||
|
end
|
||||||
|
|
||||||
|
def contacts_title
|
||||||
|
I18n.translate('streams.like_stream.contacts_title')
|
||||||
|
end
|
||||||
|
end
|
||||||
10
public/javascripts/pages/like-stream-index.js
Normal file
10
public/javascripts/pages/like-stream-index.js
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
Diaspora.Pages.LikeStreamIndex = 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");
|
||||||
|
});
|
||||||
|
};
|
||||||
19
spec/controllers/like_stream_controller_spec.rb
Normal file
19
spec/controllers/like_stream_controller_spec.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe LikeStreamController do
|
||||||
|
describe 'index' do
|
||||||
|
it 'succeeds' do
|
||||||
|
get :index
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'assigns a stream' do
|
||||||
|
get :index
|
||||||
|
assigns[:stream].should be_a Stream::Likes
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
14
spec/lib/stream/likes_spec.rb
Normal file
14
spec/lib/stream/likes_spec.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
|
||||||
|
|
||||||
|
describe Stream::Likes do
|
||||||
|
before do
|
||||||
|
@stream = Stream::Likes.new(alice, :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