diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 4e31975a624c00854f6df7c761b88ba2641aa3da..996ead2ff520effbdb362441ab3850f974537f16 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -15,10 +15,10 @@ class PeopleController < ApplicationController end def show - @aspect = :profile @person = Person.find(params[:id].to_id) - + @post_type = :all + if @person @profile = @person.profile @contact = current_user.contact_for(@person) @@ -31,7 +31,9 @@ class PeopleController < ApplicationController end @posts = current_user.visible_posts(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC' - respond_with @person + respond_with @person, :locals => {:post_type => :all} + + else flash[:error] = I18n.t 'people.show.does_not_exist' redirect_to people_path diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 8a71518cfa1cc3b009cfb4b8a7078de8d63cf8b1..780f17b5b0bfcc3c719749ae270c2bd5a26abe4c 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -9,16 +9,28 @@ class PhotosController < ApplicationController respond_to :json, :only => :show def index - if params[:person_id] - @person = current_user.contact_for_person_id(params[:person_id]) - @person = @person.person if @person + @aspect = :profile + @post_type = :photos + @person = Person.find(params[:person_id].to_id) + + if @person + @profile = @person.profile + @contact = current_user.contact_for(@person) + @is_contact = @person != current_user.person && @contact + + if @contact + @aspects_with_person = @contact.aspects + else + @pending_request = current_user.pending_requests.find_by_person_id(@person.id) + end + + @posts = current_user.visible_posts(:_type => 'Photo', :person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC' + render 'people/show' + else - @person = current_user.person + flash[:error] = I18n.t 'people.show.does_not_exist' + redirect_to people_path end - - @photos = current_user.visible_posts(:_type => "Photo", :person_id => @person.id) - - @aspect = :photos end def create @@ -85,7 +97,7 @@ class PhotosController < ApplicationController if @photo = current_user.my_posts.where(:_id => params[:id]).first respond_with @photo else - redirect_to photos_path + redirect_to person_photos_path(current_user.person) end end @@ -100,7 +112,7 @@ class PhotosController < ApplicationController redirect_to [:edit, photo] end else - redirect_to photos_path + redirect_to person_photos_path(current_user.person) end end diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 475a68784a71d930c6a13699693eebbe58007fc2..3f7911162ad2893d14e4b403def98345961d54c6 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -21,6 +21,33 @@ class StatusMessagesController < ApplicationController render :nothing => true end + + def index + @aspect = :profile + @post_type = :status_message + + @person = Person.find(params[:person_id].to_id) + + if @person + @profile = @person.profile + @contact = current_user.contact_for(@person) + @is_contact = @person != current_user.person && @contact + + if @contact + @aspects_with_person = @contact.aspects + else + @pending_request = current_user.pending_requests.find_by_person_id(@person.id) + end + + @posts = current_user.visible_posts(:_type => 'StatusMessage', :person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC' + render 'people/show' + + else + flash[:error] = I18n.t 'people.show.does_not_exist' + redirect_to people_path + end + end + def destroy @status_message = current_user.my_posts.where(:_id => params[:id]).first if @status_message diff --git a/app/views/people/_profile_sidebar.haml b/app/views/people/_profile_sidebar.html.haml similarity index 100% rename from app/views/people/_profile_sidebar.haml rename to app/views/people/_profile_sidebar.html.haml diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index e95948ababfe8a559883b52b25798cb10abbb3dd..b0b53ae18c874226df178bc9fd645d05d89979c1 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -4,14 +4,17 @@ .span-4.append-1.last - = render 'profile_sidebar', :person => @person, :is_contact => @is_contact + = render :partial => 'people/profile_sidebar', :locals => {:person => @person, :is_contact => @is_contact} .span-15.last = render 'shared/author_info', :person => @person - if @contact || current_user.person == @person - if @posts.count > 0 - = render 'shared/stream', :posts => @posts + -if @post_type == :photos + = render 'photos/index', :photos => @posts + - else + = render 'shared/stream', :posts => @posts = will_paginate @posts - else diff --git a/app/views/photos/_index.html.haml b/app/views/photos/_index.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..fc53d91f7f093260970df86a4e12b57b71381b9d --- /dev/null +++ b/app/views/photos/_index.html.haml @@ -0,0 +1,23 @@ +-# 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 + :javascript + $(document).ready(function(){ + $(".image_thumb img").load( function() { + $(this).fadeIn("slow"); + }); + }); + +.span-24.last + #thumbnails + - for photo in photos + .image_thumb + = link_to (image_tag photo.url(:thumb_medium)), photo_path(photo) + +/.span-24.last +/ #add_photo_pane +/ = render "photos/new_photo", :aspect_id => :all + diff --git a/app/views/photos/index.html.haml b/app/views/photos/index.html.haml deleted file mode 100644 index dc9fb9a9ac48959351c896911469a0eb69cb3586..0000000000000000000000000000000000000000 --- a/app/views/photos/index.html.haml +++ /dev/null @@ -1,27 +0,0 @@ --# Copyright (c) 2010, Diaspora Inc. This file is --# licensed under the Affero General Public License version 3 or later. See --# the COPYRIGHT file. - -:javascript - $(document).ready(function(){ - $(".image_thumb img").load( function() { - $(this).fadeIn("slow"); - }); - }); - - -.span-24.last{:style=>"position:relative;"} - = render 'shared/author_info', :person => @person - %ul#breadcrumb - %li= link_to "#{@person.profile.first_name}'s Photos", person_photos_path(@person) - -.span-24.last - #thumbnails - - for photo in @photos - .image_thumb - = link_to (image_tag photo.url(:thumb_medium)), photo_path(photo) - -.span-24.last - #add_photo_pane - = render "photos/new_photo", :aspect_id => :all - diff --git a/app/views/shared/_author_info.html.haml b/app/views/shared/_author_info.html.haml index 39f91c89d041451b2ba0298a4a24b55ecedc4891..fa63ede455d3645efac63c556d5bde85567f2c72 100644 --- a/app/views/shared/_author_info.html.haml +++ b/app/views/shared/_author_info.html.haml @@ -15,4 +15,4 @@ #person_nav_links = link_to t('.view_profile'), person_path(person) = link_to t('_photos'), person_photos_path(person) - = link_to 'status messages', person_photos_path(person) + = link_to 'status messages', person_status_messages_path(person) diff --git a/app/views/status_messages/index.html.haml b/app/views/status_messages/index.html.haml deleted file mode 100644 index 9bbd93abfce479a4cab1352bd03d36c6e9c7a11c..0000000000000000000000000000000000000000 --- a/app/views/status_messages/index.html.haml +++ /dev/null @@ -1,13 +0,0 @@ --# Copyright (c) 2010, Diaspora Inc. This file is --# licensed under the Affero General Public License version 3 or later. See --# the COPYRIGHT file. - -%h1.big_text status messages -= render "status_messages/new_status_message", :status_message => @status_message -%ul#stream - - - for status_message in @status_messages - = render "status_message", :post => status_message -#pagination - = will_paginate @status_messages - diff --git a/config/routes.rb b/config/routes.rb index 05461014a25a6e728d1bf76fe6551628968417b2..4b637aa90c5f93d7264615cbf7027ad384abaa9b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,9 +7,15 @@ Diaspora::Application.routes.draw do resources :status_messages, :only => [:create, :destroy, :show] resources :comments, :except => [:index] resources :requests, :except => [:edit, :update] - resources :photos + resources :photos, :except => [:index] resources :services + resources :people do + resources :status_messages + resources :photos + end + + match '/auth/:provider/callback' => 'services#create' devise_for :users, :controllers => {:registrations => "registrations", diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 02440e8ab04a8b56519f4c9d145b7cfc01f7ad62..8d310f82613412479f747c3cca4477f6e4b92917 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -36,21 +36,21 @@ describe PhotosController do describe '#index' do it 'defaults to returning all of users pictures' do - get :index + get :index, :person_id => user.person.id.to_s assigns[:person].should == user.person - assigns[:photos].should == [photo] + assigns[:posts].should == [photo] end it 'sets the person to a friend if person_id is set' do get :index, :person_id => user2.person.id.to_s assigns[:person].should == user2.person - assigns[:photos].should == [] + assigns[:posts].should == [] end - it 'sets the aspect to photos?' do - get :index - assigns[:aspect].should == :photos + it 'sets the aspect to profile' do + get :index, :person_id => user.person.id.to_s + assigns[:aspect].should == :profile end end @@ -73,7 +73,7 @@ describe PhotosController do it 'should not let you edit a photo that is not yours' do get :edit, :id => photo2.id - response.should redirect_to(:action => :index) + response.should redirect_to(:action => :index, :person_id => user.person.id.to_s) end end @@ -106,7 +106,8 @@ describe PhotosController do it 'should redirect if you do not have access to the post' do params = { :caption => "now with lasers!"} put :update, :id => photo2.id, :photo => params - response.should redirect_to(:action => :index) + response.should redirect_to(:action => :index, :person_id => user.person.id.to_s) + end end end