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)
|
||||
authenticate_user!
|
||||
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]
|
||||
render :partial => 'shared/stream', :locals => {:posts => @stream.posts}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
require File.join(Rails.root, 'app', 'models', 'acts_as_taggable_on_tag')
|
||||
require File.join(Rails.root, 'lib', 'stream', 'tag')
|
||||
|
||||
class TagsController < ApplicationController
|
||||
skip_before_filter :which_action_and_user
|
||||
|
|
@ -34,34 +35,17 @@ class TagsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
params[:name].downcase!
|
||||
@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]} "
|
||||
@stream = Stream::Tag.new(current_user, params[:name], :max_time => max_time, :page => params[:page])
|
||||
|
||||
if params[:only_posts]
|
||||
render :partial => 'shared/stream', :locals => {:posts => @posts}
|
||||
else
|
||||
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
|
||||
render :partial => 'shared/stream', :locals => {:posts => @stream.posts}
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
def tag_followed?
|
||||
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
|
||||
@tag_followed
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
module StreamHelper
|
||||
def next_page_path(opts ={})
|
||||
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)
|
||||
"/apps/1?#{{:max_time => @posts.last.created_at.to_i}.to_param}"
|
||||
elsif controller.instance_of?(PeopleController)
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ class Person < ActiveRecord::Base
|
|||
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
|
||||
AppConfig[:featured_users].present? ? Person.where(:diaspora_handle => AppConfig[:featured_users]) : []
|
||||
end
|
||||
|
|
@ -76,7 +78,6 @@ class Person < ActiveRecord::Base
|
|||
self.profile ||= Profile.new unless profile_set
|
||||
end
|
||||
|
||||
|
||||
def self.find_from_id_or_username(params)
|
||||
p = if params[:id].present?
|
||||
Person.where(:id => params[:id]).first
|
||||
|
|
@ -273,6 +274,8 @@ class Person < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
# @param person [Person]
|
||||
# @param url [String]
|
||||
def update_url(url)
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
|
||||
- content_for :page_title do
|
||||
- if params[:name]
|
||||
= "##{params[:name]}"
|
||||
- if @stream.tag_name
|
||||
= @stream.display_tag_name
|
||||
- else
|
||||
= t('.whatup', :pod => @pod_url)
|
||||
|
||||
|
|
@ -17,12 +17,12 @@
|
|||
$(".button.tag_following").hover(function(){
|
||||
$this = $(this);
|
||||
$this.removeClass("in_aspects");
|
||||
$this.val("#{t('.stop_following', :tag => params[:name])}");
|
||||
$this.val("#{t('.stop_following', :tag => @stream.tag_name)}");
|
||||
},
|
||||
function(){
|
||||
$this = $(this);
|
||||
$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() {
|
||||
|
|
@ -36,10 +36,10 @@
|
|||
|
||||
.span-6.tags_people
|
||||
%h3
|
||||
= t('people', :count => @people_count)
|
||||
= t('people', :count => @stream.people_count)
|
||||
|
||||
.side_stream.stream
|
||||
= render :partial => 'people/index', :locals => {:people => @people}
|
||||
= render :partial => 'people/index', :locals => {:people => @stream.people}
|
||||
|
||||
%br
|
||||
|
||||
|
|
@ -49,28 +49,28 @@
|
|||
.span-15.last
|
||||
.stream_container
|
||||
#author_info
|
||||
- if user_signed_in? && current_user.person != @person
|
||||
- if user_signed_in?
|
||||
.right
|
||||
- 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
|
||||
= 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
|
||||
= "##{params[:name]}"
|
||||
= @stream.display_tag_name
|
||||
%small
|
||||
= t('.followed_by')
|
||||
= t('people', :count => @tag_follow_count)
|
||||
= t('people', :count => @stream.tag_follow_count)
|
||||
|
||||
- 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
|
||||
|
||||
#main_stream.stream
|
||||
- if @posts.length > 0
|
||||
= render 'shared/stream', :posts => @posts
|
||||
- if @stream.posts.length > 0
|
||||
= render 'shared/stream', :posts => @stream.posts
|
||||
#pagination
|
||||
=link_to(t('more'), next_page_path, :class => 'paginate')
|
||||
- else
|
||||
= t('.nobody_talking', :tag => "##{params[:name]}")
|
||||
= t('.nobody_talking', :tag => @stream.display_tag_name)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue