From c608c70ca7b96824a8e9c3786cd15dcdb40e4052 Mon Sep 17 00:00:00 2001
From: danielgrippi <daniel@joindiaspora.com>
Date: Tue, 15 Mar 2011 13:20:59 -0700
Subject: [PATCH] tagging profiles complete

---
 app/controllers/posts_controller.rb           |  3 ++
 app/controllers/profiles_controller.rb        | 16 +++++----
 app/models/profile.rb                         |  1 +
 app/views/aspects/_aspect_stream.haml         |  9 +++--
 app/views/layouts/_header.html.haml           |  5 ++-
 app/views/people/_person.html.haml            |  3 +-
 app/views/people/_profile_sidebar.html.haml   |  7 ----
 app/views/people/index.html.haml              |  2 --
 app/views/people/show.html.haml               |  4 ++-
 app/views/posts/index.html.haml               | 33 ++++++++++++++-----
 app/views/profiles/_edit.html.haml            | 31 +++++------------
 app/views/profiles/_edit_public.html.haml     | 22 +++++++++++++
 app/views/profiles/edit.html.haml             |  2 +-
 app/views/shared/_author_info.html.haml       |  2 +-
 app/views/shared/_stream.haml                 | 15 +++------
 app/views/users/edit.html.haml                | 10 +++---
 .../users/getting_started/_step_1.html.haml   | 21 +++++++++---
 config/locales/diaspora/en.yml                | 11 +++----
 features/accepts_invitation.feature           |  4 +--
 features/change_password.feature              |  4 +--
 features/closes_account.feature               |  4 +--
 features/edits_profile.feature                |  5 +--
 features/signs_up.feature                     |  2 +-
 public/stylesheets/sass/application.sass      | 30 +++++++++++++++--
 spec/models/profile_spec.rb                   |  5 +++
 25 files changed, 157 insertions(+), 94 deletions(-)
 create mode 100644 app/views/profiles/_edit_public.html.haml

diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index 330c5490ff..02d744b716 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -22,6 +22,9 @@ class PostsController < ApplicationController
     @posts = @posts.tagged_with(params[:tag])
     @posts = @posts.includes(:comments, :photos).paginate(:page => params[:page], :per_page => 15, :order => 'created_at DESC')
 
+    profiles = Profile.tagged_with(params[:tag]).select('profiles.id')
+    @people = Person.where(:id => profiles.map{|p| p.id}).limit(15)
+
     @fakes = PostsFake.new(@posts)
     @commenting_disabled = true
     @pod_url = AppConfig[:pod_uri].host
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index 79267c8cc2..5306ed1c4e 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -19,15 +19,19 @@ class ProfilesController < ApplicationController
 
     if current_user.update_profile params[:profile]
       flash[:notice] = I18n.t 'profiles.update.updated'
+      if params[:getting_started]
+        redirect_to getting_started_path(:step => params[:getting_started].to_i+1)
+      else
+        redirect_to current_user.person
+      end
     else
       flash[:error] = I18n.t 'profiles.update.failed'
+      if params[:getting_started]
+        redirect_to getting_started_path(:step => params[:getting_started])
+      else
+        redirect_to edit_profile_path
+      end
     end
 
-    if params[:getting_started]
-      redirect_to getting_started_path(:step => params[:getting_started].to_i+1)
-    else
-      redirect_to edit_profile_path
-    end
- 
   end
 end
diff --git a/app/models/profile.rb b/app/models/profile.rb
index 56a8ee28eb..82a51edd42 100644
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -12,6 +12,7 @@ class Profile < ActiveRecord::Base
 
   acts_as_taggable_on :tags
   extract_tags_from :tag_string
+  validates_length_of :tag_list, :maximum => 5
 
   xml_attr :diaspora_handle
   xml_attr :first_name
diff --git a/app/views/aspects/_aspect_stream.haml b/app/views/aspects/_aspect_stream.haml
index 0353c4ccf4..b4db9f0d4e 100644
--- a/app/views/aspects/_aspect_stream.haml
+++ b/app/views/aspects/_aspect_stream.haml
@@ -10,7 +10,10 @@
   |
   = link_to_if(session[:sort_order] == 'updated_at', t('.post_time'), aspects_path(:a_ids => params[:a_ids], :sort_order => 'created_at' ))
 #main_stream.stream{:data => {:guids => aspect_ids.join(',')}}
-  = render 'shared/stream', :posts => fakes
-  %a.paginate
-    = t("more")
+  - if posts.length > 0
+    = render 'shared/stream', :posts => fakes
+    %a.paginate
+      = t("more")
+  - else
+    = render 'aspects/no_posts_message', :post_count => posts.length
 = will_paginate posts
diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml
index 6e2ef5b293..7c205f3386 100644
--- a/app/views/layouts/_header.html.haml
+++ b/app/views/layouts/_header.html.haml
@@ -39,9 +39,8 @@
       .avatar
         = owner_image_tag(:thumb_small)
       = link_to current_user.name, '#'
-      %li= link_to t('.view_profile'), current_user.person
-      %li= link_to t('.edit_profile'), edit_profile_path
-      %li= link_to t('.account_settings'), edit_user_path(current_user)
+      %li= link_to t('.profile'), current_user.person
+      %li= link_to t('.settings'), edit_user_path(current_user)
       %li= link_to t('.logout'), destroy_user_session_path
 
     -unless @landing_page
diff --git a/app/views/people/_person.html.haml b/app/views/people/_person.html.haml
index 01dce70430..ce0aa80427 100644
--- a/app/views/people/_person.html.haml
+++ b/app/views/people/_person.html.haml
@@ -3,8 +3,7 @@
 -#   the COPYRIGHT file.
 
 .stream_element{:id => person.id}
-
-  .right{:style=>"display:inline;"}
+  .right
     - if person.owner_id == current_user.id
       = t('.thats_you')
     - elsif contact && !contact.pending
diff --git a/app/views/people/_profile_sidebar.html.haml b/app/views/people/_profile_sidebar.html.haml
index 8e4e84f01b..843fec32e3 100644
--- a/app/views/people/_profile_sidebar.html.haml
+++ b/app/views/people/_profile_sidebar.html.haml
@@ -37,13 +37,6 @@
 
   -if user_signed_in? && ((contact.persisted? && !contact.pending?) || person == current_user.person || @incoming_request)
     %ul#profile_information
-      - unless person.profile.tags.blank?
-        %li
-          %h4
-            tags
-          = person.profile.format_tags(person.profile.tag_string)
-
-
       - unless person.profile.bio.blank?
         %li
           %h4
diff --git a/app/views/people/index.html.haml b/app/views/people/index.html.haml
index f40c916953..4843cdc614 100644
--- a/app/views/people/index.html.haml
+++ b/app/views/people/index.html.haml
@@ -18,9 +18,7 @@
       %span.term
         = params[:q]
 
-
 .span-15.append-1
-
   - if @hashes.empty?
     %p
       =t('.no_one_found')
diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml
index 76f57b1b35..61cae69e97 100644
--- a/app/views/people/show.html.haml
+++ b/app/views/people/show.html.haml
@@ -56,8 +56,10 @@
 
     %h3
       = @person.name
-      .description
+      %span.diaspora_handle
         = @person.diaspora_handle
+      .description
+        = @person.profile.format_tags(@person.profile.tag_string)
   %hr
 
   - if @posts.count > 0
diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml
index 8e3362f36d..03f9a19066 100644
--- a/app/views/posts/index.html.haml
+++ b/app/views/posts/index.html.haml
@@ -2,22 +2,37 @@
 -#   licensed under the Affero General Public License version 3 or later.  See
 -#   the COPYRIGHT file.
 
+
 - content_for :page_title do
-  = t('.whatup', :pod => @pod_url)
+  - if params[:tag]
+    = "##{params[:tag]}"
 
+  - else
+    = t('.whatup', :pod => @pod_url)
 
 - content_for :head do
   = include_javascripts :home
 
-%h1
-  - if params[:tag]
-    = t('.posts_tagged_with', :tag => params[:tag])
-  - else
-    = t('.whatup', :pod => @pod_url)
+.span-24.last
+  %h1
+    - if params[:tag]
+      = "##{params[:tag]}"
+
+    - else
+      = t('.whatup', :pod => @pod_url)
 
 .span-15
   #main_stream.stream
-    = render 'shared/stream', :posts => @fakes
-    %a.paginate
-      = t("more")
+    - if @fakes.length > 0
+      = render 'shared/stream', :posts => @fakes
+      %a.paginate
+        = t("more")
+    - else
+      nobody likes ##{params[:tag]}.
   = will_paginate @posts
+
+.prepend-2.span-7.last
+  %h3
+    People tagged with ##{params[:tag]}
+  .side_stream
+    = render :collection => @people, :partial => 'people/person'
diff --git a/app/views/profiles/_edit.html.haml b/app/views/profiles/_edit.html.haml
index 909b0d29cb..ecae3400c9 100644
--- a/app/views/profiles/_edit.html.haml
+++ b/app/views/profiles/_edit.html.haml
@@ -6,17 +6,16 @@
   = t('.edit_profile')
 
 = form_tag profile_path(profile), :method => :put, :multipart => true, :id => 'update_profile_form' do
-  %h3
-    = t('profiles.edit.your_profile')
-    .description
-      = t('profiles.edit.info_available_to')
+  = render 'profiles/edit_public', :profile => profile, :aspect => aspect, :person => person
 
-  = error_messages_for profile
+  %hr
+  %br
+  %h3
+    = t('profiles.edit.your_private_profile')
 
   %h4
-    = t('profiles.edit.your_name')
-    = text_field_tag 'profile[first_name]', profile.first_name, :placeholder => t('profiles.edit.first_name')
-    = text_field_tag 'profile[last_name]', profile.last_name, :placeholder => t('profiles.edit.last_name')
+    = t('profiles.edit.your_bio')
+    = text_area_tag 'profile[bio]', profile.bio, :rows => 5, :placeholder => t('fill_me_out')
 
   %h4
     = t('profiles.edit.your_gender')
@@ -29,28 +28,14 @@
     = select_date profile.birthday, :prompt => true,
       :default => true, :order => t('date.order'), :start_year => 2000, :end_year => 1930, :prefix => 'profile[date]'
 
-  %h4
-    = t('profiles.edit.your_tags')
-    = text_field_tag 'profile[tags]', profile.tag_string, :placeholder => t('.your_tags_placeholder')
-
-  %h4
-    = t('profiles.edit.your_bio')
-    = text_area_tag 'profile[bio]', profile.bio, :rows => 5, :placeholder => t('fill_me_out')
-
-  %h4
-    = t('profiles.edit.your_photo')
-    = render 'photos/new_profile_photo', :aspect => aspect, :person => person
-    %b
-
   %h4
     = t('search')
     %p{:class=>"checkbox_select"}
       = label_tag 'profile[searchable]', t('profiles.edit.allow_search')
       = check_box_tag 'profile[searchable]', true, profile.searchable
 
-  = hidden_field_tag :getting_started, step if step
+  %br
 
   .submit_block
     =yield(:submit_block)
 
-
diff --git a/app/views/profiles/_edit_public.html.haml b/app/views/profiles/_edit_public.html.haml
new file mode 100644
index 0000000000..e92cff7090
--- /dev/null
+++ b/app/views/profiles/_edit_public.html.haml
@@ -0,0 +1,22 @@
+-#   Copyright (c) 2010, Diaspora Inc.  This file is
+-#   licensed under the Affero General Public License version 3 or later.  See
+-#   the COPYRIGHT file.
+
+%h3
+  = t('profiles.edit.your_public_profile')
+
+= error_messages_for profile
+
+%h4
+  = t('profiles.edit.your_name')
+  = text_field_tag 'profile[first_name]', profile.first_name, :placeholder => t('profiles.edit.first_name')
+  = text_field_tag 'profile[last_name]', profile.last_name, :placeholder => t('profiles.edit.last_name')
+
+%h4
+  = t('profiles.edit.your_tags')
+  = text_field_tag 'profile[tags]', profile.tag_string, :placeholder => t('profiles.edit.your_tags_placeholder')
+
+%h4
+  = t('profiles.edit.your_photo')
+  = render 'photos/new_profile_photo', :aspect => aspect, :person => person
+  %br
diff --git a/app/views/profiles/edit.html.haml b/app/views/profiles/edit.html.haml
index f3752c6928..7cd5b1c5c2 100644
--- a/app/views/profiles/edit.html.haml
+++ b/app/views/profiles/edit.html.haml
@@ -11,7 +11,7 @@
     %li=link_to t('account'), edit_user_path(current_user)
     %li=link_to t('_services'), services_path
 
-.span-19.prepend-5.last
+.span-12.prepend-5.last
   - content_for :submit_block do
     = link_to t('cancel'), edit_user_path(current_user)
     = t('or')
diff --git a/app/views/shared/_author_info.html.haml b/app/views/shared/_author_info.html.haml
index 8f2e7c3f0d..7e86d01fb9 100644
--- a/app/views/shared/_author_info.html.haml
+++ b/app/views/shared/_author_info.html.haml
@@ -5,5 +5,5 @@
       = person.name
 
     #person_nav_links
-      = link_to t('layouts.header.view_profile'), person_path(person)
+      = link_to t('layouts.header.profile'), person_path(person)
       = link_to t('_photos'), person_photos_path(person)
diff --git a/app/views/shared/_stream.haml b/app/views/shared/_stream.haml
index 78f68d2283..1b41adab56 100644
--- a/app/views/shared/_stream.haml
+++ b/app/views/shared/_stream.haml
@@ -3,14 +3,9 @@
 -#   the COPYRIGHT file.
 
 
-- if posts.length > 0
-  -# for post in posts
-    = render 'shared/stream_element', :post => post, :all_aspects => @all_aspects, :commenting_disabled => defined?(@commenting_disabled)
-  = render :partial => 'shared/stream_element',
-           :collection => posts,
-           :as => :post,
-           :locals => {:all_aspects => @all_aspects,
-             :commenting_disabled => defined?(@commenting_disabled)}
+= render :partial => 'shared/stream_element',
+         :collection => posts,
+         :as => :post,
+         :locals => {:all_aspects => @all_aspects,
+           :commenting_disabled => defined?(@commenting_disabled)}
 
-- else
-  = render 'aspects/no_posts_message', :post_count => posts.length
diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml
index 0d9660666f..4a67322efd 100644
--- a/app/views/users/edit.html.haml
+++ b/app/views/users/edit.html.haml
@@ -13,16 +13,16 @@
     %li=link_to t('account'), edit_user_path(current_user)
     %li=link_to t('_services'), services_path
 
-.span-19.prepend-5.last
+.span-12.prepend-5.last
   %h2
     = t('account')
 
-  .span-8.append-2
+  .span-5.append-1
     %h3
       = t('.your_handle')
     %p
       %b= current_user.diaspora_handle
-  .span-8.last
+  .span-5.last
     %h3
       = t('.your_email')
     %p
@@ -117,14 +117,14 @@
   %br
 
 
-  #account_data.span-9.append-2
+  #account_data.span-5.append-2
     %h3 
       = t('.export_data')
     = link_to t('.download_xml'), users_export_path, :class => "button"
     %br
     = link_to t('.download_photos'), users_export_photos_path, :class => "button"
 
-  .span-8.last
+  .span-5.last
     %h3 
       = t('.close_account')
     = link_to t('.close_account'), current_user,
diff --git a/app/views/users/getting_started/_step_1.html.haml b/app/views/users/getting_started/_step_1.html.haml
index 45a6652540..c4f5ba3d41 100644
--- a/app/views/users/getting_started/_step_1.html.haml
+++ b/app/views/users/getting_started/_step_1.html.haml
@@ -2,8 +2,21 @@
 -#   licensed under the Affero General Public License version 3 or later.  See
 -#   the COPYRIGHT file.
 
-- content_for :submit_block do
-  = submit_tag "#{t('users.getting_started.save_and_continue')} →"
-= render :partial => 'profiles/edit', :locals => {:person => @person, 
-    :profile => @profile, :aspect => @aspect, :step => @step}
 
+= form_tag profile_path(@profile), :method => :put, :multipart => true, :id => 'update_profile_form' do
+  %div{:style => "width:360px"}
+    = render 'profiles/edit_public', :profile => @profile, :aspect => @aspect, :person => @person
+    = hidden_field_tag :getting_started, @step
+
+    %h4
+      = t('search')
+      %p{:class=>"checkbox_select"}
+        = label_tag 'profile[searchable]', t('profiles.edit.allow_search')
+        = check_box_tag 'profile[searchable]', true, @profile.searchable
+
+    %br
+    %br
+    %br
+
+  .submit_block
+    = submit_tag "#{t('users.getting_started.save_and_continue')} →"
diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml
index 2cd0cbd224..9ca74abe9e 100644
--- a/config/locales/diaspora/en.yml
+++ b/config/locales/diaspora/en.yml
@@ -246,9 +246,8 @@ en:
 
   layouts:
     header:
-      view_profile: "view profile"
-      edit_profile: "edit profile"
-      account_settings: "account settings"
+      profile: "profile"
+      settings: "settings"
       logout: "logout"
       blog: "blog"
       login: "login"
@@ -402,15 +401,15 @@ en:
 
   profiles:
     edit:
-      info_available_to: "This info will be available to whomever you connect with on Diaspora."
-      your_profile: "Your profile"
+      your_public_profile: "Your public profile"
+      your_private_profile: "Your private profile"
       your_name: "Your name"
       first_name: "First name"
       last_name: "Last name"
       your_gender: "Your gender"
       your_birthday: "Your birthday"
       your_tags: "You: in 5 tags"
-      your_tags_placeholder: "i.e. #ironing #knitting #kittens #knees #doors"
+      your_tags_placeholder: "i.e. #diaspora #ironing #kittens #music"
       your_bio: "Your bio"
       your_photo: "Your photo"
       update_profile: "Update Profile"
diff --git a/features/accepts_invitation.feature b/features/accepts_invitation.feature
index 57df807510..feea31cb6f 100644
--- a/features/accepts_invitation.feature
+++ b/features/accepts_invitation.feature
@@ -12,7 +12,7 @@ Feature: invitation acceptance
       And I should see "getting_started_logo"
      When I fill in "profile_first_name" with "O"
       And I fill in "profile_last_name" with "Hai"
-      And I fill in "profile_gender" with "guess!"
+      And I fill in "profile_tags" with "#beingawesome"
       And I press "Save and continue"
       Then I should see "Profile updated"
 			And I should see "Would you like to find your Facebook friends on Diaspora?"
@@ -30,7 +30,7 @@ Feature: invitation acceptance
       And I should see "getting_started_logo"
      When I fill in "profile_first_name" with "O"
       And I fill in "profile_last_name" with "Hai"
-      And I fill in "profile_gender" with "guess!"
+      And I fill in "profile_tags" with "#tags"
       And I press "Save and continue"
       Then I should see "Profile updated"
       
diff --git a/features/change_password.feature b/features/change_password.feature
index 8c1709b98a..0ee3bc4336 100644
--- a/features/change_password.feature
+++ b/features/change_password.feature
@@ -4,7 +4,7 @@ Feature: Change password
   Scenario: Change my password
   	Given I am signed in
     And I click on my name in the header
-    And I follow "account settings"
+    And I follow "settings"
     Then I should be on my account settings page
     When I put in my password in "user_current_password" 
     And I fill in "user_password" with "newsecret"
@@ -15,4 +15,4 @@ Feature: Change password
     And I follow "logout"
     Then I should be on the home page    
     And I sign in with password "newsecret"
-    Then I should be on the aspects page
\ No newline at end of file
+    Then I should be on the aspects page
diff --git a/features/closes_account.feature b/features/closes_account.feature
index b83bf1f74d..6ee0b04197 100644
--- a/features/closes_account.feature
+++ b/features/closes_account.feature
@@ -7,7 +7,7 @@ Feature: Close Account
   Scenario: user closes account
     Given I am signed in
     When I click on my name in the header
-    And I follow "account settings"
+    And I follow "settings"
     And I click ok in the confirm dialog to appear next
     And I follow "Close Account"
     Then I should be on the home page
@@ -30,7 +30,7 @@ Feature: Close Account
     And I log out
     Then I sign in as "bob@bob.bob"
     When I click on my name in the header
-    And I follow "account settings"
+    And I follow "settings"
     And I click ok in the confirm dialog to appear next
     And I follow "Close Account"
     Then I sign in as "alice@alice.alice"
diff --git a/features/edits_profile.feature b/features/edits_profile.feature
index af353794ed..41a3261210 100644
--- a/features/edits_profile.feature
+++ b/features/edits_profile.feature
@@ -4,7 +4,8 @@ Feature: editing your profile
   Background:
     Given I am signed in
     And I click on my name in the header
-    And I follow "edit profile"
+    And I follow "profile"
+    And I follow "Edit my profile"
     Then I should be on my edit profile page
 
   Scenario: editing gender with a textbox
@@ -39,4 +40,4 @@ Feature: editing your profile
     And I should see "Profile updated"
     And I click on my name in the header
     And I follow "view profile"  
-    Then I should see "November 30 1986"
\ No newline at end of file
+    Then I should see "November 30 1986"
diff --git a/features/signs_up.feature b/features/signs_up.feature
index c7d11b3499..bd925dc674 100644
--- a/features/signs_up.feature
+++ b/features/signs_up.feature
@@ -14,7 +14,7 @@ Feature: new user registration
   Scenario: new user goes through the setup wizard
    When I fill in "profile_first_name" with "O"
     And I fill in "profile_last_name" with "Hai"
-    And I fill in "profile_gender" with "guess!"
+    And I fill in "profile_tags" with "#gender"
     And I press "Save and continue"
     And I wait for "step 2" to load
     Then I should see "Profile updated"
diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass
index f969aff726..4c37d3b371 100644
--- a/public/stylesheets/sass/application.sass
+++ b/public/stylesheets/sass/application.sass
@@ -9,7 +9,7 @@ $background: rgb(252,252,252)
 body
   :padding 2em
   :margin 0
-    :top 50px
+    :top 60px
   :background-color $background
 a
   :color #107FC9
@@ -327,6 +327,8 @@ header
   h4,
   h5
     :display inline-block
+    :margin
+      :bottom 10px
 
   &.show
     a
@@ -781,7 +783,7 @@ textarea
     :size 14px
   :padding 0.3em
   :display block
-  :width 66%
+  :width 100%
   :border 1px solid #ccc
   :height auto
 
@@ -2744,3 +2746,27 @@ ul.show_comments
 
 #contact_visibility_padlock:hover
   :opacity 0.7
+
+.side_stream
+  .avatar
+    :float left
+  .right
+    :display none
+
+  .stream_element:hover
+    .right
+      :display none
+
+.tag
+  :background
+    :color lighten($blue, 47%)
+  :font
+    :weight bold
+
+.diaspora_handle
+  :font
+    :size 12px
+    :weight normal
+  :color #999
+  :margin
+    :left 6px
diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb
index 0e70e8991b..9684a18e7b 100644
--- a/spec/models/profile_spec.rb
+++ b/spec/models/profile_spec.rb
@@ -151,6 +151,11 @@ describe Profile do
       person = Factory.create(:person)
       @object = person.profile
     end
+    it 'allows 5 tags' do
+      @object.tag_string = '#one #two #three #four #five #six'
+      @object.build_tags
+      @object.valid?.should be_false
+    end
     it_should_behave_like 'it is taggable'
   end
 
-- 
GitLab