fix post presenter / arrow ordering

This commit is contained in:
danielgrippi 2012-02-17 17:51:50 -08:00
parent 7ec13d26ac
commit 30de08b340
4 changed files with 11 additions and 12 deletions

View file

@ -33,7 +33,7 @@ class PostsController < ApplicationController
respond_to do |format| respond_to do |format|
format.xml{ render :xml => @post.to_diaspora_xml } format.xml{ render :xml => @post.to_diaspora_xml }
format.mobile{render 'posts/show.mobile.haml'} format.mobile{render 'posts/show.mobile.haml'}
format.json{ render :json => PostPresenter.new(@post).to_json } format.json{ render :json => PostPresenter.new(@post, current_user).to_json }
format.any{render 'posts/show.html.haml', :layout => 'layouts/post'} format.any{render 'posts/show.html.haml', :layout => 'layouts/post'}
end end

View file

@ -69,11 +69,11 @@ class Post < ActiveRecord::Base
} }
def self.next(post) def self.next(post)
where("posts.id > ?", post.id) where("posts.created_at > ?", post.created_at)
end end
def self.previous(post) def self.previous(post)
where("posts.id < ?", post.id) where("posts.created_at < ?", post.created_at)
end end
def post_type def post_type

View file

@ -17,7 +17,7 @@ class PostPresenter
} }
end end
def next_post_url def next_post_url
if n = next_post if n = next_post
Rails.application.routes.url_helpers.post_path(n) Rails.application.routes.url_helpers.post_path(n)
@ -40,12 +40,11 @@ class PostPresenter
protected protected
def post_base def post_base
scope = if current_user if current_user
Post.owned_or_visible_by_user(current_user) current_user.posts_from(self.post.author)
else else
Post.all_public self.post.author.posts.all_public
end end
scope.where(:author_id => post.author_id)
end end
end end

View file

@ -39,8 +39,8 @@
%i.icon-comment.icon-white %i.icon-comment.icon-white
= link_to image_tag('arrow-left.png'), '#', :class => 'nav-arrow left', :id => 'back' = link_to image_tag('arrow-left.png'), '#', :class => 'nav-arrow left', :id => 'forward'
= link_to image_tag('arrow-right.png'), '#', :class => 'nav-arrow right', :id => 'forward' = link_to image_tag('arrow-right.png'), '#', :class => 'nav-arrow right', :id => 'back'
#comment.modal.fade #comment.modal.fade
.modal-header .modal-header