diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 98abbe95bc30c11c334b1e249fe94e32ca4cfd19..9e59ab7412c7b9d9cff725691b02f0a5a6452c77 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -3,12 +3,9 @@ class PhotosController < ApplicationController def create begin - @photo = Photo.instantiate(params[:photo]) + @photo = Photo.instantiate(params) @photo.person = current_user - - - if @photo.save flash[:notice] = "Successfully uploaded photo." redirect_to @photo.album diff --git a/app/models/photo.rb b/app/models/photo.rb index 6571efad5227259e63f27a196986483000b62326..01e79ea3b204ed3ae72f91b1ad9e64befcbdc027 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -15,8 +15,8 @@ class Photo < Post validates_presence_of :album def self.instantiate params = {} - image_file = params[:image] - params.delete :image + image_file = params[:user_file][0] + params.delete :user_file photo = Photo.new(params) photo.image.store! image_file photo diff --git a/app/views/albums/_album.html.haml b/app/views/albums/_album.html.haml index e30c4b4c64d41cc7c6e7548e2568b74be018d744..be8b0b55fb810e9c4f3b3a67a93d92a99a0fe90f 100644 --- a/app/views/albums/_album.html.haml +++ b/app/views/albums/_album.html.haml @@ -5,6 +5,6 @@ %div.time = link_to(how_long_ago(post), object_path(post)) %div.image_cycle - - for photo in post.photos + - for photo in post.photos[0..3] = image_tag photo.image.url(:thumb_large) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0665430a062a8781e61a9edfc418fc5d7fd106fd..948d38e67d04ea7ee2e5af7a3a11f05f9698f86d 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -20,6 +20,8 @@ = javascript_include_tag 'satisfaction' , 'satisfaction-display' + = javascript_include_tag 'jquery.html5_upload' + %body %header .container @@ -53,7 +55,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/photos/_new_photo.haml b/app/views/photos/_new_photo.haml index fd7e58b8a91a53cf8b98ac6fe98da2e8d097eeb1..22bea3e0e063711c525fee790beee3bd4c4ff360 100644 --- a/app/views/photos/_new_photo.haml +++ b/app/views/photos/_new_photo.haml @@ -1,8 +1,42 @@ +:javascript + $(function() { + $("#photo_image").html5_upload({ + // WE INSERT ALBUM_ID PARAM HERE + url: "/photos?album_id=#{album.id}", + sendBoundary: window.FormData || $.browser.mozilla, + onStart: function(event, total) { + return confirm("You are trying to upload " + total + " files. Are you sure?"); + }, + setName: function(text) { + $("#progress_report_name").text(text); + }, + setStatus: function(text) { + $("#progress_report_status").text(text); + }, + setProgress: function(val) { + $("#progress_report_bar").css('width', Math.ceil(val*100)+"%"); + }, + onFinishOne: function(event, response, name, number, total) { + //alert(response); + } + }); + }); + + + + = form_for photo, :html => {:multipart => true} do |f| = f.error_messages = f.hidden_field :album_id, :value => album.id %p - = f.file_field :image - = f.submit 'post it!', :class => 'button' + = f.file_field :image, :multiple => 'multiple' + + #progress_report + #progress_report_name + #progress_report_status{ :style => "font-style: italic;" } + #progress_report_bar_container{ :style => "width: 90%; height: 5px;" } + #progress_report_bar{ :style => "background-color: blue; width: 0; height: 100%;" } + + /= f.submit 'post it!', :class => 'button'