Merge branch 'limit_similar_contacts'

Conflicts:
	app/controllers/people_controller.rb
This commit is contained in:
Raphael Sofaer 2011-04-12 11:48:41 -07:00
commit d5ecce7ca6
7 changed files with 102 additions and 6 deletions

View file

@ -80,10 +80,12 @@ class PeopleController < ApplicationController
if @contact && !params[:only_posts] if @contact && !params[:only_posts]
@aspects_with_person = @contact.aspects @aspects_with_person = @contact.aspects
@aspect_ids = @aspects_with_person.map(&:id) @aspect_ids = @aspects_with_person.map(&:id)
@contacts_of_contact = @contact.contacts @contacts_of_contact_count = @contact.contacts.count
@contacts_of_contact = @contact.contacts.limit(36)
else else
@contact ||= Contact.new @contact ||= Contact.new
@contacts_of_contact_count = 0
@contacts_of_contact = [] @contacts_of_contact = []
end end
@ -120,6 +122,22 @@ class PeopleController < ApplicationController
end end
end end
def contacts
@person = Person.find(params[:id])
if @person
@contact = current_user.contact_for(@person)
@aspect = :profile
@contacts_of_contact = @contact.contacts.paginate(:page => params[:page], :per_page => (params[:limit] || 15))
@hashes = hashes_for_people @contacts_of_contact, @aspects
@incoming_request = current_user.request_from(@person)
@contact = current_user.contact_for(@person)
@aspects_with_person = @contact.aspects
@aspect_ids = @aspects_with_person.map(&:id)
else
flash[:error] = I18n.t 'people.show.does_not_exist'
redirect_to people_path
end
end
private private
def webfinger(account, opts = {}) def webfinger(account, opts = {})
Resque.enqueue(Job::SocketWebfinger, current_user.id, account, opts) Resque.enqueue(Job::SocketWebfinger, current_user.id, account, opts)

View file

@ -0,0 +1,59 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
- content_for :head do
= include_javascripts :people
- content_for :page_title do
= @person.name
.span-8.append-1.last
= render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact }
.span-15.last
#author_info
- if user_signed_in? && !(@contact.persisted? || current_user.person == @person)
.right
- if @incoming_request
= link_to t('.incoming_request', :name => truncate(@person.name, :length => 20, :separator => ' ', :omission => '')),
{:controller => "contacts",
:action => "new",
:person_id => @person.id},
:class => 'share_with button',
:rel => 'facebox'
-else
= link_to t('.start_sharing'),
{:controller => "contacts",
:action => "new",
:person_id => @person.id},
:class => 'share_with button',
:rel => 'facebox'
- if @share_with
= javascript_tag "$(document).ready(function() {jQuery.facebox({ ajax: '#{new_contact_path(:person_id => @person.id)}' });});"
- else
- if user_signed_in? && @contact.person && @contact.pending? == false
.right
= link_to t('people.show.mention'), new_status_message_path(:person_id => @person.id), :class => 'button', :rel => 'facebox'
= link_to t('people.show.message'), new_conversation_path(:contact_id => @contact.id, :name => @contact.person.name, :contact_id => @contact.id), :class => 'button', :rel => 'facebox'
%h3
= @person.name
%span.diaspora_handle
= @person.diaspora_handle
.description
- if !@person.profile.tag_string.blank?
= @person.profile.format_tags(@person.profile.tag_string)
- if user_signed_in? && @person == current_user.person
%span.hover_edit
= link_to t('.edit'), edit_profile_path
%hr
#people_stream.stream
- for hash in @hashes
= render :partial => 'people/person', :locals => hash
= will_paginate @contacts_of_contact

View file

@ -13,14 +13,16 @@
= render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact } = render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact }
- if user_signed_in? && @contact.persisted? && @contacts_of_contact.count > 0 - if user_signed_in? && @contact.persisted? && @contacts_of_contact.count > 0
.span-8.last .span-8.last#contacts_of_contact
%hr{:style=>"width:300px;"} %hr{:style=>"width:300px;"}
.section.contact_pictures .section.contact_pictures
%h4 %h4
= @contacts_of_contact.length = @contacts_of_contact_count
= t('.similar_contacts') = t('.contacts_of_contact')
- for person in @contacts_of_contact - for person in @contacts_of_contact
= person_image_link person = person_image_link person
- if @contacts_of_contact.count > 25
%p.see_all= link_to t('.see_all'), person_path(@person)
.span-15.last .span-15.last
#author_info #author_info

View file

@ -1,4 +1,4 @@
# Copyright (c) 2010, Diaspora Inc. This file is #.see_ Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
@ -371,7 +371,8 @@ en:
not_connected: "You are not sharing with this person" not_connected: "You are not sharing with this person"
recent_posts: "Recent Posts" recent_posts: "Recent Posts"
recent_public_posts: "Recent Public Posts" recent_public_posts: "Recent Public Posts"
similar_contacts: "similar contacts" contacts_of_contact: "contacts"
see_all: "See all"
start_sharing: "start sharing" start_sharing: "start sharing"
message: "Message" message: "Message"
mention: "Mention" mention: "Mention"

View file

@ -41,6 +41,7 @@ Diaspora::Application.routes.draw do
get :export get :export
get :export_photos get :export_photos
end end
match '/people/:id/contacts' => 'people#contacts'
controller :users do controller :users do
get 'public/:username' => :public, :as => 'users_public' get 'public/:username' => :public, :as => 'users_public'

View file

@ -2814,3 +2814,10 @@ h1.tag
:width 12px :width 12px
:height 12px :height 12px
:margin-left 0.5em :margin-left 0.5em
#contacts_of_contact
.section
:margin
:bottom 4px
.see_all
:text-align center

View file

@ -239,6 +239,14 @@ describe PeopleController do
end end
end end
end end
describe '#contacts' do
it 'assigns the contacts of a person' do
contact = alice.contact_for(bob.person)
contacts = contact.contacts
get :contacts, :id => bob.person.id
assigns(:contacts_of_contact).should == contacts
end
end
describe '#webfinger' do describe '#webfinger' do
it 'enqueues a webfinger job' do it 'enqueues a webfinger job' do