added a very basic page for the stream of all public activity stream photos
This commit is contained in:
parent
d12944d57e
commit
52487e87de
6 changed files with 65 additions and 1 deletions
11
app/controllers/apps_controller.rb
Normal file
11
app/controllers/apps_controller.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
class AppsController < ApplicationController
|
||||||
|
def show
|
||||||
|
@app = 'cubbies'
|
||||||
|
@posts = ActivityStreams::Photo
|
||||||
|
max_time = params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now
|
||||||
|
@posts = @posts.where(ActivityStreams::Photo.arel_table[:created_at].lt(max_time)).where(:public => true).order('posts.created_at DESC').limit(15).includes(:author)
|
||||||
|
@commenting_disabled = true
|
||||||
|
@people = []
|
||||||
|
@people_count = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -6,10 +6,14 @@ module StreamHelper
|
||||||
def next_page_path
|
def next_page_path
|
||||||
if controller.instance_of?(TagsController)
|
if controller.instance_of?(TagsController)
|
||||||
tag_path(@tag, :max_time => @posts.last.created_at.to_i)
|
tag_path(@tag, :max_time => @posts.last.created_at.to_i)
|
||||||
|
elsif controller.instance_of?(AppsController)
|
||||||
|
"/apps/1?#{{:max_time => @posts.last.created_at.to_i}.to_param}"
|
||||||
elsif controller.instance_of?(PeopleController)
|
elsif controller.instance_of?(PeopleController)
|
||||||
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?(AspectsController)
|
elsif controller.instance_of?(AspectsController)
|
||||||
aspects_path(:max_time => @posts.last.send(session[:sort_order].to_sym).to_i, :a_ids => params[:a_ids])
|
aspects_path(:max_time => @posts.last.send(session[:sort_order].to_sym).to_i, :a_ids => params[:a_ids])
|
||||||
|
else
|
||||||
|
raise 'in order to use pagination for this new controller, update next_page_path in stream helper'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
27
app/views/apps/show.html.haml
Normal file
27
app/views/apps/show.html.haml
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
-# 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
|
||||||
|
= "everything happening from #{@app}"
|
||||||
|
|
||||||
|
- content_for :head do
|
||||||
|
= include_javascripts :home
|
||||||
|
|
||||||
|
- content_for :body_class do
|
||||||
|
= "apps_show"
|
||||||
|
|
||||||
|
.span-24.last
|
||||||
|
%h1.tag
|
||||||
|
= "everything happening from #{@app}"
|
||||||
|
|
||||||
|
.span-13
|
||||||
|
#main_stream.stream
|
||||||
|
- if @posts.length > 0
|
||||||
|
= render 'shared/stream', :posts => @posts
|
||||||
|
#pagination
|
||||||
|
=link_to(t('more'), next_page_path, :class => 'paginate')
|
||||||
|
- else
|
||||||
|
= t('tags.show.nobody_talking', :tag => "##{params[:name]}")
|
||||||
|
|
||||||
|
.prepend-2.span-9.last
|
||||||
|
|
@ -34,7 +34,8 @@ Diaspora::Application.routes.draw do
|
||||||
|
|
||||||
resources :tags, :only => [:index]
|
resources :tags, :only => [:index]
|
||||||
get 'tags/:name' => 'tags#show', :as => 'tag'
|
get 'tags/:name' => 'tags#show', :as => 'tag'
|
||||||
|
|
||||||
|
resources :apps, :only => [:show]
|
||||||
# Users and people
|
# Users and people
|
||||||
|
|
||||||
resource :user, :only => [:edit, :update, :destroy], :shallow => true do
|
resource :user, :only => [:edit, :update, :destroy], :shallow => true do
|
||||||
|
|
|
||||||
13
spec/controllers/apps_controller_spec.rb
Normal file
13
spec/controllers/apps_controller_spec.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe AppsController do
|
||||||
|
describe '#show' do
|
||||||
|
it 'works as long as you pass something as id' do
|
||||||
|
Factory(:activity_streams_photo)
|
||||||
|
get :show, :id => 'cubbies'
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -21,4 +21,12 @@ describe StreamHelper do
|
||||||
time_for_sort(@post).should == @post.created_at
|
time_for_sort(@post).should == @post.created_at
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#next_page_path' do
|
||||||
|
it 'works for apps page' do
|
||||||
|
stub!(:controller).and_return(AppsController.new)
|
||||||
|
@posts = [Factory(:activity_streams_photo)] !s!)
|
||||||
|
next_page_path.should include '/apps/1'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue