MS SM featured users stream. because we do what we want
This commit is contained in:
parent
04b51cced8
commit
cdce54bbda
17 changed files with 122 additions and 7 deletions
15
app/controllers/featured_users_controller.rb
Normal file
15
app/controllers/featured_users_controller.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
require File.join(Rails.root, 'lib', 'stream', 'featured_users_stream')
|
||||||
|
|
||||||
|
class FeaturedUsersController < ApplicationController
|
||||||
|
before_filter :authenticate_user!
|
||||||
|
before_filter :save_sort_order, :only => :index
|
||||||
|
|
||||||
|
def index
|
||||||
|
@stream = FeaturedUsersStream.new(current_user, :max_time => params[:max_time], :order => sort_order)
|
||||||
|
if params[:only_posts]
|
||||||
|
render :partial => 'shared/stream', :locals => {:posts => @stream.posts}
|
||||||
|
else
|
||||||
|
render 'aspects/index'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
2
app/helpers/featured_users_helper.rb
Normal file
2
app/helpers/featured_users_helper.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
module FeaturedUsersHelper
|
||||||
|
end
|
||||||
|
|
@ -12,6 +12,8 @@ module StreamHelper
|
||||||
person_path(@person, :max_time => @posts.last.created_at.to_i)
|
person_path(@person, :max_time => @posts.last.created_at.to_i)
|
||||||
elsif controller.instance_of?(TagFollowingsController)
|
elsif controller.instance_of?(TagFollowingsController)
|
||||||
tag_followings_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
tag_followings_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
||||||
|
elsif controller.instance_of?(FeaturedUsersController)
|
||||||
|
featured_users_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
||||||
elsif controller.instance_of?(MentionsController)
|
elsif controller.instance_of?(MentionsController)
|
||||||
mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order])
|
||||||
elsif controller.instance_of?(AspectsController)
|
elsif controller.instance_of?(AspectsController)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
- if @stream.people.size > 0
|
- if @stream.people.size > 0
|
||||||
- for person in @stream.people.sample(15)
|
- for person in @stream.people.sample(15)
|
||||||
= person_image_link(person)
|
= person_image_link(person)
|
||||||
= link_to t('.view_all_contacts'), @stream.contacts_link, :id => "view_all_contacts_link"
|
= link_to @stream.contacts_link_title, @stream.contacts_link, :id => "view_all_contacts_link"
|
||||||
- else
|
- else
|
||||||
= t('.no_contacts')
|
= t('.no_contacts')
|
||||||
= link_to t('.manage_your_aspects'), contacts_link
|
= link_to t('.manage_your_aspects'), contacts_link
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,11 @@
|
||||||
.li
|
.li
|
||||||
%b= link_to t('.mentions'), mentions_path, :class => 'home_selector'
|
%b= link_to t('.mentions'), mentions_path, :class => 'home_selector'
|
||||||
|
|
||||||
|
.section
|
||||||
|
%ul.left_nav
|
||||||
|
.li
|
||||||
|
%b= link_to t('.featured_users'), featured_path, :class => 'home_selector'
|
||||||
|
|
||||||
.section#followed_tags_listing
|
.section#followed_tags_listing
|
||||||
= render 'tags/followed_tags_listings'
|
= render 'tags/followed_tags_listings'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
= t('.check_out')
|
= t('.check_out')
|
||||||
= link_to t('contacts.featured.featured_users'), "/featured"
|
= link_to t('contacts.featured.featured_users'), featured_users_path
|
||||||
- if @aspect
|
- if @aspect
|
||||||
or
|
or
|
||||||
= link_to t('.add_to_aspect', :name => @aspect.name).downcase, edit_aspect_path(@aspect), :rel => "facebox"
|
= link_to t('.add_to_aspect', :name => @aspect.name).downcase, edit_aspect_path(@aspect), :rel => "facebox"
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
%ul.left_nav
|
%ul.left_nav
|
||||||
- if AppConfig[:featured_users]
|
- if AppConfig[:featured_users]
|
||||||
%li{:class => ("active" if @featured)}
|
%li{:class => ("active" if @featured)}
|
||||||
= link_to t('contacts.featured.featured_users'), "/featured", :class => "element_selector"
|
= link_to t('contacts.featured.featured_users'), featured_users_path, :class => "element_selector"
|
||||||
%li{:class => ("active" if @finder)}
|
%li{:class => ("active" if @finder)}
|
||||||
= link_to "Facebook Friends", friend_finder_path('facebook'), :class => "element_selector"
|
= link_to "Facebook Friends", friend_finder_path('facebook'), :class => "element_selector"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -122,8 +122,8 @@ en:
|
||||||
aspect_listings:
|
aspect_listings:
|
||||||
edit_aspect: "Edit %{name}"
|
edit_aspect: "Edit %{name}"
|
||||||
add_an_aspect: "+ Add an aspect"
|
add_an_aspect: "+ Add an aspect"
|
||||||
|
|
||||||
selected_contacts:
|
selected_contacts:
|
||||||
|
view_all_featured_users: "See all Featured Users"
|
||||||
view_all_contacts: "View all contacts"
|
view_all_contacts: "View all contacts"
|
||||||
no_contacts: "You don't have any contacts here yet."
|
no_contacts: "You don't have any contacts here yet."
|
||||||
manage_your_aspects: "Manage your aspects."
|
manage_your_aspects: "Manage your aspects."
|
||||||
|
|
@ -158,6 +158,7 @@ en:
|
||||||
friends: "Friends"
|
friends: "Friends"
|
||||||
index:
|
index:
|
||||||
mentions: "Mentions"
|
mentions: "Mentions"
|
||||||
|
featured_users: "Featured Users"
|
||||||
donate: "Donate"
|
donate: "Donate"
|
||||||
keep_us_running: "Keep %{pod} running fast and buy servers their coffee fix with a monthly donation!"
|
keep_us_running: "Keep %{pod} running fast and buy servers their coffee fix with a monthly donation!"
|
||||||
your_aspects: "Your Aspects"
|
your_aspects: "Your Aspects"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
Diaspora::Application.routes.draw do
|
Diaspora::Application.routes.draw do
|
||||||
|
|
||||||
|
|
||||||
# Posting and Reading
|
# Posting and Reading
|
||||||
|
|
||||||
resources :reshares
|
resources :reshares
|
||||||
|
|
@ -107,7 +108,11 @@ Diaspora::Application.routes.draw do
|
||||||
resources :aspect_memberships, :only => [:destroy, :create, :update]
|
resources :aspect_memberships, :only => [:destroy, :create, :update]
|
||||||
resources :post_visibilities, :only => [:update]
|
resources :post_visibilities, :only => [:update]
|
||||||
|
|
||||||
get 'featured' => "contacts#featured", :as => 'featured_users'
|
get 'featured' => 'featured_users#index', :as => 'featured'
|
||||||
|
|
||||||
|
get 'featured_users' => "contacts#featured", :as => 'featured_users'
|
||||||
|
|
||||||
|
|
||||||
resources :people, :except => [:edit, :update] do
|
resources :people, :except => [:edit, :update] do
|
||||||
resources :status_messages
|
resources :status_messages
|
||||||
resources :photos
|
resources :photos
|
||||||
|
|
@ -120,7 +125,6 @@ Diaspora::Application.routes.draw do
|
||||||
end
|
end
|
||||||
get '/u/:username' => 'people#show', :as => 'user_profile'
|
get '/u/:username' => 'people#show', :as => 'user_profile'
|
||||||
get '/u/:username/profile_photo' => 'users#user_photo'
|
get '/u/:username/profile_photo' => 'users#user_photo'
|
||||||
|
|
||||||
# Federation
|
# Federation
|
||||||
|
|
||||||
controller :publics do
|
controller :publics do
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@ class BaseStream
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def contacts_link_title
|
||||||
|
I18n.translate('aspects.selected_contacts.view_all_contacts')
|
||||||
|
end
|
||||||
|
|
||||||
def contacts_title
|
def contacts_title
|
||||||
"title for a stream"
|
"title for a stream"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ module Messagebus
|
||||||
|
|
||||||
def initialize(api_key)
|
def initialize(api_key)
|
||||||
@client = MessagebusRubyApi::Client.new(api_key)
|
@client = MessagebusRubyApi::Client.new(api_key)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :settings
|
attr_accessor :settings
|
||||||
|
|
|
||||||
29
lib/stream/featured_users_stream.rb
Normal file
29
lib/stream/featured_users_stream.rb
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
class FeaturedUsersStream < BaseStream
|
||||||
|
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
|
||||||
9
public/javascripts/pages/featured-users-index.js
Normal file
9
public/javascripts/pages/featured-users-index.js
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
Diaspora.Pages.FeaturedUsersIndex = function() {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
this.subscribe("page/ready", function(evt, document) {
|
||||||
|
self.aspectNavigation = self.instantiate("AspectNavigation", document.find("ul#aspect_nav"));
|
||||||
|
self.stream = self.instantiate("Stream", document.find("#aspect_stream_container"));
|
||||||
|
self.infiniteScroll = self.instantiate("InfiniteScroll");
|
||||||
|
});
|
||||||
|
};
|
||||||
13
spec/controllers/featured_users_controller_spec.rb
Normal file
13
spec/controllers/featured_users_controller_spec.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe FeaturedUsersController do
|
||||||
|
|
||||||
|
describe "GET 'index'" do
|
||||||
|
it "should be successful" do
|
||||||
|
sign_in alice
|
||||||
|
get 'index'
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
15
spec/helpers/featured_users_helper_spec.rb
Normal file
15
spec/helpers/featured_users_helper_spec.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
# Specs in this file have access to a helper object that includes
|
||||||
|
# the FeaturedUsersHelper. For example:
|
||||||
|
#
|
||||||
|
# describe FeaturedUsersHelper do
|
||||||
|
# describe "string concat" do
|
||||||
|
# it "concats two strings with spaces" do
|
||||||
|
# helper.concat_strings("this","that").should == "this that"
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
describe FeaturedUsersHelper do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
12
spec/lib/stream/featured_users_spec.rb
Normal file
12
spec/lib/stream/featured_users_spec.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
|
||||||
|
|
||||||
|
describe FeaturedUsersStream do
|
||||||
|
before do
|
||||||
|
@stream = FeaturedUsersStream.new(Factory(:user), :max_time => Time.now, :order => 'updated_at')
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'shared behaviors' do
|
||||||
|
it_should_behave_like 'it is a stream'
|
||||||
|
end
|
||||||
|
end
|
||||||
5
spec/views/featured_users/index.html.haml_spec.rb
Normal file
5
spec/views/featured_users/index.html.haml_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe "featured_users/index.html.haml" do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue