Show local public posts in /p
This commit is contained in:
parent
9d1bb3ac21
commit
8f929d2b85
6 changed files with 55 additions and 3 deletions
|
|
@ -10,6 +10,16 @@ class PostsController < ApplicationController
|
|||
skip_before_filter :which_action_and_user
|
||||
skip_before_filter :set_grammatical_gender
|
||||
|
||||
def index
|
||||
@posts = StatusMessage.joins(:author).where(Person.arel_table[:owner_id].not_eq(nil)).where(:public => true, :pending => false
|
||||
).includes(:comments, :photos
|
||||
).paginate(:page => params[:page], :per_page => 15, :order => 'created_at DESC')
|
||||
|
||||
@fakes = PostsFake.new(@posts)
|
||||
@commenting_disabled = true
|
||||
@pod_url = AppConfig[:pod_uri].host
|
||||
end
|
||||
|
||||
def show
|
||||
@post = Post.where(:id => params[:id], :public => true).includes(:author, :comments => :author).first
|
||||
|
||||
|
|
|
|||
20
app/views/posts/index.html.haml
Normal file
20
app/views/posts/index.html.haml
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
- content_for :page_title do
|
||||
= t('.whatup', :pod => @pod_url)
|
||||
|
||||
|
||||
- content_for :head do
|
||||
= include_javascripts :home
|
||||
|
||||
%h1
|
||||
= t('.whatup', :pod => @pod_url)
|
||||
|
||||
.span-15
|
||||
#main_stream.stream
|
||||
= render 'shared/stream', :posts => @fakes
|
||||
%a.paginate
|
||||
= t("more")
|
||||
= will_paginate @posts
|
||||
|
|
@ -31,6 +31,7 @@
|
|||
%span.timeago
|
||||
= link_to(how_long_ago(post), status_message_path(post))
|
||||
|
||||
- unless (defined?(@commenting_disabled) && @commenting_disabled)
|
||||
= link_to t('comments.new_comment.comment').downcase, '#', :class => 'focus_comment_textarea'
|
||||
|
||||
= render "comments/comments", :post_id => post.id, :comments => post.comments, :current_user => current_user, :condensed => true, :commenting_disabled => defined?(@commenting_disabled)
|
||||
= render "comments/comments", :post_id => post.id, :comments => post.comments, :current_user => current_user, :condensed => true, :commenting_disabled => (defined?(@commenting_disabled) && @commenting_disabled)
|
||||
|
|
|
|||
|
|
@ -423,6 +423,9 @@ en:
|
|||
people_on_pod_are_aware_of: " people on pod are aware of"
|
||||
aspect_list:
|
||||
edit_membership: "edit aspect membership"
|
||||
posts:
|
||||
index:
|
||||
whatup: "What's happening on %{pod}"
|
||||
requests:
|
||||
manage_aspect_contacts:
|
||||
manage_within: "Manage contacts within"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Diaspora::Application.routes.draw do
|
|||
|
||||
match 'notifications/read_all' => 'notifications#read_all'
|
||||
resources :notifications, :only => [:index, :update]
|
||||
resources :posts, :only => [:show], :path => '/p/'
|
||||
resources :posts, :only => [:show, :index], :path => '/p/'
|
||||
|
||||
resources :contacts
|
||||
resources :aspect_memberships, :only => [:destroy, :create]
|
||||
|
|
|
|||
|
|
@ -11,6 +11,24 @@ describe PostsController do
|
|||
@user = alice
|
||||
@controller.stub!(:current_user).and_return(nil)
|
||||
end
|
||||
describe '#index' do
|
||||
it 'shows the most recent public posts' do
|
||||
posts = []
|
||||
10.times do
|
||||
posts << @user.post(:status_message, :message => "hello", :public => true, :to => 'all')
|
||||
end
|
||||
get :index
|
||||
assigns[:posts].should =~ posts
|
||||
end
|
||||
it' shows only local posts' do
|
||||
10.times do
|
||||
@user.post(:status_message, :message => "hello", :public => true, :to => 'all')
|
||||
end
|
||||
@user.person.update_attributes(:owner_id => nil)
|
||||
get :index
|
||||
assigns[:posts].should == []
|
||||
end
|
||||
end
|
||||
describe '#show' do
|
||||
it 'shows a public post' do
|
||||
status = @user.post(:status_message, :message => "hello", :public => true, :to => 'all')
|
||||
|
|
|
|||
Loading…
Reference in a new issue