fix sql error
This commit is contained in:
parent
c77c9df646
commit
4b25545e82
9 changed files with 75 additions and 1 deletions
11
app/controllers/comment_stream_controller.rb
Normal file
11
app/controllers/comment_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', 'comments')
|
||||||
|
|
||||||
|
class CommentStreamController < ApplicationController
|
||||||
|
def index
|
||||||
|
default_stream_action(Stream::Comments)
|
||||||
|
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?(LikeStreamController)
|
elsif controller.instance_of?(LikeStreamController)
|
||||||
like_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
like_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
||||||
|
elsif controller.instance_of?(CommentStreamController)
|
||||||
|
comment_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
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,10 @@ class StatusMessage < Post
|
||||||
joins(:mentions).where(:mentions => {:person_id => person.id})
|
joins(:mentions).where(:mentions => {:person_id => person.id})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope :commented_by, lambda { |person|
|
||||||
|
select('DISTINCT "posts".*').joins(:comments).where(:comments => {:author_id => person.id})
|
||||||
|
}
|
||||||
|
|
||||||
scope :liked_by, lambda { |person|
|
scope :liked_by, lambda { |person|
|
||||||
joins(:likes).where(:likes => {:author_id => person.id})
|
joins(:likes).where(:likes => {:author_id => person.id})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,12 @@
|
||||||
%b
|
%b
|
||||||
= link_to t('streams.mentions.title'), mentions_path, :class => 'home_selector'
|
= link_to t('streams.mentions.title'), mentions_path, :class => 'home_selector'
|
||||||
|
|
||||||
|
.section
|
||||||
|
%ul.left_nav
|
||||||
|
%li
|
||||||
|
%b
|
||||||
|
= link_to t('streams.comment_stream.title'), comment_stream_path, :class => 'home_selector'
|
||||||
|
|
||||||
.section
|
.section
|
||||||
%ul.left_nav
|
%ul.left_nav
|
||||||
%li
|
%li
|
||||||
|
|
|
||||||
|
|
@ -889,9 +889,13 @@ en:
|
||||||
title: "@Mentions"
|
title: "@Mentions"
|
||||||
contacts_title: "People who mentioned you"
|
contacts_title: "People who mentioned you"
|
||||||
|
|
||||||
|
comment_stream:
|
||||||
|
title: "Commented Posts"
|
||||||
|
contacts_title: "People who posts you commented"
|
||||||
|
|
||||||
like_stream:
|
like_stream:
|
||||||
title: "Like Stream"
|
title: "Like Stream"
|
||||||
contacts_title: "People who Posts you like"
|
contacts_title: "People who posts you like"
|
||||||
|
|
||||||
followed_tag:
|
followed_tag:
|
||||||
title: "#Followed Tags"
|
title: "#Followed Tags"
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,8 @@ Diaspora::Application.routes.draw do
|
||||||
resources :mentions, :only => [:index]
|
resources :mentions, :only => [:index]
|
||||||
resources "tag_followings", :only => [:create]
|
resources "tag_followings", :only => [:create]
|
||||||
|
|
||||||
|
get 'comment_stream' => 'comment_stream#index', :as => 'comment_stream'
|
||||||
|
|
||||||
get 'like_stream' => 'like_stream#index', :as => 'like_stream'
|
get 'like_stream' => 'like_stream#index', :as => 'like_stream'
|
||||||
|
|
||||||
get 'tags/:name' => 'tags#show', :as => 'tag'
|
get 'tags/:name' => 'tags#show', :as => 'tag'
|
||||||
|
|
|
||||||
22
lib/stream/comments.rb
Normal file
22
lib/stream/comments.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::Comments < Stream::Base
|
||||||
|
def link(opts={})
|
||||||
|
Rails.application.routes.url_helpers.comment_stream_path(opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
def title
|
||||||
|
I18n.translate("streams.comment_stream.title")
|
||||||
|
end
|
||||||
|
|
||||||
|
# @return [ActiveRecord::Association<Post>] AR association of posts
|
||||||
|
def posts
|
||||||
|
@posts ||= StatusMessage.commented_by(self.user.person)
|
||||||
|
end
|
||||||
|
|
||||||
|
def contacts_title
|
||||||
|
I18n.translate('streams.comment_stream.contacts_title')
|
||||||
|
end
|
||||||
|
end
|
||||||
11
public/javascripts/pages/comment-stream-index.js
Normal file
11
public/javascripts/pages/comment-stream-index.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
Diaspora.Pages.CommentStreamIndex = 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/comments_spec.rb
Normal file
12
spec/lib/stream/comments_spec.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
|
||||||
|
|
||||||
|
describe Stream::Comments do
|
||||||
|
before do
|
||||||
|
@stream = Stream::Comments.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