diff --git a/app/controllers/apps_controller.rb b/app/controllers/apps_controller.rb new file mode 100644 index 000000000..78b8de72c --- /dev/null +++ b/app/controllers/apps_controller.rb @@ -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 diff --git a/app/helpers/stream_helper.rb b/app/helpers/stream_helper.rb index 3fe8aca2b..92a31e98d 100644 --- a/app/helpers/stream_helper.rb +++ b/app/helpers/stream_helper.rb @@ -6,10 +6,14 @@ module StreamHelper def next_page_path if controller.instance_of?(TagsController) 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) person_path(@person, :max_time => @posts.last.created_at.to_i) elsif controller.instance_of?(AspectsController) 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 diff --git a/app/views/apps/show.html.haml b/app/views/apps/show.html.haml new file mode 100644 index 000000000..3b461c0b5 --- /dev/null +++ b/app/views/apps/show.html.haml @@ -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 diff --git a/config/routes.rb b/config/routes.rb index de9ddc7a1..8b4772333 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -34,7 +34,8 @@ Diaspora::Application.routes.draw do resources :tags, :only => [:index] get 'tags/:name' => 'tags#show', :as => 'tag' - + + resources :apps, :only => [:show] # Users and people resource :user, :only => [:edit, :update, :destroy], :shallow => true do diff --git a/spec/controllers/apps_controller_spec.rb b/spec/controllers/apps_controller_spec.rb new file mode 100644 index 000000000..ae066c520 --- /dev/null +++ b/spec/controllers/apps_controller_spec.rb @@ -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 diff --git a/spec/helpers/stream_helper_spec.rb b/spec/helpers/stream_helper_spec.rb index ebb6ce0b7..8d55ca303 100644 --- a/spec/helpers/stream_helper_spec.rb +++ b/spec/helpers/stream_helper_spec.rb @@ -21,4 +21,12 @@ describe StreamHelper do time_for_sort(@post).should == @post.created_at 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