From 0c2fc54c0ff1c90580f16e5fcec880f716ac88db Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 26 Jul 2010 13:29:39 -0700 Subject: [PATCH 1/4] MS we didnt serialize the post creator sig....sigh.... this could not be the problem --- app/models/comment.rb | 2 ++ 1 file changed, 2 insertions(+) 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 From d7550568ade7e2c020e6188db9b4f822f552782f Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 26 Jul 2010 13:55:44 -0700 Subject: [PATCH 2/4] added pagination to photo picker on the user profile. still ugly, less sucky --- app/controllers/users_controller.rb | 2 +- app/views/layouts/application.html.haml | 2 +- app/views/users/edit.html.haml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) 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/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0665430a0..22270d801 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -53,7 +53,7 @@ .span-18.append-3.last = yield .span-3.last - = link_to (person_image_tag(current_user), root_path) + = link_to(person_image_tag(current_user), root_path) = link_to "Edit your profile", edit_user_path(current_user) %br %br 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 From 47f5c77e1abf7f979f885be45a1f2fea2ffcdacf Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 26 Jul 2010 15:09:02 -0700 Subject: [PATCH 3/4] kinda prettied up the albums page --- app/controllers/albums_controller.rb | 2 +- app/helpers/albums_helper.rb | 26 ++++++++++++++++++++++++++ app/models/album.rb | 8 ++++++++ app/views/albums/_album.html.haml | 5 +++++ app/views/albums/index.html.haml | 10 +++++++--- 5 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 app/helpers/albums_helper.rb 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/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/views/albums/_album.html.haml b/app/views/albums/_album.html.haml index e30c4b4c6..0043c0fd6 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 = 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] From 88c83bb0283b54fabc7f025db28e67ba5a15a7c9 Mon Sep 17 00:00:00 2001 From: maxwell Date: Mon, 26 Jul 2010 15:15:42 -0700 Subject: [PATCH 4/4] MS added pagination to the author show page --- app/controllers/authors_controller.rb | 2 +- app/views/authors/show.html.haml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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/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!