diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index 22499dfdef3aadbc539d13878430381dbbbaf3e4..0ced97b09b2c3354936159286ffd4102e0be55a9 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 edf27e7c64bd919117d8d7405f377200c1ce096a..82a7237cfe130ab106f708f5a3a83c57ccc0193b 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 4440aff1b0f95c5daefd743681a22c2cb3e68189..66e89231b5bdb2871148996baa1789929be4993f 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 0000000000000000000000000000000000000000..b3e9b4f0c1be526e07fba92e1caa0f32fbd92134 --- /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 e6d73ad94335974758f6716e8437091180031170..f6273a7c32705fb9ce2233a0f0fe8bc2dc41eafa 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 0000000000000000000000000000000000000000..bdc9fca085865ed385a78e8f01c3316ee0def8ab --- /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 ddd115f98a4e09d2380b42b15fff7f00c49b56eb..9ab506ff5b96b5180d8551559d5f03c38ba16fdb 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 849621c8c362d2f7c07d1a2e6a92ddef5c79b997..a97f6ee7ab3d11250c3a91a5d77705c7dd10701e 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 6080af18eb1ec53fb3587d007e116a98e9c6b8f1..6f16d69671629b8e7a592de9977c5cd79fd7341f 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 04539c543a28370c8e333f7d89e749f0b6db032b..b64c543c77fa190fe16e3d51982dafab3660786b 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 6b7e73735d48b8db7d40f0a2c3080d638d656ab7..3a0ec81fadf5ca9d9f79019268ab164722b1952c 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