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
|
class PeopleController < ApplicationController
|
||||||
before_filter :authenticate_user!, :except => [:show]
|
before_filter :authenticate_user!, :except => [:show]
|
||||||
|
|
||||||
respond_to :html
|
respond_to :html, :except => [:tag_index]
|
||||||
respond_to :json, :only => [:index, :show]
|
respond_to :json, :only => [:index, :show]
|
||||||
|
respond_to :js, :only => [:tag_index]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@aspect = :search
|
@aspect = :search
|
||||||
|
|
@ -33,12 +34,18 @@ class PeopleController < ApplicationController
|
||||||
else
|
else
|
||||||
people = Person.search(params[:q], current_user)
|
people = Person.search(params[:q], current_user)
|
||||||
end
|
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)
|
@hashes = hashes_for_people(@people, @aspects)
|
||||||
end
|
end
|
||||||
end
|
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
|
def hashes_for_people people, aspects
|
||||||
ids = people.map{|p| p.id}
|
ids = people.map{|p| p.id}
|
||||||
contacts = {}
|
contacts = {}
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ class TagsController < ApplicationController
|
||||||
render :partial => 'shared/stream', :locals => {:posts => @posts}
|
render :partial => 'shared/stream', :locals => {:posts => @posts}
|
||||||
else
|
else
|
||||||
profiles = Profile.tagged_with(params[:name]).where(:searchable => true).select('profiles.id, profiles.person_id')
|
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
|
@people_count = Person.where(:id => profiles.map{|p| p.person_id}).count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,11 @@
|
||||||
|
|
||||||
- content_for :head do
|
- content_for :head do
|
||||||
= include_javascripts :home
|
= include_javascripts :home
|
||||||
|
:javascript
|
||||||
|
$(".people_stream .pagination a").live("click", function() {
|
||||||
|
$.getScript(this.href);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
- content_for :body_class do
|
- content_for :body_class do
|
||||||
= "tags_show"
|
= "tags_show"
|
||||||
|
|
||||||
|
|
@ -32,21 +36,4 @@
|
||||||
= t('people', :count => @people_count)
|
= t('people', :count => @people_count)
|
||||||
|
|
||||||
.side_stream.stream
|
.side_stream.stream
|
||||||
- for person in @people
|
= render :partial => 'people/index', :locals => {:people => @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
|
|
||||||
\...
|
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ Diaspora::Application.routes.draw do
|
||||||
resources :aspect_memberships, :only => [:destroy, :create, :update]
|
resources :aspect_memberships, :only => [:destroy, :create, :update]
|
||||||
resources :post_visibilities, :only => [:update]
|
resources :post_visibilities, :only => [:update]
|
||||||
|
|
||||||
|
get 'people/tag_index' => 'people#tag_index'
|
||||||
resources :people, :except => [:edit, :update] do
|
resources :people, :except => [:edit, :update] do
|
||||||
resources :status_messages
|
resources :status_messages
|
||||||
resources :photos
|
resources :photos
|
||||||
|
|
@ -95,6 +96,8 @@ Diaspora::Application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Federation
|
# Federation
|
||||||
|
|
||||||
controller :publics do
|
controller :publics do
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,21 @@ describe PeopleController do
|
||||||
end
|
end
|
||||||
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
|
describe "#show performance", :performance => true do
|
||||||
before do
|
before do
|
||||||
require 'benchmark'
|
require 'benchmark'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue