From 6f7f82e818d67f4576e658d08bd3f8d2e759f7f0 Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 21 Jul 2010 15:47:30 -0700 Subject: [PATCH] added helpers for photo show page --- app/helpers/photos_helper.rb | 14 ++++++++++++++ app/views/photos/show.html.haml | 14 +++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 app/helpers/photos_helper.rb diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb new file mode 100644 index 000000000..844223c25 --- /dev/null +++ b/app/helpers/photos_helper.rb @@ -0,0 +1,14 @@ +module PhotosHelper + + def linked_scaled_photo(photo, album) + link_to (image_tag photo.image.url(:scaled_full)), photo_path(album.next_photo(photo)) + end + + def link_to_prev(photo, album) + link_to "<< previous", photo_path(album.prev_photo(photo)) + end + + def link_to_next(photo, album) + link_to "next >>", photo_path(album.next_photo(photo)) + end +end diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 252ac23d0..a3f0915f0 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -1,23 +1,23 @@ - %h3 viewing photos from album - =link_to @album.name, album_path(@album) + = link_to @album.name, album_path(@album) %div{:id => @photo.id} = link_to "full size", @photo.image.url - %br #show_photo - = link_to (image_tag @photo.image.url(:scaled_full)), photo_path(@album.next_photo(@photo)) + = linked_scaled_photo @photo, @album #photo_pagination - = link_to "<< previous", photo_path(@album.prev_photo(@photo)) - = link_to "next >>", photo_path(@album.next_photo(@photo)) + = link_to_prev @photo, @album + | + = link_to_next @photo, @album %p = link_to "Destroy", @photo, :confirm => 'Are you sure?', :method => :delete - | + + %p = link_to "<< back to album", album_path(@album) %h4{:class => "show_post_comments"}