From 82fabbadd14af8d224771dca8108ebd52fc9ce96 Mon Sep 17 00:00:00 2001 From: Ilya Zhitomirskiy <iz268@nyu.edu> Date: Mon, 31 Oct 2011 12:30:15 -0700 Subject: [PATCH] Revert "remove sort order option from the stream (commented at is too crazy and way to slow on large data sets)" This reverts commit 95aac2f3529d6be1c2b17956a24245fe76559de3. --- app/controllers/application_controller.rb | 11 +++++++++++ app/controllers/aspects_controller.rb | 1 + app/views/aspects/_aspect_stream.haml | 7 +++++++ config/locales/diaspora/en.yml | 5 ++++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 15f6f33117..35b2c4f2dc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -138,8 +138,19 @@ class ApplicationController < ActionController::Base @tags ||= current_user.followed_tags 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 + def default_stream_action(stream_klass) authenticate_user! + save_sort_order @stream = stream_klass.new(current_user, :max_time => max_time, :order => sort_order) if params[:only_posts] diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 86d2ebc712..5ca11fa677 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -6,6 +6,7 @@ require File.join(Rails.root, "lib", 'stream', "aspect") class AspectsController < ApplicationController before_filter :authenticate_user! + before_filter :save_sort_order, :only => :index before_filter :save_selected_aspects, :only => :index before_filter :ensure_page, :only => :index diff --git a/app/views/aspects/_aspect_stream.haml b/app/views/aspects/_aspect_stream.haml index 8f3788f54f..5ef3067a7d 100644 --- a/app/views/aspects/_aspect_stream.haml +++ b/app/views/aspects/_aspect_stream.haml @@ -3,6 +3,13 @@ -# the COPYRIGHT file. #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 = stream.title diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 3abf5a868c..3d3728fef3 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -845,7 +845,10 @@ en: no_applications: "You haven't registered any applications yet." streams: - community_spotlight_stream: "Community Spotlight" + recently: "recently:" + commented_on: "commented on" + posted: "posted" + community_spotlight_stream: "Community Spotlight" aspects_stream: "Aspects" mentioned_stream: "@Mentions" followed_tags_stream: "#Followed Tags" -- GitLab