Fix pagination in AppsController

This commit is contained in:
Raphael Sofaer 2011-06-09 16:22:52 -07:00
parent 0790c3397e
commit 7fd86924ee
4 changed files with 18 additions and 12 deletions

View file

@ -3,7 +3,10 @@ class AppsController < ApplicationController
@app = 'cubbies' @app = 'cubbies'
@posts = ActivityStreams::Photo @posts = ActivityStreams::Photo
max_time = params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now 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) @posts = @posts.where(ActivityStreams::Photo.arel_table[:created_at].lt(max_time)
).where(:public => true
).order('posts.created_at DESC'
).includes(:author => :profile).limit(30)
@commenting_disabled = true @commenting_disabled = true
@people = [] @people = []
@people_count = 0 @people_count = 0

View file

@ -17,15 +17,15 @@
%h1 %h1
= "#{@app}" = "#{@app}"
#main_stream.stream #main_stream.stream.canvas
- if @posts.length > 0 - if @posts.length > 0
.canvas.stream - for post in @posts
- for post in @posts .image-element.stream_element
.image-element.stream-element .hold-me
.hold-me = link_to(image_tag(post.image_url), object_path(post))
= link_to(image_tag(post.image_url), object_path(post)) .via
.via = post.author.name
= post.author.name .time{:integer => post.created_at.to_i}
#pagination #pagination
=link_to(t('more'), next_page_path, :class => 'paginate') =link_to(t('more'), next_page_path, :class => 'paginate')

View file

@ -2928,7 +2928,9 @@ h1.tag
:width 98% :width 98%
.canvas .canvas
.image-element .image-element,
.stream_element
:border none
:padding 20px :padding 20px
:height 170px :height 170px
:width 170px :width 170px

View file

@ -103,10 +103,11 @@ end
Factory.define(:activity_streams_photo, :class => ActivityStreams::Photo) do |p| Factory.define(:activity_streams_photo, :class => ActivityStreams::Photo) do |p|
p.association(:author, :factory => :person) p.association(:author, :factory => :person)
p.image_url "http://example.com/awesome.png" p.image_url "http://example.com/awesome.png"
p.image_height 9001 p.image_height 900
p.image_width 4 p.image_width 400
p.object_url "http://example.com/awesome_things.gif" p.object_url "http://example.com/awesome_things.gif"
p.objectId "http://example.com/awesome_things.gif" p.objectId "http://example.com/awesome_things.gif"
p.actor_url "http://notcubbi.es/cubber" p.actor_url "http://notcubbi.es/cubber"
p.provider_display_name "not cubbies" p.provider_display_name "not cubbies"
p.public true
end end