Skip to content
Extraits de code Groupes Projets
Valider 55ffc44a rédigé par Your Name's avatar Your Name
Parcourir les fichiers

wip

parent b8984e7e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 77 ajouts et 32 suppressions
......@@ -147,6 +147,19 @@ class ApplicationController < ActionController::Base
end
end
def default_stream_action(stream_klass)
puts "yah"
authenticate_user!
save_sort_order
@stream = stream_klass.new(current_user, :max_time => params[:max_time], :order => sort_order)
if params[:only_posts]
render :partial => 'shared/stream', :locals => {:posts => @stream.posts}
else
render 'aspects/index'
end
end
def sort_order
is_mobile_device? ? 'created_at' : session[:sort_order]
end
......
require File.join(Rails.root, 'lib', 'stream', 'featured_users_stream')
class FeaturedUsersController < ApplicationController
before_filter :authenticate_user!
before_filter :save_sort_order, :only => :index
def index
@stream = FeaturedUsersStream.new(current_user, :max_time => params[:max_time], :order => sort_order)
if params[:only_posts]
render :partial => 'shared/stream', :locals => {:posts => @stream.posts}
else
render 'aspects/index'
end
default_stream_action(FeaturedUsersStream)
end
end
......@@ -5,16 +5,7 @@
require File.join(Rails.root, 'lib','stream', 'mention_stream')
class MentionsController < ApplicationController
before_filter :authenticate_user!
before_filter :save_sort_order, :only => :index
def index
@stream = MentionStream.new(current_user, :max_time => params[:max_time], :order => sort_order)
if params[:only_posts]
render :partial => 'shared/stream', :locals => {:posts => @stream.posts}
else
render 'aspects/index'
end
default_stream_action(MentionStream)
end
end
......@@ -2,6 +2,8 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require File.join(Rails.root, 'lib', 'stream', 'public_stream')
class PostsController < ApplicationController
before_filter :authenticate_user!, :except => :show
before_filter :set_format_if_malformed_from_status_net, :only => :show
......@@ -59,6 +61,10 @@ class PostsController < ApplicationController
end
end
def index
default_stream_action(PublicStream)
end
def set_format_if_malformed_from_status_net
request.format = :html if request.format == 'application/html+xml'
end
......
# 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', 'public_stream')
class PublicsController < ApplicationController
require File.join(Rails.root, '/lib/diaspora/parser')
......@@ -13,6 +14,7 @@ class PublicsController < ApplicationController
skip_before_filter :set_grammatical_gender
before_filter :allow_cross_origin, :only => [:hcard, :host_meta, :webfinger]
before_filter :check_for_xml, :only => [:receive, :receive_public]
before_filter :authenticate_user!, :only => [:index]
respond_to :html
respond_to :xml, :only => :post
......
......@@ -6,15 +6,9 @@ require File.join(Rails.root, 'lib', 'stream', 'tag_stream')
class TagFollowingsController < ApplicationController
before_filter :authenticate_user!
before_filter :save_sort_order, :only => :index
def index
@stream = TagStream.new(current_user, :max_time => params[:max_time], :order => sort_order)
if params[:only_posts]
render :partial => 'shared/stream', :locals => {:posts => @stream.posts}
else
render 'aspects/index'
end
default_stream_action(TagStream)
end
# POST /tag_followings
......
......@@ -16,6 +16,8 @@ module StreamHelper
featured_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
elsif controller.instance_of?(MentionsController)
mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
elsif controller.instance_of?(PostsController)
public_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
elsif controller.instance_of?(AspectsController)
aspects_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :a_ids => @stream.aspect_ids, :sort_order => session[:sort_order])
else
......
......@@ -41,6 +41,7 @@ class Post < ActiveRecord::Base
def self.for_a_stream(max_time, order)
by_max_time(max_time, order).
includes_for_a_stream.
where(:type => BaseStream::TYPES_OF_POST_IN_STREAM).
limit(15)
end
......
......@@ -839,7 +839,8 @@ en:
tags:
title: "Posts tagged: %{tags}"
contacts_title: "People who dig these tags"
public:
title: "Public Activity"
users:
logged_out:
......
......@@ -20,7 +20,7 @@ Diaspora::Application.routes.draw do
resources :comments, :only => [:new, :create, :destroy, :index]
end
get 'p/:id' => 'posts#show', :as => 'short_post'
get 'public_stream' => 'posts#index', :as => 'public_stream'
# roll up likes into a nested resource above
resources :comments, :only => [:create, :destroy] do
resources :likes, :only => [:create, :destroy, :index]
......@@ -137,6 +137,7 @@ Diaspora::Application.routes.draw do
end
# External
resources :authorizations, :only => [:index, :destroy]
......
class BaseStream
TYPES_OF_POST_IN_STREAM = ['StatusMessage', 'Reshare', 'ActivityStreams::Photo']
attr_accessor :max_time, :order, :user
def initialize(user, opts={})
......@@ -7,7 +8,6 @@ class BaseStream
self.order = opts[:order]
end
def random_featured_user
Person.find_by_diaspora_handle(featured_diaspora_id)
end
......
......@@ -78,7 +78,7 @@ class RedisCache
# exposing the need to tie cache to a stream
# @return [Array<String>] Acceptable Post types for the given cache
def self.acceptable_types
::AspectStream::TYPES_OF_POST_IN_STREAM
BaseStream::TYPES_OF_POST_IN_STREAM
end
# Instantiate a redis connection
......
......@@ -3,7 +3,6 @@
# the COPYRIGHT file.
class AspectStream < BaseStream
TYPES_OF_POST_IN_STREAM = ['StatusMessage', 'Reshare', 'ActivityStreams::Photo']
# @param user [User]
# @param inputted_aspect_ids [Array<Integer>] Ids of aspects for given stream
......
......@@ -20,7 +20,7 @@ class FeaturedUsersStream < BaseStream
end
def posts
Post.all_public.where(:author_id => people.map{|x| x.id}, :type => AspectStream::TYPES_OF_POST_IN_STREAM).for_a_stream(max_time, order)
Post.all_public.where(:author_id => people.map{|x| x.id}).for_a_stream(max_time, order)
end
def people
......
# 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 PublicStream < BaseStream
def link(opts={})
Rails.application.routes.url_helpers.public_stream_path(opts)
end
def title
I18n.translate("streams.public.title")
end
# @return [ActiveRecord::Association<Post>] AR association of posts
def posts
@posts ||= Post.all_public.for_a_stream(max_time, order)
end
# @return [ActiveRecord::Association<Person>] AR association of people within stream's given aspects
def people
@people ||= posts.map{|p| p.author}.uniq
end
def contacts_title
"The last 15 people in this stream"
end
def can_comment?(post)
post.author.local?
end
end
Diaspora.Pages.PostsIndex = 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");
});
};
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter