diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 10c2c10cad1083b8efa82989b8dfa31a2ff130f5..39b96cb67853ad14fd28551fe8a750a4881e0dd4 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -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 diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..fe836c60bf627c258ad9bbbdb602ff02b9851308 --- /dev/null +++ b/app/views/posts/index.html.haml @@ -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 diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 264363785f7b7fcbdd336be7c67104a4f18597d0..c0d4d079d830248c14fe9143336b4e508f702a56 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -31,6 +31,7 @@ %span.timeago = link_to(how_long_ago(post), status_message_path(post)) - = link_to t('comments.new_comment.comment').downcase, '#', :class => 'focus_comment_textarea' + - 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) diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 5b07221acc5ae93c147080ce2cdb6fdcbd1ba876..662c63d5bee7f4f3459f73eac4aae93bf32f776b 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -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" diff --git a/config/routes.rb b/config/routes.rb index 199f93d82a96e44a8aa2a2ad0c5c247cbabc8e20..6ca43618726e884dce03244a7ac1a3f41689c48e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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] diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index b75c9e53a9cb8ddcf8dc2ec31eec006fd4e5e766..12bca86643ffe2e616c35e8596146e4cd5475e5f 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -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')