remove sort order logic from controllers; backbone stream does not support it; was to be depricated anyway
This commit is contained in:
parent
828624f392
commit
1b8f78e006
10 changed files with 39 additions and 88 deletions
|
|
@ -135,16 +135,6 @@ class ApplicationController < ActionController::Base
|
||||||
@tags ||= current_user.followed_tags
|
@tags ||= current_user.followed_tags
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_sort_order
|
|
||||||
if params[:sort_order].present?
|
|
||||||
session[:sort_order] = (params[:sort_order] == 'created_at') ? 'created_at' : 'updated_at'
|
|
||||||
elsif session[:sort_order].blank?
|
|
||||||
session[:sort_order] = 'created_at'
|
|
||||||
else
|
|
||||||
session[:sort_order] = (session[:sort_order] == 'created_at') ? 'created_at' : 'updated_at'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# @param stream_klass [Constant]
|
# @param stream_klass [Constant]
|
||||||
# @return [String] JSON representation of posts given a [Stream] constant.
|
# @return [String] JSON representation of posts given a [Stream] constant.
|
||||||
def stream_json(stream_klass)
|
def stream_json(stream_klass)
|
||||||
|
|
@ -153,9 +143,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
def stream(stream_klass)
|
def stream(stream_klass)
|
||||||
authenticate_user!
|
authenticate_user!
|
||||||
save_sort_order
|
stream_klass.new(current_user, :max_time => max_time)
|
||||||
|
|
||||||
stream_klass.new(current_user, :max_time => max_time, :order => sort_order)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_stream_action(stream_klass)
|
def default_stream_action(stream_klass)
|
||||||
|
|
@ -168,10 +156,6 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_order
|
|
||||||
is_mobile_device? ? 'created_at' : session[:sort_order]
|
|
||||||
end
|
|
||||||
|
|
||||||
def max_time
|
def max_time
|
||||||
params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now
|
params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ require File.join(Rails.root, "lib", 'stream', "aspect")
|
||||||
|
|
||||||
class AspectsController < ApplicationController
|
class AspectsController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
before_filter :save_sort_order, :only => :index
|
|
||||||
before_filter :save_selected_aspects, :only => :index
|
before_filter :save_selected_aspects, :only => :index
|
||||||
before_filter :ensure_page, :only => :index
|
before_filter :ensure_page, :only => :index
|
||||||
|
|
||||||
|
|
@ -14,11 +13,8 @@ class AspectsController < ApplicationController
|
||||||
respond_to :json, :only => [:show, :create, :index]
|
respond_to :json, :only => [:show, :create, :index]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
#@backbone = true
|
|
||||||
|
|
||||||
aspect_ids = (session[:a_ids] ? session[:a_ids] : [])
|
aspect_ids = (session[:a_ids] ? session[:a_ids] : [])
|
||||||
@stream = Stream::Aspect.new(current_user, aspect_ids,
|
@stream = Stream::Aspect.new(current_user, aspect_ids,
|
||||||
:order => sort_order,
|
|
||||||
:max_time => params[:max_time].to_i)
|
:max_time => params[:max_time].to_i)
|
||||||
|
|
||||||
respond_with do |format|
|
respond_with do |format|
|
||||||
|
|
|
||||||
|
|
@ -11,21 +11,21 @@ module StreamHelper
|
||||||
elsif controller.instance_of?(PeopleController)
|
elsif controller.instance_of?(PeopleController)
|
||||||
local_or_remote_person_path(@person, :max_time => time_for_scroll(opts[:ajax_stream], @stream))
|
local_or_remote_person_path(@person, :max_time => time_for_scroll(opts[:ajax_stream], @stream))
|
||||||
elsif controller.instance_of?(TagFollowingsController)
|
elsif controller.instance_of?(TagFollowingsController)
|
||||||
tag_followings_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
tag_followings_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream))
|
||||||
elsif controller.instance_of?(CommunitySpotlightController)
|
elsif controller.instance_of?(CommunitySpotlightController)
|
||||||
spotlight_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
spotlight_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream))
|
||||||
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))
|
||||||
elsif controller.instance_of?(MultisController)
|
elsif controller.instance_of?(MultisController)
|
||||||
multi_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
multi_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream))
|
||||||
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))
|
||||||
elsif controller.instance_of?(AspectsController)
|
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])
|
aspects_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :a_ids => @stream.aspect_ids)
|
||||||
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))
|
||||||
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))
|
||||||
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
|
||||||
|
|
@ -40,12 +40,8 @@ module StreamHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def time_for_sort(post)
|
def time_for_sort(post)
|
||||||
if controller.instance_of?(AspectsController)
|
|
||||||
post.send(session[:sort_order].to_sym)
|
|
||||||
else
|
|
||||||
post.created_at
|
post.created_at
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def comments_expanded
|
def comments_expanded
|
||||||
false
|
false
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
%li.all_aspects
|
%li.all_aspects
|
||||||
.root_element= link_to t('aspects.index.your_aspects'), aspects_path
|
.root_element= link_to t('aspects.index.your_aspects'), aspects_path
|
||||||
|
|
||||||
|
- if @stream.is_a?(Stream::Aspect)
|
||||||
%ul.sub_nav
|
%ul.sub_nav
|
||||||
- if defined?(stream)
|
- if defined?(stream)
|
||||||
%a.toggle_selector{:href => '#'}
|
%a.toggle_selector{:href => '#'}
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,6 @@
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
#aspect_stream_header
|
#aspect_stream_header
|
||||||
#sort_by
|
|
||||||
= t('streams.recently')
|
|
||||||
%span.controls
|
|
||||||
= link_to_if(session[:sort_order] == 'created_at', t('streams.commented_on'), stream.link(:sort_order => 'updated_at'))
|
|
||||||
·
|
|
||||||
= link_to_if(session[:sort_order] == 'updated_at', t('streams.posted'), stream.link(:sort_order => 'created_at' ))
|
|
||||||
|
|
||||||
%h3
|
%h3
|
||||||
= stream.title
|
= stream.title
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
%li
|
%li
|
||||||
%b=link_to t('streams.followed_tag.title'), tag_followings_path, :class => 'home_selector'
|
%b=link_to t('streams.followed_tag.title'), tag_followings_path, :class => 'home_selector'
|
||||||
|
|
||||||
|
- if @stream.is_a?(Stream::FollowedTag)
|
||||||
%ul.sub_nav
|
%ul.sub_nav
|
||||||
- if tags.size > 0
|
- if tags.size > 0
|
||||||
- for tg in tags
|
- for tg in tags
|
||||||
|
|
|
||||||
|
|
@ -881,9 +881,6 @@ en:
|
||||||
no_applications: "You haven't registered any applications yet."
|
no_applications: "You haven't registered any applications yet."
|
||||||
|
|
||||||
streams:
|
streams:
|
||||||
recently: "recently:"
|
|
||||||
commented_on: "commented on"
|
|
||||||
posted: "posted"
|
|
||||||
community_spotlight_stream: "Community Spotlight"
|
community_spotlight_stream: "Community Spotlight"
|
||||||
aspects_stream: "Aspects"
|
aspects_stream: "Aspects"
|
||||||
mentioned_stream: "@Mentions"
|
mentioned_stream: "@Mentions"
|
||||||
|
|
|
||||||
|
|
@ -2414,17 +2414,6 @@ ul.show_comments,
|
||||||
:color #eee
|
:color #eee
|
||||||
:border 1px solid #ccc
|
:border 1px solid #ccc
|
||||||
|
|
||||||
#sort_by
|
|
||||||
:float right
|
|
||||||
:color #777
|
|
||||||
.controls
|
|
||||||
:font
|
|
||||||
:weight 700
|
|
||||||
a
|
|
||||||
:font
|
|
||||||
:weight normal
|
|
||||||
|
|
||||||
|
|
||||||
#remember_me
|
#remember_me
|
||||||
input[type='checkbox']
|
input[type='checkbox']
|
||||||
:display inline
|
:display inline
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,9 @@ describe StreamHelper do
|
||||||
before do
|
before do
|
||||||
@post = Factory(:status_message)
|
@post = Factory(:status_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#time_for_sort" do
|
describe "#time_for_sort" do
|
||||||
it "returns sort_order for an aspectscontroller" do
|
it "returns post.created_at" do
|
||||||
sort_order = :stored_in_session
|
|
||||||
stub!(:controller).and_return(AspectsController.new)
|
|
||||||
stub!(:session).and_return({:sort_order => sort_order})
|
|
||||||
@post.should_receive(sort_order)
|
|
||||||
time_for_sort(@post)
|
|
||||||
end
|
|
||||||
it "returns post.created_at otherwise" do
|
|
||||||
stub!(:controller).and_return(mock())
|
stub!(:controller).and_return(mock())
|
||||||
time_for_sort(@post).should == @post.created_at
|
time_for_sort(@post).should == @post.created_at
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue