added pagination for people on tag pages
This commit is contained in:
parent
283e376712
commit
1ef9d43262
5 changed files with 34 additions and 22 deletions
|
|
@ -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 = {}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
Loading…
Reference in a new issue