72 lines
1.7 KiB
Ruby
72 lines
1.7 KiB
Ruby
# 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 StreamsController < ApplicationController
|
|
before_action :authenticate_user!
|
|
before_action :save_selected_aspects, :only => :aspects
|
|
before_action :redirect_unless_admin, :only => :public
|
|
|
|
layout ->(c) { request.format == :mobile ? "application" : "with_header_with_footer" }
|
|
|
|
respond_to :html,
|
|
:mobile,
|
|
:json
|
|
|
|
def aspects
|
|
aspect_ids = (session[:a_ids] || [])
|
|
@stream = Stream::Aspect.new(current_user, aspect_ids,
|
|
:max_time => max_time)
|
|
stream_responder
|
|
end
|
|
|
|
def public
|
|
stream_responder(Stream::Public)
|
|
end
|
|
|
|
def activity
|
|
stream_responder(Stream::Activity)
|
|
end
|
|
|
|
def multi
|
|
stream_responder(Stream::Multi)
|
|
end
|
|
|
|
def commented
|
|
stream_responder(Stream::Comments)
|
|
end
|
|
|
|
def liked
|
|
stream_responder(Stream::Likes)
|
|
end
|
|
|
|
def mentioned
|
|
stream_responder(Stream::Mention)
|
|
end
|
|
|
|
def followed_tags
|
|
gon.preloads[:tagFollowings] = tags
|
|
stream_responder(Stream::FollowedTag)
|
|
end
|
|
|
|
private
|
|
|
|
def stream_responder(stream_klass=nil)
|
|
|
|
if stream_klass.present?
|
|
@stream ||= stream_klass.new(current_user, :max_time => max_time)
|
|
end
|
|
|
|
respond_with do |format|
|
|
format.html { render 'streams/main_stream' }
|
|
format.mobile { render 'streams/main_stream' }
|
|
format.json { render :json => @stream.stream_posts.map {|p| LastThreeCommentsDecorator.new(PostPresenter.new(p, current_user)) }}
|
|
end
|
|
end
|
|
|
|
def save_selected_aspects
|
|
if params[:a_ids].present?
|
|
session[:a_ids] = params[:a_ids]
|
|
end
|
|
end
|
|
end
|