Merge branch 'master' of github.com:diaspora/diaspora_rails

This commit is contained in:
danielvincent 2010-07-26 15:52:02 -07:00
commit 65acd48885
10 changed files with 53 additions and 6 deletions

View file

@ -2,7 +2,7 @@ class AlbumsController < ApplicationController
before_filter :authenticate_user!
def index
@albums = Album.paginate :page => params[:page], :order => 'created_at DESC'
@albums = Album.mine_or_friends(params[:friends], current_user).paginate :page => params[:page], :order => 'created_at DESC'
end
def create

View file

@ -3,7 +3,7 @@ class AuthorsController < ApplicationController
def show
@author= Author.where(:id => params[:id]).first
@author_ostatus_posts = @author.ostatus_posts.sort(:created_at.desc)
@author_ostatus_posts = @author.ostatus_posts.paginate :page => params[:page], :order => 'created_at DESC'
end

View file

@ -12,7 +12,7 @@ class UsersController < ApplicationController
def edit
@user = User.first(:id => params[:id])
@profile = @user.profile
@photos = Photo.all
@photos = Photo.paginate :page => params[:page], :order => 'created_at DESC'
end
def update

View file

@ -0,0 +1,26 @@
module AlbumsHelper
def friends_albums_link
if params[:friends]
"friends albums"
else
link_to 'friends albums', albums_path({:friends => true})
end
end
def your_albums_link
if params[:friends]
link_to 'your albums', albums_path
else
'your albums'
end
end
def album_person(album)
person = album.person
if album.person_id == current_user.id
link_to "you", user_path(current_user)
else
link_to person.real_name, person_path(person)
end
end
end

View file

@ -20,6 +20,14 @@ class Album
after_save :notify_people
before_destroy :propagate_retraction
def self.mine_or_friends(friend_param, current_user)
if friend_param
Album.where(:person_id.ne => current_user.id)
else
Album.where(:person_id => current_user.id)
end
end
def prev_photo(photo)
n_photo = self.photos.where(:created_at.lt => photo.created_at).sort(:created_at.desc).first
n_photo ? n_photo : self.photos.sort(:created_at.desc).first

View file

@ -33,6 +33,8 @@ class Comment
validates_true_for :post_creator_signature, :logic => lambda {self.verify_post_creator_signature}
xml_accessor :creator_signature
xml_accessor :post_creator_signature
key :creator_signature, String
key :post_creator_signature, String

View file

@ -2,8 +2,13 @@
%div.name
= link_to post.name, object_path(post)
%div.time
by:
= album_person(post)
%br
= link_to(how_long_ago(post), object_path(post))
%div.image_cycle
- for photo in post.photos[0..3]
= image_tag photo.image.url(:thumb_large)

View file

@ -1,7 +1,9 @@
%h1.big_text albums
%h1.big_text
= friends_albums_link
\/
=your_albums_link
%span= link_to ' + ', new_album_path
%h3
= link_to "make a new album", new_album_path
%ul#stream
- for album in @albums
@ -9,3 +11,5 @@
#pagination
= will_paginate @albums
%h3
= link_to "make a new album", new_album_path unless params[:friends]

View file

@ -8,5 +8,6 @@
%ul#stream
- for post in @author_ostatus_posts
= render type_partial(post), :post => post
= will_paginate @author_ostatus_posts
- else
%h3 no posts to display!

View file

@ -17,6 +17,7 @@
%div.small_photo{:id => photo.image.thumb_medium.url}
= check_box_tag 'checked_photo'
= link_to image_tag(photo.image.url(:thumb_medium)), "#"
=will_paginate @photos
%h3 Info