Skip to content
Extraits de code Groupes Projets
Valider 1ef9d432 rédigé par Maxwell Salzberg's avatar Maxwell Salzberg
Parcourir les fichiers

added pagination for people on tag pages

parent 283e3767
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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'
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter