diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index 22499dfde..0ced97b09 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -37,6 +37,17 @@ class ContactsController < ApplicationController render :layout => false end + def featured + @featured = true + @people = [] + if diaspora_ids = AppConfig[:featured_users] + @people = diaspora_ids.inject [] do |people, id| + person = Webfinger.new(id).fetch + people << person unless person.blank? + end + end + end + private def sort_and_paginate_profiles contacts diff --git a/app/views/aspects/_aspect_listings.haml b/app/views/aspects/_aspect_listings.haml index edf27e7c6..82a7237cf 100644 --- a/app/views/aspects/_aspect_listings.haml +++ b/app/views/aspects/_aspect_listings.haml @@ -3,7 +3,7 @@ -# the COPYRIGHT file. %ul#aspect_nav.left_nav - %li.all_aspects{:class => ("active" if params["set"] != "all" && params["set"] != "only_sharing")} + %li.all_aspects{:class => ("active" if params["set"] != "all" && params["set"] != "only_sharing" && !defined?(@featured))} %a.home_selector{:href => controller_index_path, :class => ("sub_selected" if params["a_id"])} .contact_count = my_contacts_count diff --git a/app/views/aspects/_no_posts_message.haml b/app/views/aspects/_no_posts_message.haml index 4440aff1b..66e89231b 100644 --- a/app/views/aspects/_no_posts_message.haml +++ b/app/views/aspects/_no_posts_message.haml @@ -3,7 +3,11 @@ -# the COPYRIGHT file. #no_posts.empty_message{:class => ("hidden" unless post_count == 0)} - %h4 - = t('.start_talking') - = link_to t('.try_adding_some_more_contacts'), contacts_path + %h4{:style => "text-align:center;"} + = t('.you_have_no_contacts') + %br + %br + = t('.try_adding_some_more_contacts') + != t('.or_featured', :link => link_to(t(".featured_users") , featured_path)) + diff --git a/app/views/contacts/featured.haml b/app/views/contacts/featured.haml new file mode 100644 index 000000000..b3e9b4f0c --- /dev/null +++ b/app/views/contacts/featured.haml @@ -0,0 +1,37 @@ +-# 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 :page_title do + = t('.featured_users') + +- content_for :head do + = include_javascripts :people + +#section_header + %h2 + = t('contacts.index.title') + += render 'shared/contact_sidebar' + +.span-18.last + %h3 + = t('.featured_users') + %br + + #featured_users + - @people.each do |person| + .user_card + = person_image_link(person, :size => :thumb_large) + %h4 + = person.name + + .tags + - 5.times do |n| + - person.profile.tags.each do |tg| + = "##{tg}" + + .add_user_to_aspect + = render :partial => 'people/relationship_action', + :locals => { :person => person, :contact => current_user.contact_for(person), + :current_user => current_user } diff --git a/app/views/contacts/index.html.haml b/app/views/contacts/index.html.haml index e6d73ad94..f6273a7c3 100644 --- a/app/views/contacts/index.html.haml +++ b/app/views/contacts/index.html.haml @@ -2,21 +2,17 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - - content_for :page_title do = t('.title') - content_for :head do = include_javascripts :people - - #section_header %h2 = t('.title') -.span-5.append-1 - = render 'aspects/aspect_listings' += render 'shared/contact_sidebar' .span-18.last #people_stream.stream.contacts diff --git a/app/views/shared/_contact_sidebar.html.haml b/app/views/shared/_contact_sidebar.html.haml new file mode 100644 index 000000000..bdc9fca08 --- /dev/null +++ b/app/views/shared/_contact_sidebar.html.haml @@ -0,0 +1,17 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +.span-5.append-1 + = render 'aspects/aspect_listings' + + %hr + + %ul.left_nav + - if AppConfig[:featured_users] + %li{:class => ("active" if defined?(@featured))} + = link_to t('contacts.featured.featured_users'), "/featured", :class => "element_selector" + /%li + / = link_to "Invite friends", "#", :class => "element_selector" + + diff --git a/config/application.yml.example b/config/application.yml.example index ddd115f98..9ab506ff5 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -131,7 +131,11 @@ defaults: &defaults single_process_mode: true # Use paypal for recurring donations - paypal_hosted_button_id: '' + paypal_hosted_button_id: "" + + # Featured users + # (expressed as an array of Diaspora IDs) + featured_users: # Use this section to override default settings in specific environments development: diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 849621c8c..a97f6ee7a 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -111,7 +111,10 @@ en: edit_aspect: "edit aspect" no_posts_message: start_talking: "Nobody has said anything yet!" - try_adding_some_more_contacts: "Try adding some more contacts." + you_have_no_contacts: "You haven't added any contacts yet!" + try_adding_some_more_contacts: "You can search (top) or invite (right) more contacts." + or_featured: "Or you can share with %{link}" + featured_users: "featured users" aspect_listings: add_an_aspect: "+ Add an aspect" @@ -220,6 +223,8 @@ en: only_sharing_with_me: "Only sharing with me" remove_person_from_aspect: "Remove %{person_name} from \"%{aspect_name}\"" many_people_are_you_sure: "Are you sure you want to start a private conversation with more than %{suggested_limit} contacts? Posting to this aspect may be a better way to contact them." + featured: + featured_users: "Featured Users" conversations: index: diff --git a/config/routes.rb b/config/routes.rb index 6080af18e..6f16d6967 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -101,6 +101,7 @@ Diaspora::Application.routes.draw do resources :aspect_memberships, :only => [:destroy, :create, :update] resources :post_visibilities, :only => [:update] + get 'featured' => "contacts#featured" resources :people, :except => [:edit, :update] do resources :status_messages resources :photos diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 04539c543..b64c543c7 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -2870,7 +2870,8 @@ ul.left_nav a.aspect_selector, a.home_selector, - a.tag_selector + a.tag_selector, + a.element_selector &:active :cursor -webkit-grabbing :cursor -moz-grabbing @@ -2879,6 +2880,7 @@ ul.left_nav a.aspect_selector, a.home_selector, a.tag_selector, + a.element_selector, .root_element :display block :width 100% @@ -2889,7 +2891,8 @@ ul.left_nav a.aspect_selector, a.home_selector, - a.tag_selector + a.tag_selector, + a.element_selector &:hover @include border-radius(2px) @@ -3154,3 +3157,44 @@ ul.left_nav :margin :top 30px +#featured_users + .avatar + :height 140px + :width 140px + +.user_card + @include border-radius(3px) + @include box-shadow(0,1px,5px,#ccc) + :padding 10px + :bottom 30px + :margin + :bottom 15px + :right 10px + + :position relative + + :min-height 220px + + :vertical-align top + + :border 1px solid #ccc + :display inline-block + + :width 140px + + .tags + :color #999 + + h4 + :margin + :bottom 0 + :padding + :bottom 2px + + .dropdown + :width 100% + +.add_user_to_aspect + :bottom 12px + :right 5px + :position absolute diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index 6b7e73735..3a0ec81fa 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -325,4 +325,28 @@ describe PeopleController do get :retrieve_remote, :diaspora_handle => @user.diaspora_handle end end + + describe '#featued' do + it 'succeeds' do + get :featured + response.should be_success + end + + it 'gets queries for users in the app config' do + AppConfig[:featured_users] = [alice.diaspora_handle] + + get :featured + assigns[:people].should == [alice.person] + end + + it 'fetches the webfinger profiles' do + AppConfig[:featured_users] = [alice.diaspora_handle] + + wf = mock + wf.should_receive(:fetch) + Webfinger.should_receive(:new).with(alice.diaspora_handle).and_return(wf) + + get :featured + end + end end