diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9692cc778..ac0c983e2 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -98,27 +98,9 @@ class UsersController < ApplicationController @person = @user.person @profile = @user.profile @services = @user.services - service = current_user.services.where(:type => "Services::Facebook").first + @step = 0 - @step = ((params[:step].to_i>0)&&(params[:step].to_i<4)) ? params[:step].to_i : 1 - @step ||= 1 - - if @step == 2 && SERVICES['facebook']['app_id'] == "" - @step = 3 - end - - if @step == 3 - @friends = service ? service.finder(:local => true) : [] - @friends ||= [] - end - - if @step == 3 && @friends.length == 0 - @user.update_attributes(:getting_started => false) - flash[:notice] = I18n.t('users.getting_started.could_not_find_anyone') - redirect_to root_path - else - render "users/getting_started" - end + render "users/getting_started" end def getting_started_completed diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index df5646212..003b89a37 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -3,8 +3,40 @@ # the COPYRIGHT file. module UsersHelper - def first_name_or_username (user) - set_name = user.person.profile.first_name - (set_name.nil? || set_name.empty?) ? user.username : user.person.profile.first_name + + # @return [Boolean] The user has filled out all profile fields + def has_completed_profile? + profile = current_user.person.profile + [:full_name, :image_url, + :birthday, :gender, + :bio, :location, + :tag_string].map! do |attr| + return false if profile.send(attr).blank? + end + true + end + + # @return [Boolean] The user has connected at least one service + def has_connected_services? + AppConfig[:connected_services].blank? || current_user.services.size > 0 + end + + # @return [Boolean] The user has at least 3 contacts + def has_few_contacts? + current_user.contacts.receiving.size > 2 + end + + # @return [Boolean] The user has followed at least 3 tags + def has_few_followed_tags? + current_user.followed_tags.size > 2 + end + + # @return [Boolean] The user has connected to cubbi.es + def has_connected_cubbies? + end + + # @return [Boolean] The user has completed all steps in getting started + def has_completed_getting_started? + current_user.getting_started == false end end diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index e9c6bf482..ddd0e747a 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -12,10 +12,11 @@ %h3 = current_user.first_name - .section - %ul.left_nav - %li - = link_to "Welcome", getting_started_path, :class => "home_selector" + - unless has_completed_getting_started? + .section + %ul.left_nav + %li + = link_to "Welcome", getting_started_path, :class => "home_selector" .section = render 'aspects/aspect_listings' diff --git a/app/views/users/getting_started.html.haml b/app/views/users/getting_started.html.haml index 6b9896132..1339841d3 100644 --- a/app/views/users/getting_started.html.haml +++ b/app/views/users/getting_started.html.haml @@ -2,19 +2,17 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -- content_for :head do - = include_javascripts :home - .span-5.leftNavBar #home_user_badge = owner_image_link %h3 = current_user.first_name - .section - %ul.left_nav - %li - = link_to "Welcome", getting_started_path, :class => "home_selector active" + - unless has_completed_getting_started? + .section + %ul.left_nav + %li + = link_to "Welcome", getting_started_path, :class => "home_selector active" .section = render 'aspects/aspect_listings' @@ -28,10 +26,10 @@ = "Welcome, #{current_user.first_name}!" %ul#getting_started - %li.profile + %li.profile{:class => ("completed" if has_completed_profile?)} .getting_started_number %h3 - 1 + = @step += 1 .content #getting_started_profile_photo = person_image_link(current_user.person, :size => :thumb_medium) @@ -47,22 +45,23 @@ #edit_profile_button_div = link_to "Edit Profile", edit_profile_path, :class => "button" - %li.services - .getting_started_number - %h3 - 2 - .content - %h3 - = t('.connect_to_your_other_social_networks') - #getting_started_service_icons - - AppConfig.configured_services.each do |service| - - unless current_user.services.any?{|x| x.provider == service} - = link_to(image_tag("social_media_logos/#{service.downcase}-48x48.png", :title => service.titleize), "/auth/#{service}") + - unless AppConfig[:configured_services].blank? + %li.services{:class => ("completed" if has_connected_services?)} + .getting_started_number + %h3 + = @step += 1 + .content + %h3 + = t('.connect_to_your_other_social_networks') + #getting_started_service_icons + - AppConfig.configured_services.each do |service| + - unless current_user.services.any?{|x| x.provider == service} + = link_to(image_tag("social_media_logos/#{service.downcase}-48x48.png", :title => service.titleize), "/auth/#{service}") - %li + %li.connect_with_people{:class => ("completed" if has_few_contacts?)} .getting_started_number %h3 - 3 + = @step += 1 .content %h3 = t(".connect_with_people") @@ -108,17 +107,16 @@ #global_search = form_tag(people_path, :method => 'get', :id => "global_search_form") do = text_field_tag 'q', nil, :placeholder => "Search for people", :type => 'search', :results => 5 - .span-5.last - %p - or - = link_to "find friends from Facebook", "#" + .span-5.last{:style => "height:30px;"} + or + = link_to t('.find_friends_from_facebook'), friend_finder_path('facebook'), :rel => 'facebox' .clearfix %br - %li + %li.follow_interests{:class => ("completed" if has_few_followed_tags?)} .getting_started_number %h3 - 4 + = @step += 1 .content %h3 = t(".follow_your_interests") @@ -134,21 +132,21 @@ %h4 Featured tags %p - = link_to "#diaspora", "#" + = link_to "#diaspora", tag_path('diaspora') %br - = link_to "#kittens", "#" + = link_to "#kittens", tag_path('kittens') %br - = link_to "#puppies", "#" + = link_to "#puppies", tag_path('puppies') %br - = link_to "#maddog", "#" + = link_to "#maddog", tag_path('maddog') .clearfix %br %br - %li + %li.cubbies .getting_started_number %h3 - 5 + = @step += 1 .content %h3 = t(".connect_to") diff --git a/app/views/users/getting_started/_step_1.html.haml b/app/views/users/getting_started/_step_1.html.haml deleted file mode 100644 index 967e739f0..000000000 --- a/app/views/users/getting_started/_step_1.html.haml +++ /dev/null @@ -1,22 +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. - - -= form_tag profile_path, :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/app/views/users/getting_started/_step_2.html.haml b/app/views/users/getting_started/_step_2.html.haml deleted file mode 100644 index 900aa12f9..000000000 --- a/app/views/users/getting_started/_step_2.html.haml +++ /dev/null @@ -1,19 +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. - - -%br -%br -%br -%br -%br -%h3{:style => 'text-align: center;'} - = t('.find_your_friends_on_diaspora') - %br - %br - %br - = link_to image_tag('services/facebook_sign_in.png', :id => 'getting_started_logo', :width => 154, :height => 22), '/auth/facebook' - -.submit_block - = link_to "#{t('.skip')} →", getting_started_path(:step => @step+1), :class => 'button' diff --git a/app/views/users/getting_started/_step_3.html.haml b/app/views/users/getting_started/_step_3.html.haml deleted file mode 100644 index 267ece875..000000000 --- a/app/views/users/getting_started/_step_3.html.haml +++ /dev/null @@ -1,21 +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. -- content_for :head do - = include_javascripts :aspects - -%h3 - = t('.people_already_on_diaspora') - - %br - %br - -#people_stream.stream - - for friend in @friends - = render :partial => 'people/person', :locals => {:person => friend.person, :contact => friend.contact} - -%br -%br - -.submit_block - = link_to "#{t('.finish')} →", getting_started_completed_path, :class => 'button' diff --git a/config/initializers/fetch_featured_users.rb b/config/initializers/fetch_featured_users.rb index eba98d1cc..7029bec96 100644 --- a/config/initializers/fetch_featured_users.rb +++ b/config/initializers/fetch_featured_users.rb @@ -1,4 +1,4 @@ -unless AppConfig[:featured_users].count == Person.featured_users.count +unless Rails.env == 'test' || AppConfig[:featured_users].count == Person.featured_users.count puts "Fetching featured users from remote servers..." AppConfig[:featured_users].each do |x| Webfinger.new(x).fetch diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 72514cea1..6dfcd8963 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -794,6 +794,8 @@ en: follow_your_interests: "Follow your interests" connect_to: "Connect to" + find_friends_from_facebook: "find friends from Facebook" + profile_fields: name: "Name" birthday: "Birthday" diff --git a/public/images/icons/check_box_checked.svg b/public/images/icons/check_box_checked.svg new file mode 100755 index 000000000..8d829aeb4 --- /dev/null +++ b/public/images/icons/check_box_checked.svg @@ -0,0 +1,11 @@ + + + + + + diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index d44288b36..92ff9f0ab 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -3203,6 +3203,18 @@ ul#getting_started input[type='search'] :width 210px + &.completed + @include opacity(0.4) + @include transition(opacity, 0.2s) + + &:hover, + &:active + @include opacity(1) + + .content h3 + :text + :decoration line-through + .profile :min-height 170px @@ -3282,9 +3294,9 @@ ul#getting_started :padding :left 20px -.completed - :background - :image url('/images/icons/check_yes_ok.png') !important + &.completed + :background + :image url('/images/icons/check_yes_ok.png') !important #featured_users_pane :padding 10px 0 diff --git a/spec/factories.rb b/spec/factories.rb index abe0a7f85..a294c4362 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -16,7 +16,6 @@ Factory.define :profile do |p| p.birthday Date.today end - Factory.define :person do |p| p.sequence(:diaspora_handle) { |n| "bob-person-#{n}#{r_str}@aol.com" } p.sequence(:url) { |n| AppConfig[:pod_url] } diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb index 5e8562aac..83f9a5abf 100644 --- a/spec/helpers/users_helper_spec.rb +++ b/spec/helpers/users_helper_spec.rb @@ -4,18 +4,105 @@ require 'spec_helper' describe UsersHelper do - describe '#first_name_or_username' do + before do + @current_user = alice + end + + def current_user + @current_user + end + + describe "#has_completed_profile?" do + it 'returns true if the current user has filled out all 7 suggested fields (from getting started)' do + profile = @current_user.person.profile + profile.update_attributes!( + {:first_name => "alice", :last_name => "smith", :image_url => "abcd.jpg", :birthday => Date.new, + :gender => "cow", :location => "san fran", :tag_string => "#sup", :bio => "holler" }) + has_completed_profile?.should be_true + end + + it 'returns false if the current user has not filled out all 7 suggested fields (from getting started)' do + @current_user.update_attributes(:person => {:profile => + {:first_name => nil, :last_name => nil, :birthday => nil, :gender => nil }}) + has_completed_profile?.should be_false + end + end + + describe "#has_connected_services?" do before do - @user = alice + AppConfig[:connected_services] = ['fake_service'] end - it 'should display the first name if it is set' do - first_name_or_username(@user).should == @user.person.profile.first_name + it 'returns true if the current user has connected at least one service' do + @current_user.services << Factory.build(:service) + has_connected_services?.should be_true end - it 'should display the username if the first name is empty' do - @user.person.profile.first_name = "" - first_name_or_username(@user).should == @user.username + it 'returns true if the current user has zero connected services and the server has no services to connect' do + AppConfig[:connected_services] = [] + @current_user.services.delete_all + has_connected_services?.should be_true + end + + it 'returns false if the current user has not connected any service' do + @current_user.services.delete_all + has_connected_services?.should be_false + end + end + + describe "#has_few_contacts?" do + it 'returns true if the current_user has more than 2 contacts' do + 3.times do |n| + @current_user.contacts << Contact.new(:person => Factory(:person), :receiving => true) + end + has_few_contacts?.should be_true + end + + it 'returns false if the current_user has less than 2 contacts (inclusive)' do + @current_user.contacts.delete_all + has_few_contacts?.should be_false + end + end + + describe "has_few_followed_tags?" do + it 'returns true if the current_user has more than 2 contacts' do + 3.times do |n| + @current_user.followed_tags << ActsAsTaggableOn::Tag.new(:name => "poodles_#{n}") + end + has_few_followed_tags?.should be_true + end + + it 'returns false if the current_user has less than 2 contacts (inclusive)' do + @current_user.followed_tags.delete_all + has_few_followed_tags?.should be_false + end + end + + describe "#has_connected_cubbies?" do + before do + pending + end + + it 'returns true if the current user has connected cubbies to their account' do + has_connected_cubbies?.should be_true + end + + it 'returns false if the current user has not connected cubbies to their account' do + has_connected_cubbies?.should be_false + end + end + + describe "#has_completed_getting_started?" do + it 'returns true if the current user has completed getting started' do + @current_user.getting_started = false + @current_user.save + has_completed_getting_started?.should be_true + end + + it 'returns false if the current user has not completed getting started' do + @current_user.getting_started = true + @current_user.save + has_completed_getting_started?.should be_false end end end