featured users => community spotlight
This commit is contained in:
parent
6cce4f0872
commit
44b58d707f
28 changed files with 100 additions and 102 deletions
7
app/controllers/community_spotlight_controller.rb
Normal file
7
app/controllers/community_spotlight_controller.rb
Normal file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -64,7 +64,7 @@ module ApplicationHelper
|
|||
if current_user.contacts.size > 0
|
||||
contacts_path
|
||||
else
|
||||
featured_users_path
|
||||
community_spotlight_path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
29
lib/stream/community_spotlight.rb
Normal file
29
lib/stream/community_spotlight.rb
Normal file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue