tag stream wip
This commit is contained in:
parent
8029cb0784
commit
2dda160990
5 changed files with 26 additions and 39 deletions
|
|
@ -150,7 +150,7 @@ class ApplicationController < ActionController::Base
|
||||||
def default_stream_action(stream_klass)
|
def default_stream_action(stream_klass)
|
||||||
authenticate_user!
|
authenticate_user!
|
||||||
save_sort_order
|
save_sort_order
|
||||||
@stream = stream_klass.new(current_user, :max_time => params[:max_time], :order => sort_order)
|
@stream = stream_klass.new(current_user, :max_time => max_time, :order => sort_order)
|
||||||
|
|
||||||
if params[:only_posts]
|
if params[:only_posts]
|
||||||
render :partial => 'shared/stream', :locals => {:posts => @stream.posts}
|
render :partial => 'shared/stream', :locals => {:posts => @stream.posts}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
# licensed under the Affero General Public License version 3 or later. See
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
require File.join(Rails.root, 'app', 'models', 'acts_as_taggable_on_tag')
|
require File.join(Rails.root, 'app', 'models', 'acts_as_taggable_on_tag')
|
||||||
|
require File.join(Rails.root, 'lib', 'stream', 'tag')
|
||||||
|
|
||||||
class TagsController < ApplicationController
|
class TagsController < ApplicationController
|
||||||
skip_before_filter :which_action_and_user
|
skip_before_filter :which_action_and_user
|
||||||
|
|
@ -34,34 +35,17 @@ class TagsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
params[:name].downcase!
|
@stream = Stream::Tag.new(current_user, params[:name], :max_time => max_time, :page => params[:page])
|
||||||
@aspect = :tag
|
|
||||||
@tag = ActsAsTaggableOn::Tag.find_by_name(params[:name])
|
|
||||||
@tag_follow_count = @tag.try(:followed_count).to_i
|
|
||||||
|
|
||||||
if current_user
|
|
||||||
@posts = StatusMessage.owned_or_visible_by_user(current_user)
|
|
||||||
else
|
|
||||||
@posts = StatusMessage.all_public
|
|
||||||
end
|
|
||||||
|
|
||||||
@posts = @posts.tagged_with(params[:name]).for_a_stream(max_time, 'created_at')
|
|
||||||
|
|
||||||
@commenting_disabled = true
|
|
||||||
params[:prefill] = "##{params[:name]} "
|
|
||||||
|
|
||||||
if params[:only_posts]
|
if params[:only_posts]
|
||||||
render :partial => 'shared/stream', :locals => {:posts => @posts}
|
render :partial => 'shared/stream', :locals => {:posts => @stream.posts}
|
||||||
else
|
return
|
||||||
profiles = Profile.tagged_with(params[:name]).where(:searchable => true).select('profiles.id, profiles.person_id')
|
|
||||||
@people = Person.where(:id => profiles.map{|p| p.person_id}).paginate(:page => params[:page], :per_page => 15)
|
|
||||||
@people_count = Person.where(:id => profiles.map{|p| p.person_id}).count
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_followed?
|
def tag_followed?
|
||||||
if @tag_followed.nil?
|
if @tag_followed.nil?
|
||||||
@tag_followed = TagFollowing.joins(:tag).where(:tags => {:name => params[:name]}, :user_id => current_user.id).exists? #,
|
@tag_followed = TagFollowing.joins(:tag).where(:tags => {:name => params[:name]}, :user_id => current_user.id).exists?
|
||||||
end
|
end
|
||||||
@tag_followed
|
@tag_followed
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
module StreamHelper
|
module StreamHelper
|
||||||
def next_page_path(opts ={})
|
def next_page_path(opts ={})
|
||||||
if controller.instance_of?(TagsController)
|
if controller.instance_of?(TagsController)
|
||||||
tag_path(:name => @tag.name, :max_time => @posts.last.created_at.to_i)
|
tag_path(:name => @stream.tag_name, :max_time => time_for_scroll(opts[:ajax_stream], @stream))
|
||||||
elsif controller.instance_of?(AppsController)
|
elsif controller.instance_of?(AppsController)
|
||||||
"/apps/1?#{{:max_time => @posts.last.created_at.to_i}.to_param}"
|
"/apps/1?#{{:max_time => @posts.last.created_at.to_i}.to_param}"
|
||||||
elsif controller.instance_of?(PeopleController)
|
elsif controller.instance_of?(PeopleController)
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ class Person < ActiveRecord::Base
|
||||||
select("DISTINCT people.*")
|
select("DISTINCT people.*")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
def self.featured_users
|
||||||
AppConfig[:featured_users].present? ? Person.where(:diaspora_handle => AppConfig[:featured_users]) : []
|
AppConfig[:featured_users].present? ? Person.where(:diaspora_handle => AppConfig[:featured_users]) : []
|
||||||
end
|
end
|
||||||
|
|
@ -76,7 +78,6 @@ class Person < ActiveRecord::Base
|
||||||
self.profile ||= Profile.new unless profile_set
|
self.profile ||= Profile.new unless profile_set
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.find_from_id_or_username(params)
|
def self.find_from_id_or_username(params)
|
||||||
p = if params[:id].present?
|
p = if params[:id].present?
|
||||||
Person.where(:id => params[:id]).first
|
Person.where(:id => params[:id]).first
|
||||||
|
|
@ -272,6 +273,8 @@ class Person < ActiveRecord::Base
|
||||||
person.update_url(url)
|
person.update_url(url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# @param person [Person]
|
# @param person [Person]
|
||||||
# @param url [String]
|
# @param url [String]
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
|
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
- if params[:name]
|
- if @stream.tag_name
|
||||||
= "##{params[:name]}"
|
= @stream.display_tag_name
|
||||||
- else
|
- else
|
||||||
= t('.whatup', :pod => @pod_url)
|
= t('.whatup', :pod => @pod_url)
|
||||||
|
|
||||||
|
|
@ -17,12 +17,12 @@
|
||||||
$(".button.tag_following").hover(function(){
|
$(".button.tag_following").hover(function(){
|
||||||
$this = $(this);
|
$this = $(this);
|
||||||
$this.removeClass("in_aspects");
|
$this.removeClass("in_aspects");
|
||||||
$this.val("#{t('.stop_following', :tag => params[:name])}");
|
$this.val("#{t('.stop_following', :tag => @stream.tag_name)}");
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
$this = $(this);
|
$this = $(this);
|
||||||
$this.addClass("in_aspects");
|
$this.addClass("in_aspects");
|
||||||
$this.val("#{t('.following', :tag => params[:name])}");
|
$this.val("#{t('.following', :tag => @stream.tag_name)}");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$(".people_stream .pagination a").live("click", function() {
|
$(".people_stream .pagination a").live("click", function() {
|
||||||
|
|
@ -36,10 +36,10 @@
|
||||||
|
|
||||||
.span-6.tags_people
|
.span-6.tags_people
|
||||||
%h3
|
%h3
|
||||||
= t('people', :count => @people_count)
|
= t('people', :count => @stream.people_count)
|
||||||
|
|
||||||
.side_stream.stream
|
.side_stream.stream
|
||||||
= render :partial => 'people/index', :locals => {:people => @people}
|
= render :partial => 'people/index', :locals => {:people => @stream.people}
|
||||||
|
|
||||||
%br
|
%br
|
||||||
|
|
||||||
|
|
@ -49,28 +49,28 @@
|
||||||
.span-15.last
|
.span-15.last
|
||||||
.stream_container
|
.stream_container
|
||||||
#author_info
|
#author_info
|
||||||
- if user_signed_in? && current_user.person != @person
|
- if user_signed_in?
|
||||||
.right
|
.right
|
||||||
- unless tag_followed?
|
- unless tag_followed?
|
||||||
= button_to t('.follow', :tag => params[:name]), tag_tag_followings_path(:name => params[:name]), :method => :post, :class => 'button take_action'
|
= button_to t('.follow', :tag => @stream.tag_name), tag_tag_followings_path(:name => @stream.tag_name), :method => :post, :class => 'button take_action'
|
||||||
- else
|
- else
|
||||||
= button_to t('.following', :tag => params[:name]), tag_tag_followings_path(:name => params[:name]), :method => :delete, :class => 'button red_on_hover tag_following in_aspects take_action'
|
= button_to t('.following', :tag => @stream.tag_name), tag_tag_followings_path(:name => @stream.tag_name), :method => :delete, :class => 'button red_on_hover tag_following in_aspects take_action'
|
||||||
%h2
|
%h2
|
||||||
= "##{params[:name]}"
|
= @stream.display_tag_name
|
||||||
%small
|
%small
|
||||||
= t('.followed_by')
|
= t('.followed_by')
|
||||||
= t('people', :count => @tag_follow_count)
|
= t('people', :count => @stream.tag_follow_count)
|
||||||
|
|
||||||
- if current_user
|
- if current_user
|
||||||
= render 'shared/publisher', :selected_aspects => all_aspects.map{|a| a.id}, :aspect_ids => all_aspects.map{|a| a.id}, :for_all_aspects => true, :aspect => all_aspects.first
|
= render 'shared/publisher', :selected_aspects => @stream.aspect_ids, :aspect_ids => @stream.aspect_ids, :for_all_aspects => true, :aspect => @stream.aspect
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
|
|
||||||
#main_stream.stream
|
#main_stream.stream
|
||||||
- if @posts.length > 0
|
- if @stream.posts.length > 0
|
||||||
= render 'shared/stream', :posts => @posts
|
= render 'shared/stream', :posts => @stream.posts
|
||||||
#pagination
|
#pagination
|
||||||
=link_to(t('more'), next_page_path, :class => 'paginate')
|
=link_to(t('more'), next_page_path, :class => 'paginate')
|
||||||
- else
|
- else
|
||||||
= t('.nobody_talking', :tag => "##{params[:name]}")
|
= t('.nobody_talking', :tag => @stream.display_tag_name)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue