kinda prettied up the albums page

This commit is contained in:
maxwell 2010-07-26 15:09:02 -07:00
parent d7550568ad
commit 47f5c77e1a
5 changed files with 47 additions and 4 deletions

View file

@ -2,7 +2,7 @@ class AlbumsController < ApplicationController
before_filter :authenticate_user! before_filter :authenticate_user!
def index 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 end
def create def create

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 after_save :notify_people
before_destroy :propagate_retraction 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) def prev_photo(photo)
n_photo = self.photos.where(:created_at.lt => photo.created_at).sort(:created_at.desc).first 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 n_photo ? n_photo : self.photos.sort(:created_at.desc).first

View file

@ -2,8 +2,13 @@
%div.name %div.name
= link_to post.name, object_path(post) = link_to post.name, object_path(post)
%div.time %div.time
by:
= album_person(post)
%br
= link_to(how_long_ago(post), object_path(post)) = link_to(how_long_ago(post), object_path(post))
%div.image_cycle %div.image_cycle
- for photo in post.photos - for photo in post.photos
= image_tag photo.image.url(:thumb_large) = 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 %ul#stream
- for album in @albums - for album in @albums
@ -9,3 +11,5 @@
#pagination #pagination
= will_paginate @albums = will_paginate @albums
%h3
= link_to "make a new album", new_album_path unless params[:friends]