diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index fbacc7ff0..cbf77afee 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -109,6 +109,22 @@ class PeopleController < ApplicationController 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 def webfinger(account, opts = {}) Resque.enqueue(Job::SocketWebfinger, current_user.id, account, opts) diff --git a/app/views/people/contacts.haml b/app/views/people/contacts.haml new file mode 100644 index 000000000..9c0b74a75 --- /dev/null +++ b/app/views/people/contacts.haml @@ -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 diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index d70723fca..15f76de7d 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -13,14 +13,16 @@ = render :partial => 'people/profile_sidebar', :locals => {:person => @person, :contact => @contact } - if user_signed_in? && @contact.persisted? && @contacts_of_contact.count > 0 - .span-8.last + .span-8.last#contacts_of_contact %hr{:style=>"width:300px;"} .section.contact_pictures %h4 = @contacts_of_contact_count - = t('.similar_contacts') + = t('.contacts_of_contact') - for person in @contacts_of_contact = person_image_link person + - if @contacts_of_contact.count > 25 + %p.see_all= link_to t('.see_all'), person_path(@person) .span-15.last #author_info diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index eaae01dd2..7b3ca015a 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -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 # the COPYRIGHT file. @@ -363,7 +363,8 @@ en: not_connected: "You are not sharing with this person" recent_posts: "Recent Posts" recent_public_posts: "Recent Public Posts" - similar_contacts: "similar contacts" + contacts_of_contact: "contacts" + see_all: "See all" start_sharing: "start sharing" message: "Message" mention: "Mention" diff --git a/config/routes.rb b/config/routes.rb index 7a7a1a2c9..cf20934d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,6 +37,7 @@ Diaspora::Application.routes.draw do resources :status_messages resources :photos end + match '/people/:id/contacts' => 'people#contacts' match '/people/by_handle' => 'people#retrieve_remote', :as => 'person_by_handle' match '/auth/:provider/callback' => 'services#create' diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 41331bb38..9c1444ade 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -2800,3 +2800,10 @@ h1.tag :width 12px :height 12px :margin-left 0.5em + +#contacts_of_contact + .section + :margin + :bottom 4px + .see_all + :text-align center diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 73d18d99d..6594da764 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -208,6 +208,14 @@ describe PeopleController do 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 it 'enqueues a webfinger job' do