diff --git a/app/helpers/stream_helper.rb b/app/helpers/stream_helper.rb index f747e5fe8..abc2af716 100644 --- a/app/helpers/stream_helper.rb +++ b/app/helpers/stream_helper.rb @@ -11,20 +11,22 @@ module StreamHelper elsif controller.instance_of?(PeopleController) person_path(@person, :max_time => @posts.last.created_at.to_i) elsif controller.instance_of?(TagFollowingsController) - tag_followings_path(:max_time => @stream.posts.last.created_at.to_i) + tag_followings_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream)) elsif controller.instance_of?(AspectsController) - if opts[:ajax_stream] - time = (Time.now() + 1).to_i - - else - time = @stream.posts.last.send(@stream.order.to_sym).to_i - end - aspects_path(:max_time => time, :sort_order => session[:sort_order], :a_ids => @stream.aspect_ids) + aspects_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :a_ids => @stream.aspect_ids) else raise 'in order to use pagination for this new controller, update next_page_path in stream helper' end end + def time_for_scroll(ajax_stream, stream) + if ajax_stream + (Time.now() + 1).to_i + else + stream.posts.last.send(stream.order.to_sym).to_i + end + end + def time_for_sort post if controller.instance_of?(AspectsController) post.send(session[:sort_order].to_sym) diff --git a/app/views/aspects/_aspect_stream.haml b/app/views/aspects/_aspect_stream.haml index 01791295c..5ac7a9a4f 100644 --- a/app/views/aspects/_aspect_stream.haml +++ b/app/views/aspects/_aspect_stream.haml @@ -6,15 +6,12 @@ #sort_by = t('.recently') %span.controls - = link_to_if(session[:sort_order] == 'updated_at', t('.posted'), aspects_path(:a_ids => stream.aspect_ids, :sort_order => 'created_at' )) + = link_to_if(session[:sort_order] == 'created_at', t('.commented_on'), stream.link(:sort_order => 'updated_at')) ยท - = link_to_if(session[:sort_order] == 'created_at', t('.commented_on'), aspects_path(:a_ids => stream.aspect_ids, :sort_order => 'updated_at')) + = link_to_if(session[:sort_order] == 'updated_at', t('.posted'), stream.link(:sort_order => 'created_at' )) %h3 - - if stream.for_all_aspects? - = t('.stream') - - else - = stream.aspects.to_sentence + = stream.title = render 'shared/publisher', :selected_aspects => stream.aspects, :aspect_ids => stream.aspect_ids, :for_all_aspects => stream.for_all_aspects?, :aspect => stream.aspect = render 'aspects/no_posts_message' diff --git a/app/views/aspects/_selected_contacts.html.haml b/app/views/aspects/_selected_contacts.html.haml index 26ab71d88..7b0718605 100644 --- a/app/views/aspects/_selected_contacts.html.haml +++ b/app/views/aspects/_selected_contacts.html.haml @@ -1,12 +1,7 @@ #selected_aspect_contacts.section .title.no_icon %h5 - - if @stream.for_all_aspects? || @stream.aspect_ids.size > 1 - = "#{t('_contacts')}" - - else - = @stream.aspect.name - = "(#{@stream.people.size})" - + = @stream.contacts_title .content - if @stream.people.size > 0 diff --git a/app/views/tags/_followed_tags_listings.haml b/app/views/tags/_followed_tags_listings.haml index 0b9703666..8270cb9dc 100644 --- a/app/views/tags/_followed_tags_listings.haml +++ b/app/views/tags/_followed_tags_listings.haml @@ -6,7 +6,7 @@ %ul.left_nav %li %div.root_element - = t('aspects.index.tags_following') + =link_to t('aspects.index.tags_following'), tag_followings_path %ul.sub_nav - if tags.size > 0 diff --git a/config/environments/development.rb b/config/environments/development.rb index 3f7a38e3d..18345ee44 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -21,7 +21,6 @@ Diaspora::Application.configure do config.action_mailer.raise_delivery_errors = false config.active_support.deprecation = :log #config.threadsafe! - # Monkeypatch around the nasty "2.5MB exception page" issue, caused by very large environment vars # This snippet via: http://stackoverflow.com/questions/3114993/exception-pages-in-development-mode-take-upwards-of-15-30-seconds-to-render-why # Relevant Rails ticket: https://rails.lighthouseapp.com/projects/8994/tickets/5027-_request_and_responseerb-and-diagnosticserb-take-an-increasingly-long-time-to-render-in-development-with-multiple-show-tables-calls diff --git a/config/routes.rb b/config/routes.rb index 78c7cf23f..80c19d166 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -53,7 +53,7 @@ Diaspora::Application.routes.draw do end - # get "tag_followings" => "tag_followings#index", :as => 'tag_followings' + get "tag_followings" => "tag_followings#index", :as => 'tag_followings' get 'tags/:name' => 'tags#show', :as => 'tag' diff --git a/lib/aspect_stream.rb b/lib/aspect_stream.rb index c12a7e9e4..b71cd82d2 100644 --- a/lib/aspect_stream.rb +++ b/lib/aspect_stream.rb @@ -54,6 +54,10 @@ class AspectStream @people ||= Person.all_from_aspects(aspect_ids, @user).includes(:profile) end + def link(opts={}) + Rails.application.routes.url_helpers.aspects_path(opts.merge(:a_ids => aspect_ids)) + end + # The first aspect in #aspects, given the stream is not for all aspects, or #aspects size is 1 # @note aspects.first is used for mobile. NOTE(this is a hack and should be fixed) # @return [Aspect,Symbol] @@ -67,6 +71,14 @@ class AspectStream for_all_aspects? end + def title + if self.for_all_aspects? + I18n.t('.stream') + else + self.aspects.to_sentence + end + end + # Determine whether or not the stream is displaying across # all of the user's aspects. # @@ -74,4 +86,12 @@ class AspectStream def for_all_aspects? @all_aspects ||= aspect_ids.length == @user.aspects.size end + + def contacts_title + if self.for_all_aspects? || self.aspect_ids.size > 1 + I18n.t('_contacts') + else + "#{self.aspect.name}(#{self.people.size})" + end + end end diff --git a/lib/tag_stream.rb b/lib/tag_stream.rb index 3ec31f303..2c421b2a9 100644 --- a/lib/tag_stream.rb +++ b/lib/tag_stream.rb @@ -14,31 +14,22 @@ class TagStream # @return [void] def initialize(user, opts={}) @tags = user.followed_tags - @tag_string = @tags.join(', '){|tag| tag.name}.to_sym + @tag_string = @tags.join(', '){|tag| tag.name} @user = user @max_time = opts[:max_time] @order = opts[:order] end - # Filters aspects given the stream's aspect ids on initialization and the user. - # Will disclude aspects from inputted aspect ids if user is not associated with their - # target aspects. - # - # @return [ActiveRecord::Association] Filtered aspects given the stream's user - def aspects - [@tag_string] + def link(opts={}) + Rails.application.routes.url_helpers.tag_followings_path(opts) end - # Maps ids into an array from #aspects - # - # @return [Array] Aspect ids - def aspect_ids - [] + def title + "Tag Stream" end # @return [ActiveRecord::Association] AR association of posts def posts - # NOTE(this should be something like Post.all_for_stream(@user, aspect_ids, {}) that calls visible_posts @posts ||= StatusMessage.tagged_with([@tag_string], :any => true) @@ -49,18 +40,24 @@ class TagStream @people ||= posts.map{|p| p.author}.uniq end - # The first aspect in #aspects, given the stream is not for all aspects, or #aspects size is 1 - # @note aspects.first is used for mobile. NOTE(this is a hack and should be fixed) - # @return [Aspect,Symbol] - def aspect - @tags_string + def for_all_aspects? + false + end + + def aspects + [] end - # Determine whether or not the stream is displaying across - # all of the user's aspects. - # - # @return [Boolean] - def for_all_aspects? - true + def aspect + nil end + + def contacts_title + "People who like #{@tag_string}" + end + + def aspect_ids + [] + end + end