diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 9f0863713..f25d5a543 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -5,8 +5,9 @@ class PeopleController < ApplicationController before_filter :authenticate_user!, :except => [:show] - respond_to :html + respond_to :html, :except => [:tag_index] respond_to :json, :only => [:index, :show] + respond_to :js, :only => [:tag_index] def index @aspect = :search @@ -33,12 +34,18 @@ class PeopleController < ApplicationController else people = Person.search(params[:q], current_user) end - @people = people.paginate :page => params[:page], :per_page => limit + @people = people.paginate( :page => params[:page], :per_page => 15) @hashes = hashes_for_people(@people, @aspects) end end end + def tag_index + profiles = Profile.tagged_with(params[:name]).where(:searchable => true).select('profiles.id, profiles.person_id') + @people = Person.where(:id => profiles.map{|p| p.person_id}).paginate(:page => params[:page], :per_page => 15) + respond_with @people + end + def hashes_for_people people, aspects ids = people.map{|p| p.id} contacts = {} diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 85e30a34b..145914856 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -65,7 +65,7 @@ class TagsController < ApplicationController render :partial => 'shared/stream', :locals => {:posts => @posts} else profiles = Profile.tagged_with(params[:name]).where(:searchable => true).select('profiles.id, profiles.person_id') - @people = Person.where(:id => profiles.map{|p| p.person_id}).limit(15) + @people = Person.where(:id => profiles.map{|p| p.person_id}).paginate(:page => params[:page], :per_page => 15) @people_count = Person.where(:id => profiles.map{|p| p.person_id}).count end end diff --git a/app/views/tags/show.haml b/app/views/tags/show.haml index dd545a56e..ee681076c 100644 --- a/app/views/tags/show.haml +++ b/app/views/tags/show.haml @@ -10,7 +10,11 @@ - content_for :head do = include_javascripts :home - + :javascript + $(".people_stream .pagination a").live("click", function() { + $.getScript(this.href); + return false; + }); - content_for :body_class do = "tags_show" @@ -32,21 +36,4 @@ = t('people', :count => @people_count) .side_stream.stream - - for person in @people - .stream_element{:id => person.id} - = person_image_link(person) - - if current_user - - contact = current_user.contacts.find_by_person_id(person.id) - - contact ||= Contact.new(:person => person) - - unless person == current_user.person - .right - = render 'aspect_memberships/aspect_dropdown', :contact => contact, :person => person, :hang => 'left' - - .content - %span.from - =person_link(person) - .info - = person.profile.format_tags(person.profile.tag_string) - - - if @people_count > 15 - \... + = render :partial => 'people/index', :locals => {:people => @people} diff --git a/config/routes.rb b/config/routes.rb index 8b4772333..76be54cba 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -87,6 +87,7 @@ Diaspora::Application.routes.draw do resources :aspect_memberships, :only => [:destroy, :create, :update] resources :post_visibilities, :only => [:update] + get 'people/tag_index' => 'people#tag_index' resources :people, :except => [:edit, :update] do resources :status_messages resources :photos @@ -95,6 +96,8 @@ Diaspora::Application.routes.draw do end + + # Federation controller :publics do diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 8788f18a9..2339897fd 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -74,6 +74,21 @@ describe PeopleController do end end + describe '#tag_index' do + it 'works for js' do + get :tag_index, :name => 'jellybeans', :format => :js + response.should be_success + end + + it 'returns awesome people who have that tag' do + f = Factory(:person) + f.profile.tag_string = "#seeded" + f.profile.save + get :tag_index, :name => 'seeded', :format => :js + assigns[:people].count.should == 1 + end + end + describe "#show performance", :performance => true do before do require 'benchmark'