diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index 716bcd002..7b4ed0a6d 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -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 diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb index 2f53c442b..f4e6b80c7 100644 --- a/app/controllers/authors_controller.rb +++ b/app/controllers/authors_controller.rb @@ -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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d3a09d9ed..5414ac03a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/helpers/albums_helper.rb b/app/helpers/albums_helper.rb new file mode 100644 index 000000000..a21735e45 --- /dev/null +++ b/app/helpers/albums_helper.rb @@ -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 \ No newline at end of file diff --git a/app/models/album.rb b/app/models/album.rb index 1307cfd2c..14aa95778 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -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 diff --git a/app/models/comment.rb b/app/models/comment.rb index 7643e9eae..1808952a8 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -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 diff --git a/app/views/albums/_album.html.haml b/app/views/albums/_album.html.haml index be8b0b55f..16b2b9d5f 100644 --- a/app/views/albums/_album.html.haml +++ b/app/views/albums/_album.html.haml @@ -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) diff --git a/app/views/albums/index.html.haml b/app/views/albums/index.html.haml index 47f11bd0b..ee4cd4c09 100644 --- a/app/views/albums/index.html.haml +++ b/app/views/albums/index.html.haml @@ -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] diff --git a/app/views/authors/show.html.haml b/app/views/authors/show.html.haml index 364bf6eac..902682434 100644 --- a/app/views/authors/show.html.haml +++ b/app/views/authors/show.html.haml @@ -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! diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 594647c29..565772fd6 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -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