From 7472642bd1d56b9a01ae6ee379536406701ae19e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20Rodr=C3=ADguez?= Date: Wed, 6 Feb 2013 19:14:48 -0200 Subject: [PATCH 1/4] Refactor: *people_controller#show *photos_controller#index *views/people/show both html and mobile --- app/controllers/people_controller.rb | 9 --------- app/controllers/photos_controller.rb | 8 +------- app/views/people/show.html.haml | 6 +++--- app/views/people/show.mobile.haml | 11 +---------- 4 files changed, 5 insertions(+), 29 deletions(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index a7ea9541d..c54f8ef17 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -82,27 +82,18 @@ class PeopleController < ApplicationController @post_type = :all @aspect = :profile - @share_with = (params[:share_with] == 'true') - @stream = Stream::Person.new(current_user, @person, :max_time => max_time) - @profile = @person.profile unless params[:format] == "json" # hovercard if current_user @block = current_user.blocks.where(:person_id => @person.id).first @contact = current_user.contact_for(@person) - @aspects_with_person = [] if @contact && !params[:only_posts] - @aspects_with_person = @contact.aspects - @aspect_ids = @aspects_with_person.map(&:id) @contacts_of_contact_count = @contact.contacts.count @contacts_of_contact = @contact.contacts.limit(8) - else @contact ||= Contact.new - @contacts_of_contact_count = 0 - @contacts_of_contact = [] end end end diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 319bb5187..186b96435 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -12,23 +12,17 @@ class PhotosController < ApplicationController @person = Person.find_by_guid(params[:person_id]) if @person - @profile = @person.profile @contact = current_user.contact_for(@person) - @is_contact = @person != current_user.person && @contact - @aspects_with_person = [] if @contact - @aspects_with_person = @contact.aspects @contacts_of_contact = @contact.contacts @contacts_of_contact_count = @contact.contacts.count else @contact = Contact.new - @contacts_of_contact = [] - @contacts_of_contact_count = 0 end @posts = current_user.photos_from(@person) - + respond_to do |format| format.all { render 'people/show' } format.json{ render_for_api :backbone, :json => @posts, :root => :photos } diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index a2b18ca21..bd305550b 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -15,14 +15,14 @@ .span-6 = 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-5.last#contacts_of_contact .section.contact_pictures %h4 = t('contacts', :count => @contacts_of_contact_count) - - for person in @contacts_of_contact + - @contacts_of_contact.each do |person| = person_image_link person - - if @contacts_of_contact.count > 8 + - if @contacts_of_contact_count > 8 %p.see_all= link_to t('.see_all'), person_contacts_path(@person) .span-18.last diff --git a/app/views/people/show.mobile.haml b/app/views/people/show.mobile.haml index 28cf9a18b..f6d7254ba 100644 --- a/app/views/people/show.mobile.haml +++ b/app/views/people/show.mobile.haml @@ -15,18 +15,9 @@ %span.description = @person.diaspora_handle - - if user_signed_in? && !(@contact.persisted? || current_user.person == @person) - - if @incoming_request - .floating - %h3 - = t('.incoming_request', :name => @person.name) - %h4 - = link_to t('.return_to_aspects'), aspects_manage_path - = t('.to_accept_or_ignore') - .span12 - if @stream.stream_posts.length > 0 - -if @post_type == :photos + - if @post_type == :photos = render 'photos/index', :photos => @stream.stream_posts - else #main_stream.stream From e76935daafadd91820dbc5f1654d205f1a7b7098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20Rodr=C3=ADguez?= Date: Wed, 6 Feb 2013 19:18:00 -0200 Subject: [PATCH 2/4] remove inline styles from views/people/show --- app/assets/stylesheets/application.css.sass | 1 + app/views/people/show.html.haml | 4 ++-- app/views/people/show.mobile.haml | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/application.css.sass b/app/assets/stylesheets/application.css.sass index d69500018..afafe2504 100644 --- a/app/assets/stylesheets/application.css.sass +++ b/app/assets/stylesheets/application.css.sass @@ -988,6 +988,7 @@ ul#settings_nav .dull :color #aaa + :text-align center :font :style italic diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index bd305550b..06ec889e0 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -31,8 +31,8 @@ #main_stream.stream - if @block.present? - %div{:style=>"text-align:center;", :class => "dull"} + .dull = t('.ignoring', :name => @person.first_name) - + #paginate %span.loader.hidden diff --git a/app/views/people/show.mobile.haml b/app/views/people/show.mobile.haml index f6d7254ba..afdaafe2b 100644 --- a/app/views/people/show.mobile.haml +++ b/app/views/people/show.mobile.haml @@ -26,10 +26,9 @@ %a.more-link.paginate{:href => next_page_path} %h1 = t("more") - - else #main_stream - %div{:style=>"text-align:center;", :class => "dull"} + .dull - if user_signed_in? && (current_user.person != @person) = t('.has_not_shared_with_you_yet', :name => @person.first_name) From c1eb986f5bb8a0054506fd9b196899d6cdb60c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20Rodr=C3=ADguez?= Date: Fri, 8 Feb 2013 21:22:12 -0200 Subject: [PATCH 3/4] remove unnecessary code from people_controller#contacts and use #each in view --- app/controllers/people_controller.rb | 2 -- app/views/people/contacts.haml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index c54f8ef17..3115f1f1b 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -146,8 +146,6 @@ class PeopleController < ApplicationController @aspect = :profile @contacts_of_contact = @contact.contacts.paginate(:page => params[:page], :per_page => (params[:limit] || 15)) @hashes = hashes_for_people @contacts_of_contact, @aspects - @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 diff --git a/app/views/people/contacts.haml b/app/views/people/contacts.haml index 1c7b302d3..c53f15781 100644 --- a/app/views/people/contacts.haml +++ b/app/views/people/contacts.haml @@ -16,6 +16,6 @@ = render 'people/sub_header', :person => @person, :contact => @contact #people_stream.stream - - for hash in @hashes + - @hashes.each do |hash| = render :partial => 'people/person', :locals => hash = will_paginate @contacts_of_contact From eb8e777873e3b541196553d661bb2b401ed3f0b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabi=C3=A1n=20Rodr=C3=ADguez?= Date: Sun, 24 Feb 2013 12:24:35 -0200 Subject: [PATCH 4/4] update changelog --- Changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Changelog.md b/Changelog.md index 207b81ef7..f8dd4c210 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Head +## Refactor + +* Refactor people_controller#show and photos_controller#index [#4002](https://github.com/diaspora/diaspora/issues/4002) + ## Features * Deleting a post that was shared to Facebook now deletes it from Facebook too [#3980]( https://github.com/diaspora/diaspora/pull/3980)