Commit 637fd74b

mo khan <mo@mokhan.ca>
2013-07-01 23:06:03
display carousel of additional photos
1 parent 7072ee6
Changed files (3)
app
app/controllers/photos_controller.rb
@@ -1,8 +1,9 @@
 class PhotosController < ApplicationController
   before_filter :authenticate_user!
-  before_filter :find_creation
+  before_filter :find_creation, :except => [:index]
 
   def index
+    @creation = Creation.find(params[:creation_id])
     @photos = @creation.photos
     respond_to do |format|
       format.html # index.html.erb
app/views/creations/show.html.erb
@@ -64,7 +64,7 @@ $(function() {
 <% if @creation.photos_count > 1 %>
   <div class="row">
     <div class="span12">
-      <%= link_to "view all photos &raquo;".html_safe, creation_photos_path(@creation), :class => "pull-right" %>
+      <%= link_to "view #{pluralize(@creation.photos_count-1, "other photo")} &raquo;".html_safe, creation_photos_path(@creation), :class => "pull-right" %>
       <ul class="thumbnails">
       <% @creation.photos.each do |photo| %>
         <li class="span2"><%= image_tag photo.image.thumb.url, :class => "thumbnail" %></li>
app/views/photos/index.html.erb
@@ -0,0 +1,28 @@
+
+<div class="row">
+  <div class="span12">
+    <%= link_to "&laquo; Back to creation".html_safe, creation_path(@creation) %>
+    <div class="row">
+      <div class="span3">&nbsp;</div>
+      <div class="span6">
+        <div id="myCarousel" class="carousel slide">
+          <ol class="carousel-indicators">
+            <% @photos.each_with_index do |photo, index| %>
+              <li data-target="#myCarousel" data-slide-to="<%= index %>" class="<%= index == 0 ? "active" : "" %>"></li>
+            <% end %>
+          </ol>
+          <!-- Carousel items -->
+          <div class="carousel-inner">
+            <% @photos.each_with_index do |photo,index| %>
+              <div class="item <%= index == 0 ? "active" : "" %>"><%= image_tag photo.image.url, :class => "thumbnail" %></div>
+            <% end %>
+          </div>
+          <!-- Carousel nav -->
+          <a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
+          <a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
+        </div>
+      </div>
+      <div class="span3">&nbsp;</div>
+    </div>
+  </div>
+</div>