From 44b58d707fd8ac954b7543df8a5b21a6b2242cd0 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Thu, 20 Oct 2011 11:50:49 -0700 Subject: [PATCH] featured users => community spotlight --- .../community_spotlight_controller.rb | 7 +++++ app/controllers/contacts_controller.rb | 6 ++-- app/controllers/featured_users_controller.rb | 7 ----- app/helpers/application_helper.rb | 2 +- app/helpers/stream_helper.rb | 4 +-- app/models/person.rb | 4 +-- app/views/aspects/_no_contacts_message.haml | 2 +- .../_user.html.haml | 0 app/views/contacts/_aspect_listings.haml | 2 +- app/views/contacts/index.html.haml | 2 +- .../{featured.haml => spotlight.haml} | 4 +-- app/views/shared/_contact_sidebar.html.haml | 6 ++-- app/views/shared/_right_sections.html.haml | 6 ++-- app/views/users/getting_started.haml | 8 ++--- config/application.yml.example | 4 +-- config/initializers/fetch_featured_users.rb | 6 ++-- config/locales/diaspora/en.yml | 10 +++---- config/routes.rb | 4 +-- lib/stream/base.rb | 12 ++++---- lib/stream/community_spotlight.rb | 29 +++++++++++++++++++ lib/stream/featured_users.rb | 29 ------------------- lib/stream/soup.rb | 12 ++++---- public/stylesheets/sass/application.sass | 4 +-- ...=> community_spotlight_controller_spec.rb} | 4 +-- spec/controllers/contacts_controller_spec.rb | 8 ++--- spec/helpers/application_helper_spec.rb | 4 +-- ...ed_spec.rb => community_spotlight_spec.rb} | 4 +-- spec/models/person_spec.rb | 12 ++++---- 28 files changed, 100 insertions(+), 102 deletions(-) create mode 100644 app/controllers/community_spotlight_controller.rb delete mode 100644 app/controllers/featured_users_controller.rb rename app/views/{featured_users => community_spotlight}/_user.html.haml (100%) rename app/views/contacts/{featured.haml => spotlight.haml} (85%) create mode 100644 lib/stream/community_spotlight.rb delete mode 100644 lib/stream/featured_users.rb rename spec/controllers/{featured_users_controller_spec.rb => community_spotlight_controller_spec.rb} (80%) rename spec/lib/stream/{featured_spec.rb => community_spotlight_spec.rb} (57%) diff --git a/app/controllers/community_spotlight_controller.rb b/app/controllers/community_spotlight_controller.rb new file mode 100644 index 000000000..837d77bdb --- /dev/null +++ b/app/controllers/community_spotlight_controller.rb @@ -0,0 +1,7 @@ +require File.join(Rails.root, 'lib', 'stream', 'community_spotlight') + +class CommunitySpotlightController < ApplicationController + def index + default_stream_action(Stream::CommunitySpotlight) + end +end diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index 450b00b1a..a35902b81 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -38,9 +38,9 @@ class ContactsController < ApplicationController render :layout => false end - def featured - @featured = true - @people = Person.featured_users + def spotlight + @spotlight = true + @people = Person.community_spotlight end private diff --git a/app/controllers/featured_users_controller.rb b/app/controllers/featured_users_controller.rb deleted file mode 100644 index e5cc606d6..000000000 --- a/app/controllers/featured_users_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -require File.join(Rails.root, 'lib', 'stream', 'featured_users') - -class FeaturedUsersController < ApplicationController - def index - default_stream_action(Stream::FeaturedUsers) - end -end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fd7bef727..87c9cd862 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -64,7 +64,7 @@ module ApplicationHelper if current_user.contacts.size > 0 contacts_path else - featured_users_path + community_spotlight_path end end diff --git a/app/helpers/stream_helper.rb b/app/helpers/stream_helper.rb index 9f4d0d502..32acba7d1 100644 --- a/app/helpers/stream_helper.rb +++ b/app/helpers/stream_helper.rb @@ -12,8 +12,8 @@ module StreamHelper person_path(@person, :max_time => @posts.last.created_at.to_i) elsif controller.instance_of?(TagFollowingsController) tag_followings_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) - elsif controller.instance_of?(FeaturedUsersController) - featured_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) + elsif controller.instance_of?(CommunitySpotlightController) + spotlight_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) elsif controller.instance_of?(MentionsController) mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) elsif controller.instance_of?(SoupsController) diff --git a/app/models/person.rb b/app/models/person.rb index 23d748c92..9606c4515 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -61,8 +61,8 @@ class Person < ActiveRecord::Base scope :profile_tagged_with, lambda{|tag_name| joins(:profile => :tags).where(:profile => {:tags => {:name => tag_name}}).where('profiles.searchable IS TRUE') } - def self.featured_users - AppConfig[:featured_users].present? ? Person.where(:diaspora_handle => AppConfig[:featured_users]) : [] + def self.community_spotlight + AppConfig[:community_spotlight].present? ? Person.where(:diaspora_handle => AppConfig[:community_spotlight]) : [] end # Set a default of an empty profile when a new Person record is instantiated. diff --git a/app/views/aspects/_no_contacts_message.haml b/app/views/aspects/_no_contacts_message.haml index a4a0e052b..30aa0d3bd 100644 --- a/app/views/aspects/_no_contacts_message.haml +++ b/app/views/aspects/_no_contacts_message.haml @@ -7,5 +7,5 @@ %br %br = t('.try_adding_some_more_contacts') - != t('.or_featured', :link => link_to(t(".featured_users") , featured_users_path)) + != t('.or_spotlight', :link => link_to(t(".community_spotlight") , community_spotlight_path)) diff --git a/app/views/featured_users/_user.html.haml b/app/views/community_spotlight/_user.html.haml similarity index 100% rename from app/views/featured_users/_user.html.haml rename to app/views/community_spotlight/_user.html.haml diff --git a/app/views/contacts/_aspect_listings.haml b/app/views/contacts/_aspect_listings.haml index ed0f17802..2cc8dd481 100644 --- a/app/views/contacts/_aspect_listings.haml +++ b/app/views/contacts/_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" && !@featured && !@finder)} + %li.all_aspects{:class => ("active" if params["set"] != "all" && params["set"] != "only_sharing" && !@spotlight && !@finder)} %a.home_selector{:href => contacts_path, :class => ("sub_selected" if params["a_id"])} = t('contacts.index.my_contacts') .contact_count diff --git a/app/views/contacts/index.html.haml b/app/views/contacts/index.html.haml index fd10ce84d..4f67435e0 100644 --- a/app/views/contacts/index.html.haml +++ b/app/views/contacts/index.html.haml @@ -60,7 +60,7 @@ %br %br = t('.check_out') - = link_to t('contacts.spotlight.community_spotlight'), featured_users_path + = link_to t('contacts.spotlight.community_spotlight'), community_spotlight_path - if @aspect or = link_to t('.add_to_aspect', :name => @aspect.name).downcase, edit_aspect_path(@aspect), :rel => "facebox" diff --git a/app/views/contacts/featured.haml b/app/views/contacts/spotlight.haml similarity index 85% rename from app/views/contacts/featured.haml rename to app/views/contacts/spotlight.haml index 5285491ee..54918e6fa 100644 --- a/app/views/contacts/featured.haml +++ b/app/views/contacts/spotlight.haml @@ -19,7 +19,7 @@ = t('contacts.spotlight.community_spotlight') %br - #featured_users + #community_spotlight - unless @people.blank? - @people.each do |person| - = render 'featured_users/user', :person => person + = render 'community_spotlight/user', :person => person diff --git a/app/views/shared/_contact_sidebar.html.haml b/app/views/shared/_contact_sidebar.html.haml index 27ef1ac60..a506cd122 100644 --- a/app/views/shared/_contact_sidebar.html.haml +++ b/app/views/shared/_contact_sidebar.html.haml @@ -8,9 +8,9 @@ %hr %ul.left_nav - - if AppConfig[:featured_users] - %li{:class => ("active" if @featured)} - = link_to t('users.getting_started.featured_users'), featured_users_path, :class => "element_selector" + - if AppConfig[:community_spotlight] + %li{:class => ("active" if @spotlight)} + = link_to t('users.getting_started.community_spotlight'), community_spotlight_path, :class => "element_selector" %li{:class => ("active" if @finder)} = link_to "Facebook Friends", friend_finder_path('facebook'), :class => "element_selector" diff --git a/app/views/shared/_right_sections.html.haml b/app/views/shared/_right_sections.html.haml index 736667f19..8fc62600a 100644 --- a/app/views/shared/_right_sections.html.haml +++ b/app/views/shared/_right_sections.html.haml @@ -69,13 +69,13 @@ .content != t('bookmarklet.explanation', :link => link_to(t('bookmarklet.explanation_link_text'), bookmarklet)) -- if @stream.has_featured_users? +- if @stream.has_communtiy_spotlight? .section .title.no_icon %h5 =t('aspects.index.community_spotlight') - .content#featured_users - = link_to t('aspects.index.see_more_from_us'), featured_path, :id => 'view_all_contacts_link' + .content#community_spotlight + = link_to t('aspects.index.see_more_from_us'), spotlight_path, :id => 'view_all_contacts_link' - unless AppConfig[:paypal_hosted_button_id].blank? .section diff --git a/app/views/users/getting_started.haml b/app/views/users/getting_started.haml index 1f5cbd217..79ead984b 100644 --- a/app/views/users/getting_started.haml +++ b/app/views/users/getting_started.haml @@ -106,12 +106,12 @@ :contact => current_user.contact_for(diasporahq), :current_user => current_user } - #featured_users_pane + #community_spotlight_pane %h4 - = t('.featured_users') + = t('.community_spotlight') %div - - Person.featured_users[0..5].each do |person| + - Person.community_spotlight[0..5].each do |person| .featured_user_card_small .right .add_to_aspect @@ -125,7 +125,7 @@ - person.profile.tags[0..2].each do |tg| = link_to "##{tg}", tag_path(tg.name), :target => "_blank" - = link_to "#{t('.see_all_featured_users')} ->", featured_users_path, :target => "_blank" + = link_to "#{t('.see_all_community_spotlight')} ->", community_spotlight_path, :target => "_blank" %br #find_friends_pane diff --git a/config/application.yml.example b/config/application.yml.example index 222ef90da..557dd1c6c 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -60,9 +60,9 @@ defaults: &defaults # to contact joindiaspora.com, set this to true: no_follow_diasporahq: false - # Featured users + # Community Spotlight # (expressed as an array of Diaspora IDs) - featured_users: + community_spotlight: - 'diasporahq@joindiaspora.com' # List of users who have admin privileges diff --git a/config/initializers/fetch_featured_users.rb b/config/initializers/fetch_featured_users.rb index edf576304..c53ab20ff 100644 --- a/config/initializers/fetch_featured_users.rb +++ b/config/initializers/fetch_featured_users.rb @@ -1,8 +1,8 @@ #this breaks seed scripts -unless !ActiveRecord::Base.connection.table_exists?('people') || Rails.env == 'test' || AppConfig[:featured_users].nil? || AppConfig[:featured_users].count == Person.featured_users.count - print "Fetching featured users from remote servers" - AppConfig[:featured_users].each do |x| +unless !ActiveRecord::Base.connection.table_exists?('people') || Rails.env == 'test' || AppConfig[:community_spotlight].nil? || AppConfig[:community_spotlight].count == Person.community_spotlight.count + print "Fetching community spotlight users from remote servers" + AppConfig[:community_spotlight].each do |x| Webfinger.new(x).fetch print "." end diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 04c65c798..410e312d0 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -117,15 +117,15 @@ en: no_contacts_message: you_should_add_some_more_contacts: "You should add some more contacts!" 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" + or_spotlight: "Or you can share with %{link}" + community_spotlight: "community spotlight" aspect_listings: select_all: "Select all" deselect_all: "Deselect all" edit_aspect: "Edit %{name}" add_an_aspect: "+ Add an aspect" selected_contacts: - view_all_featured_users: "See all Featured Users" + view_all_communtiy_spotlight: "See all community spotlight" view_all_contacts: "View all contacts" no_contacts: "You don't have any contacts here yet." manage_your_aspects: "Manage your aspects." @@ -908,7 +908,7 @@ en: search_for_hashtags: "Search for #hashtags" search_for_people: "Search for people" connect_with_people_explanation_pt2: "Aspects are an intuitive way to group new and familar faces, private to you, allowing you to filter down or share with subsets of your contacts easily." - featured_users: "Featured users" + community_spotlight: "Community spotlight" follow_your_interests: "Follow your interests" connect_to: "Connect to" @@ -916,7 +916,7 @@ en: find_friends_from_facebook: "find friends from Facebook" featured_tags: "Follow featured tags" find_friends: "Find friends" - see_all_featured_users: "See all featured users" + see_all_community_spotlight: "See all community spotlight" get_updates_from_core: "Get updates about the project from the core team." hashtag_explanation: "Hashtags allow you to talk about and follow your interests. They're also a great way to find new people on Diaspora." diff --git a/config/routes.rb b/config/routes.rb index 63981046b..a2769e779 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -109,9 +109,9 @@ Diaspora::Application.routes.draw do resources :aspect_memberships, :only => [:destroy, :create, :update] resources :share_visibilities, :only => [:update] - get 'featured' => 'featured_users#index', :as => 'featured' + get 'spotlight' => 'community_spotlight#index', :as => 'spotlight' - get 'featured_users' => "contacts#featured", :as => 'featured_users' + get 'community_spotlight' => "contacts#spotlight", :as => 'community_spotlight' get 'soup' => "soups#index", :as => 'soup' diff --git a/lib/stream/base.rb b/lib/stream/base.rb index 5717ea329..37f1b2690 100644 --- a/lib/stream/base.rb +++ b/lib/stream/base.rb @@ -9,13 +9,13 @@ class Stream::Base end # @return [Person] - def random_featured_user - @random_featured_user ||= Person.find_by_diaspora_handle(featured_diaspora_id) + def random_community_spotlight_member + @random_community_spotlight_member ||= Person.find_by_diaspora_handle(spotlight_diaspora_id) end # @return [Boolean] - def has_featured_users? - random_featured_user.present? + def has_communtiy_spotlight? + random_community_spotlight_member.present? end #requied to implement said stream @@ -111,8 +111,8 @@ class Stream::Base @contacts_in_stream ||= Contact.where(:user_id => user.id, :person_id => people.map{|x| x.id}).all end - def featured_diaspora_id - @featured_diaspora_id ||= AppConfig[:featured_users].try(:sample, 1) + def spotlight_diaspora_id + @spotlight_diaspora_id ||= AppConfig[:community_spotlight].try(:sample, 1) end # @param post [Post] diff --git a/lib/stream/community_spotlight.rb b/lib/stream/community_spotlight.rb new file mode 100644 index 000000000..dee1ed33a --- /dev/null +++ b/lib/stream/community_spotlight.rb @@ -0,0 +1,29 @@ +class Stream::CommunitySpotlight < Stream::Base + def title + "Community Spotlight doing cool stuff!" + end + + def link(opts={}) + Rails.application.routes.url_helpers.spotlight_path(opts) + end + + def contacts_title + "This week's community spotlight" + end + + def contacts_link + Rails.application.routes.url_helpers.community_spotlight_path + end + + def contacts_link_title + I18n.translate('aspects.selected_contacts.view_all_community_spotlight') + end + + def posts + Post.all_public.where(:author_id => people.map{|x| x.id}).for_a_stream(max_time, order) + end + + def people + Person.community_spotlight + end +end diff --git a/lib/stream/featured_users.rb b/lib/stream/featured_users.rb deleted file mode 100644 index d4e1a7447..000000000 --- a/lib/stream/featured_users.rb +++ /dev/null @@ -1,29 +0,0 @@ -class Stream::FeaturedUsers < Stream::Base - def title - "Featured users doing cool stuff!" - end - - def link(opts={}) - Rails.application.routes.url_helpers.featured_path(opts) - end - - def contacts_title - "This week's featured users" - end - - def contacts_link - Rails.application.routes.url_helpers.featured_users_path - end - - def contacts_link_title - I18n.translate('aspects.selected_contacts.view_all_featured_users') - end - - def posts - Post.all_public.where(:author_id => people.map{|x| x.id}).for_a_stream(max_time, order) - end - - def people - Person.featured_users - end -end diff --git a/lib/stream/soup.rb b/lib/stream/soup.rb index 29438b4c9..df4f04fed 100644 --- a/lib/stream/soup.rb +++ b/lib/stream/soup.rb @@ -14,7 +14,7 @@ class Stream::Soup < Stream::Base def posts @posts ||= lambda do post_ids = aspect_posts_ids + followed_tag_ids + mentioned_post_ids - post_ids += featured_user_post_ids if include_featured_users? + post_ids += community_spotlight_post_ids if include_community_spotlight? Post.where(:id => post_ids).for_a_stream(max_time, order) end.call end @@ -25,7 +25,7 @@ class Stream::Soup < Stream::Base private - def include_featured_users? + def include_community_spotlight? false end @@ -41,13 +41,13 @@ class Stream::Soup < Stream::Base @mentioned_post_ids ||= ids(StatusMessage.where_person_is_mentioned(user.person).for_a_stream(max_time, order)) end - def featured_user_post_ids - @featured_user_post_ids ||= ids(Post.all_public.where(:author_id => featured_user_ids).for_a_stream(max_time, order)) + def community_spotlight_post_ids + @community_spotlight_post_ids ||= ids(Post.all_public.where(:author_id => community_spotlight_person_ids).for_a_stream(max_time, order)) end #worthless helpers - def featured_user_ids - Person.featured_users.select('id').map{|x| x.id} + def community_spotlight_person_ids + Person.community_spotlight.select('id').map{|x| x.id} end def tag_array diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 0e9390a41..abbad7ea4 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -3152,7 +3152,7 @@ a.toggle_selector :margin :top 30px -#featured_users +#community_spotlight .avatar :height 140px :width 140px @@ -3343,7 +3343,7 @@ ul#getting_started -#featured_users_pane +#community_spotlight_pane :padding 10px 0 .featured_user_card_small diff --git a/spec/controllers/featured_users_controller_spec.rb b/spec/controllers/community_spotlight_controller_spec.rb similarity index 80% rename from spec/controllers/featured_users_controller_spec.rb rename to spec/controllers/community_spotlight_controller_spec.rb index 0a32f1e32..75c6da0b6 100644 --- a/spec/controllers/featured_users_controller_spec.rb +++ b/spec/controllers/community_spotlight_controller_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper' -describe FeaturedUsersController do - +describe CommunitySpotlightController do describe "GET 'index'" do it "should be successful" do sign_in alice @@ -9,5 +8,4 @@ describe FeaturedUsersController do response.should be_success end end - end diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb index 4e2c16833..28ae29caf 100644 --- a/spec/controllers/contacts_controller_spec.rb +++ b/spec/controllers/contacts_controller_spec.rb @@ -77,16 +77,16 @@ describe ContactsController do end end - describe '#featured' do + describe '#spotlight' do it 'succeeds' do - get :featured + get :spotlight response.should be_success end it 'gets queries for users in the app config' do - AppConfig[:featured_users] = [alice.diaspora_handle] + AppConfig[:community_spotlight] = [alice.diaspora_handle] - get :featured + get :spotlight assigns[:people].should == [alice.person] end end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 1af5cb4d6..e477e65fd 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -18,9 +18,9 @@ describe ApplicationHelper do end end - it 'links to featured users' do + it 'links to community spotlight' do @current_user = Factory(:user) - contacts_link.should == featured_users_path + contacts_link.should == community_spotlight_path end it 'links to contacts#index' do diff --git a/spec/lib/stream/featured_spec.rb b/spec/lib/stream/community_spotlight_spec.rb similarity index 57% rename from spec/lib/stream/featured_spec.rb rename to spec/lib/stream/community_spotlight_spec.rb index 53eb2353c..b1437c865 100644 --- a/spec/lib/stream/featured_spec.rb +++ b/spec/lib/stream/community_spotlight_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream') -describe Stream::FeaturedUsers do +describe Stream::CommunitySpotlight do before do - @stream = Stream::FeaturedUsers.new(Factory(:user), :max_time => Time.now, :order => 'updated_at') + @stream = Stream::CommunitySpotlight.new(Factory(:user), :max_time => Time.now, :order => 'updated_at') end describe 'shared behaviors' do diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 66432f6c8..47b3cbc94 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -479,17 +479,17 @@ describe Person do end end - describe '.featured_users' do - describe "when the pod owner hasn't set up any featured users" do + describe '.community_spotlight' do + describe "when the pod owner hasn't set up any community spotlight members" do before do - @existing_featured_users = AppConfig[:featured_users] - AppConfig[:featured_users] = nil + @existing_community_spotlight = AppConfig[:community_spotlight] + AppConfig[:community_spotlight] = nil end after do - AppConfig[:featured_users] = @existing_featured_users + AppConfig[:community_spotlight] = @existing_community_spotlight end it "returns an empty array" do - Person.featured_users.should == [] + Person.community_spotlight.should == [] end end end